3 ms·
I love love love ragel. Won't the code here: https://github.com/gritzko/librdx/blob/master/JSON.lex https://github.com/gritzko/librdx/blob/master/JSON.lex ac
by djoldman 2y ago
I love love love ragel.
Won't the code here:
https://github.com/gritzko/librdx/blob/master/JSON.lex https://github.com/gritzko/librdx/blob/master/JSON.lex
accept "[" as valid json?
delimiter = OpenObject | CloseObject | OpenArray | CloseArray | Comma | Colon;
primitive = Number | String | Literal;
JSON = ws* ( primitive? ( ws* delimiter ws* primitive? )* ) ws*;
Root = JSON;
(pick zero of everything in JSON except one delimiter...)
I usually begin with the RFCs:
https://datatracker.ietf.org/doc/html/rfc4627#autoid-3 https://datatracker.ietf.org/doc/html/rfc4627#autoid-3
I'm not sure one can implement JSON with ragel... I believe ragel can only handle regular languages and JSON is context free.
- gritzko 2y agoThat is a lexer, so yes, it accepts almost any sequence of valid tokens. Pure Ragel only parses regular languages, but there are ways.