Branch was accepted but did not progress the lexer #319
Replies: 3 comments
-
What you have doesn't make sense because the following can never progress: Dirs []*DIR `parser:"@@*" json:"dirs"` That is, if the first branch of You'll need to refactor your grammar to remove this. I don't have time to dig into this too deeply, but this is a red flag to me:
Name string `parser:"'<' @('If'|'ElseIf'|'Else')" json:"name,omitempty"` This is almost certainly incorrect, as it's not capturing the structure of the language. eg. the user could type |
Beta Was this translation helpful? Give feedback.
-
I suppose you are correct, I have slightly modified it. You are correct, with the If...if...if...that is because I have nested if statements...like
another example, which is also valid:
I refactored it based upon your advice to the following code
This now allows for multiple If's, but not grouping them unexpectedly. I am still grouping elseif's together and only checking for one else. It seems to work and I can still handle this logically. Thanks for pointing out the now obvious solution. Let me know if you see anything else that is dumb/weird. Edit 2: |
Beta Was this translation helpful? Give feedback.
-
Is it possible to track something like so.
With the above, is it possible to consolidate all of the rewrite Cond's to the next Rule? to satisfy this?
I assume this is not possible due to the sequential nature of the parser, but I figured I would ask. How the Directive work is that all RewriteCond's are paired with the next instance of RewriteRule. What I have is fine if the Rule comes right after the cond, which it normally does, but I don't think it has to. Is this possible? I can't think of any possible way for the parser to look ahead and match it to the RewriteRule. So it would need to find the cond's store them and when it finds the rewrite, it combines it at that point, that way the rewrite is in the right order, but the cond's are attached to it. (Right now I am assuming they are one after another) I think I will have to add a post processing step to my parser for this, to resolve these. |
Beta Was this translation helpful? Give feedback.
-
Hello I have an issue where the "lexer" is not progressing, but I am not sure why, I am probably overcomplicating things
The piece that causes the issue is
IfGroup []*IFENTRY `parser:"EOL* ( (EOL* @@ EOL*)*" json:"ifgroup,omitempty"`
which if I replace with:
IfGroup []*IFENTRY `parser:"EOL* ( (EOL* @@ EOL*)+" json:"ifgroup,omitempty"`
it works, but I want to be able to account for empty if statements. The reason for this is I want to make sure if/else/elseif tags are grouped together when parsing. If I am overcomplicating this and you have a better way, I am all ears :-) Either way I would like to know why this isn't progressing, it seems like it should
Below is my full code.
Beta Was this translation helpful? Give feedback.
All reactions