Help with simple usage #415
-
Hi all, Just starting to use this library to parse a custom file format, quite similiar to INI files. I am not able to get right the most simple example. This is the file contents
And this is the parser
Getting this error
Any hint ? Thanks |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
Traditional lexer/parsers like Participle operate in two independent phases: the lexer extracts named tokens from the raw text, then the parser uses those tokens to construct an AST. Your lexer only has tokens for "Ident", so when it encounters "==" it fails. You'll need to define rules for any possible text you might encounter. Also note that the rules are tried in order, first match wins. |
Beta Was this translation helpful? Give feedback.
Traditional lexer/parsers like Participle operate in two independent phases: the lexer extracts named tokens from the raw text, then the parser uses those tokens to construct an AST. Your lexer only has tokens for "Ident", so when it encounters "==" it fails. You'll need to define rules for any possible text you might encounter. Also note that the rules are tried in order, first match wins.