Haskell Parsec parser for an expression starting with a word or parenthesis, ending with end of word or a parenthesis -
i'm trying figure out how write haskell parsec parser consuming of these ruby expressions:
hello("test", 'test2') my_variable hello(world("test")) (hello + " " + world)
when parser starts parsing @ beginning of of these items, should return whole string , stop parsing @ end of item. if of these items followed comma, comma should not consumed.
i've tried few times write parser these types of expressions no success. it's not necessary parse sub-components of these expressions -- don't need full ast. need consume , capture these sorts of chunks.
i thought maybe adequate heuristic involve balancing parentheses , eating content within outer balanced parentheses, in addition preceding identifier. need writing parser works way.
it doesn't make sense try parse without parsing everything. either (a) write structured, correct parser, or (b) write eats input, counting , tracking doesn't parse it. you'll find hard (b) parsec. key question correctness: how parse this(example + "(with" + (weird ("bracketing)?")+"("))
unless parse strings? should bite bullet , write string
parser first, identifier
parser, mutually recursive expression
, argumentlist
, function
parsers. don't have return ast.
Comments
Post a Comment