You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Where FIRST, S_E_C_O_N_D, third, FOURTH some macros, and abc, efg, abc.efg macros arguments (zero or more). I write parser, but I don't understand how to separate macros and arguments tokenization.
classCMake : Grammar<Any?>() {
valLINE_COMMENT by token("#.*", ignore =true)
valNL by token("[\r\n]+", ignore =true)
valWS by token("\\s+", ignore =true)
valO_PAREN by token("\\(")
valC_PAREN by token("\\)")
valIDENT by token("[A-Za-z_][A-Za-z0-9_]*")
valARG by token("[^\\s()#]+")
val macros by IDENT*-O_PAREN* optional(parser(this::arguments)) *-C_PARENval arguments by separated(parser(this::ARG), WS, true)
overrideval rootParser by oneOrMore(macros)
}
This parser throw exception Could not parse input: MismatchedToken(expected=C_PAREN (\)), found=IDENT for "abc" at 6 (1:7)), but abc is ARG, not IDENT.
Thanks for help!
The text was updated successfully, but these errors were encountered:
rndev-io
changed the title
Separate similar tokens
Help with parser
May 7, 2020
Hi, cool and useful library, thanks!
I need help to write parser for next grammar (it's some subset of CMake grammar)
Where
FIRST, S_E_C_O_N_D, third, FOURTH
some macros, andabc, efg, abc.efg
macros arguments (zero or more). I write parser, but I don't understand how to separate macros and arguments tokenization.This parser throw exception
Could not parse input: MismatchedToken(expected=C_PAREN (\)), found=IDENT for "abc" at 6 (1:7))
, butabc
isARG
, notIDENT
.Thanks for help!
The text was updated successfully, but these errors were encountered: