ed-cooper / Ebnf.Compiler

Compiles EBNF statements to C# DLLs
MIT License
2 stars 0 forks source link

Semi-colon in literals interpreted as end of statement #5

Closed furesoft closed 5 years ago

ed-cooper commented 5 years ago

Hi, please clarify what you mean here or I'll have to close the issue.

furesoft commented 5 years ago

when i have the rule: expression = keyword, ";";

it does not parse true, but it should be true

ed-cooper commented 5 years ago

Thanks for pointing this out.

This is caused by statements being split by semi-colon, regardless of whether this semi-colon is inside a literal.

See https://github.com/ed-cooper/Ebnf.Compiler/blob/master/EBNF.Compiler/Compiler.cs#L67

As a temporary solution, please try this alternative statement and if you could feedback to me whether it works as expected that would be helpful:

expression = keyword, "\u003B";
furesoft commented 5 years ago

solution:

make custom split method, if char to split is in quotes then not split it. i have implemented this function, but i must search in my archive

ed-cooper commented 5 years ago

In the latest commit, I've added a method called SanitiseStatement which contains functionality to only remove spaces when they are outside literals.

This can be abstracted to also work for this situation.