diff options
author | Kaz Kylheku <kaz@kylheku.com> | 2021-05-28 21:07:46 -0700 |
---|---|---|
committer | Kaz Kylheku <kaz@kylheku.com> | 2021-05-28 21:07:46 -0700 |
commit | 5d42362d611c9103a07f768d8d2bcc1911e0f41b (patch) | |
tree | b3108e56546a98596fcded61d559cd89ddf8d317 /parser.y | |
parent | f24dad0044cd108c537477373a20027ee660de4c (diff) | |
download | txr-5d42362d611c9103a07f768d8d2bcc1911e0f41b.tar.gz txr-5d42362d611c9103a07f768d8d2bcc1911e0f41b.tar.bz2 txr-5d42362d611c9103a07f768d8d2bcc1911e0f41b.zip |
json: get-json function.
* eval.c (eval_init): get-json intrinsic registered.
* parser.c (prime_parser): Handle prime_json.
(lisp_parse_impl): Take enum prime_parser argument
directly instead of the interactive flag.
(lisp_parse, nread, iread): Pass appropriate prime_parser
value instead of the original flag.
(get_json): New function. Like nread, but passes prime_json.
* parser.h (enum prime_parser): New constant, prime_json.
(get_json): Declared.
* parser.l (prime_scanner): Handle prime_json.
* parser.y (SECRET_ESCAPE_J): New terminal symbol.
(spec): New productions around SECRET_ESCAPE_J for parsing
JSON.
* lex.yy.c.shipped, y.tab.c.shipped, y.tab.h.shipped: Updated.
* txr.1: Documented.
* share/txr/stdlib/doc-syms.tl: Updated.
Diffstat (limited to 'parser.y')
-rw-r--r-- | parser.y | 12 |
1 files changed, 11 insertions, 1 deletions
@@ -120,7 +120,7 @@ INLINE val expand_form_ver(val form, int ver) %token <lineno> HASH_BACKSLASH HASH_SLASH DOTDOT HASH_H HASH_S HASH_R HASH_J %token <lineno> HASH_SEMI HASH_B_QUOTE HASH_N HASH_T %token <lineno> WORDS WSPLICE QWORDS QWSPLICE -%token <lineno> SECRET_ESCAPE_R SECRET_ESCAPE_E SECRET_ESCAPE_I +%token <lineno> SECRET_ESCAPE_R SECRET_ESCAPE_E SECRET_ESCAPE_I SECRET_ESCAPE_J %token <lineno> OLD_DOTDOT %token <val> NUMBER METANUM JSKW @@ -195,6 +195,16 @@ spec : clauses_opt { set_syntax_tree(parser, $1); } yybadtok(yychar, nil); parser->syntax_tree = nil; } } + | SECRET_ESCAPE_J json_val { set_syntax_tree(parser, $2); + YYACCEPT; } + byacc_fool { internal_error("notreached"); } + | SECRET_ESCAPE_J { if (yychar == YYEOF) { + parser->syntax_tree = nao; + YYACCEPT; + } else { + yybadtok(yychar, nil); + parser->syntax_tree = nil; + } } | error '\n' { parser->syntax_tree = nil; if (parser->errors >= 8) YYABORT; |