Open oovm opened 2 years ago
Hi, that is an interesting point. I will try to find a fix, it might require some additions to the API. This page gives some ideas about how to support the juxtaposition operator in a pratt parser. In our case, I think we need to modify the lbp
and led
to do something when encountering a prefix and nilfix (primary) expression.
@oovm do you possibly have an example grammar to test?
@segeljakt
I created a test case here, the content after juxtaposition will be discarded.
This is the implementation part of pratt parser:
There is another problem.
In regular language, prefix +
and infix +
can be distinguished by this expression:
Expr : Term (Infix Term)*
Term : Prefix* Factor Suffix*
But in languages with juxtaposition, only expressions like this can be used
Expr :
| Prefix
| Infix
| Factor
| Suffix
At this time infix +
will be overwritten by prefix +
.
Is there any way to mark such polymorphic operators?
This problem also exists with the prefix !
(not) and the suffix !
(factorial).
eg: x^5!y
-> x^(5!)*y
In the lexer stage, I have no way of knowing whether the previous expression terminates.
Hi, I'm sorry for the late response. I am currently working towards a deadline so I haven't had time to take a look. I will return as soon as possible.
I came across a special syntax where a space between two Primary expressions indicates a special connection.
For example:
In the current situation, two consecutive Primary expressions will cause the following expressions to disappear directly.
Is there any suitable patch hacking?