fimpp icon indicating copy to clipboard operation
fimpp copied to clipboard

"and" in conditional expressions confused with tuple syntax.

Open avian2 opened this issue 8 years ago • 0 comments

Conjuctions don't work well because the parser confuses the word and with the syntax for tuples.

For instance, this works with or:

Applejack has more than one or Pinkie Pie has more than one

[1.60] parsed: Alternative(
  List(
    Relational(
      VariableValue(applejack),>,NumberValue(1)
    ), 
    Relational(
      VariableValue(pinkie pie),>,NumberValue(1)
    )
  )
)

However, replacing or with and:

Applejack has more than one and Pinkie Pie has more than one

[1.47] failure: ‘Has’ ain't no pony I've heard of. Do they have tea parties with ‘Has’?

The source of the problem is that the parser attempts to make a tuple from one and Pinkie Pie has ..., which in turn attempts to make an identifier from Pinkie Pie has .... This then fails here because has is a keyword.

~~I think ^? combinator is not the right approach here. The check for keywords should make the parser backtrack instead of failing.~~

avian2 avatar Mar 25 '17 09:03 avian2