-
Notifications
You must be signed in to change notification settings - Fork 66
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Ambiguous grammar handling #273
Comments
use for your regex you might want to try some rules like
I guess. (not well tested, best to make your own grammar to fully understand) I don't see how can it contain unbalanced parentheses? Based my grammar mostly on a very lightweight PCRE syntax now, not sure what you have. |
@WebFreak001 thanks for your answer! and sorry for such delay. First of all, my grammar description.
So, you think i should use regex grammar for such kind of parameter?
Scope expression described on line 181:
Well, i'll think where i can use |
for 1 you should implement a proper string parser (as you have the value quoted, which would mean it couldn't be unbalanced parentheses if done properly), look at https://github.com/PhilippeSigaud/Pegged/blob/master/pegged/examples/strings.d if your values are unquoted, look at my regex grammar I posted which will make it balanced too for 2: if it is always in this order (everything before last colon is logical and) then it is easy to describe as rule using lookaheads like
if it's not always in this order, and dependent on the name of the identifier you write in there (being any arbitrary variable you defined earlier) you will either parse it as one list and resolve it later as part of your libraries API or try to implement it using semantic actions. |
Hello and thanks for awesome library!
I'm trying to implement Qt's
qmake
project files parser from scratch.But i've found two issues:
AND
operator and single-line code block delimiterfunc(var, ([A-Z])+)
, which can contain unbalanced parenthesizes and made function call statement ambiguous tooSo the qmake language cannot be described using PEG.
However, i've managed to
reinvent a wheeladd "preprocessor" code eliminating those issues using naive parser.It's just replaces "delimiter colon" with "@" char, and enquote regular expressions.
The resulting code already can be parsed using PEG/pegged.
Does
pegged
have some built-in stuff to help fighting with such kind of ambiguous grammars?Or just i chose the wrong tool.
Thanks!
P.S. Link to my project using
pegged
The text was updated successfully, but these errors were encountered: