summaryrefslogtreecommitdiffstats
path: root/debug.h
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2021-05-26 22:48:52 -0700
committerKaz Kylheku <kaz@kylheku.com>2021-05-26 22:48:52 -0700
commit2df469c3cda02c07f17e65cdaae5d9d16dc6b978 (patch)
treeba88b0ceff362bf8f544fbac9bd389eda7da486a /debug.h
parent644a28827acc238aefcd907820eed3378d41e3eb (diff)
downloadtxr-2df469c3cda02c07f17e65cdaae5d9d16dc6b978.tar.gz
txr-2df469c3cda02c07f17e65cdaae5d9d16dc6b978.tar.bz2
txr-2df469c3cda02c07f17e65cdaae5d9d16dc6b978.zip
New #J syntax for JSON objects in TXR Lisp.
(needs buffer literal error message cleanup) * parser.c (json_s): New symbol variable. (is_balanced_line): Follow braces out of initial state. This concession allows the listener to accept input like #J{"a":"b"}. (me_json): New static function (macro expander). The #J X syntax produces a (json Y) form, with the JSON syntax X translated to a Lisp object Y. If that is evaluated, this macro translates it to (quote Y). (parse_init): initialize json_s variable with interned symbol, and register the json macro. * parser.h (json_s): Declared. (end_of_json): Declared. * parser.l (num_esc): Treat u escape sequences in the same way as x. This function can then be used for handling the \u escapes in JSON string literals. (DIG19, JNUM, JPUNC, NJPUNC): New lex named patterns. (JSON, JLIT): New lex start conditions. (grammar): Recognize #J syntax, mapping to HASH_J token, which transitions into JSON start state. In JSON start state, handle all the elements: numbers, keywords, arrays and objects. Transition into JLIT state. In JLIT start state, handle all the elements of JSON string literals, including surrogate pair escapes. JSON literals share the fallback {UANY} fallback patter with other literals. (end_of_jason): New function. * parser.y (HASH_J, JSKW): New token symbols. (json, json_val, json_vals, json_pairs): New nonterminal symbols, and rules. (i_expr, n_expr): Generate json nonterminal, to hook the stuff into the grammar. (yybadtoken): Handle JKSW and HASH_J tokens. * lex.yy.c.shipped, y.tab.c.shipped, y.tab.h.shipped: Updated.
Diffstat (limited to 'debug.h')
0 files changed, 0 insertions, 0 deletions