1
0
mirror of https://github.com/stedolan/jq.git synced 2024-05-11 05:55:39 +00:00

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).
This commit is contained in:
Stephen Dolan
2012-09-22 14:03:46 +01:00
parent 359d5f33bd
commit a2643cc0d5
2 changed files with 5 additions and 1 deletions

View File

@@ -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]+ {}

View File

@@ -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