summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Dolan <mu@netsoc.tcd.ie>2012-09-22 14:03:46 +0100
committerStephen Dolan <mu@netsoc.tcd.ie>2012-09-22 14:03:46 +0100
commita2643cc0d564033c49bffbd0de9a8e797281e73f (patch)
treee00b27b5a0bd58fb5cb1286ee988c0d128b3bac7
parent359d5f33bde0df899985eac3d720f5c6a7f4d580 (diff)
Allow underscores in IDENT tokens. Fixes #3.
IDENT syntax now includes ASCII letters and underscores, so '.foo_bar' now works. Non-ASCII letters won't work in IDENT tokens (it's impossible to tell which non-ascii characters are "letters" without full unicode tables), so '.données' is still a syntax error (the workaround is '.["données"]', since you can put anything you like in a string).
-rw-r--r--lexer.l2
-rw-r--r--testdata4
2 files changed, 5 insertions, 1 deletions
diff --git a/lexer.l b/lexer.l
index e604adab..fe0049a9 100644
--- a/lexer.l
+++ b/lexer.l
@@ -107,7 +107,7 @@
}
-[[:alnum:]]+ { yylval->literal = jv_string(yytext); return IDENT;}
+[a-zA-Z_][a-zA-Z_0-9]* { yylval->literal = jv_string(yytext); return IDENT;}
[ \n\t]+ {}
diff --git a/testdata b/testdata
index 8a289973..307eaa62 100644
--- a/testdata
+++ b/testdata
@@ -61,6 +61,10 @@ null
{"foo": {"bar": 42}, "bar": "badvalue"}
42
+.foo_bar
+{"foo_bar": 2}
+2
+
.["foo"].bar
{"foo": {"bar": 42}, "bar": "badvalue"}
42