2

I am having a problem parsing a list of of strings:

syntax: "stringlist intersects ('string1','string2')"

This is tokenised to:

Token.Identifier,
Token.Intersects,
Token.LParen
Token.StringValue,
Token.Comma,
Token.StringValue
Token.RParen

My parser looks like:

static TokenListParser<FilterToken, Token<FilterToken>[]> ConstantList =>
   from l in Token.EqualTo(FilterToken.LParen)
   from values in Token.EqualTo(Token.StringValue).ManyDelimitedBy(Token.EqualTo(Token.Comma))
   from r in Token.EqualTo(Token.RParen)
   select values

The result is: Syntax error(line 1, column 33): unxpected comma ',', expected rparen

Any clues?

Akilawani
  • 29
  • 3
  • 1
    The (partial) parser in your question looks fine to me; I'm happy to dig in further but it'd be much quicker for me to debug if you can post the full code somewhere (a gist?). A single `Program.cs` console app with the token/tokenizer/parser types in it would be ideal, if possible. Cheers! – Nicholas Blumhardt Dec 11 '17 at 22:36
  • Apologies. You are right the code above works fine. The problem was caused by the order of applying parsers. I also had a Factor parser looking for (expression) – Akilawani Dec 21 '17 at 01:44
  • Great, glad you found it :-) – Nicholas Blumhardt Dec 21 '17 at 03:51

0 Answers0