Próbuję napisać prosty grammer dla PEG.js które odpowiadają mniej więcej tak:Kłopoty z PEG.js koniec wejścia
some text;
arbitrary other text that can also have µnicode; different expression;
let's escape the \; semicolon, and \not recognized escapes are not a problem;
possibly last expression not ending with semicolon
Więc w zasadzie są to niektóre teksty oddzielone średnikami. Moja uproszczona grammer wygląda następująco:
start
= flow:Flow
Flow
= instructions:Instruction*
Instruction
= Empty/Text
TextCharacter
= "\\;"/
.
Text
= text:TextCharacter+ ';' {return text.join('')}
Empty
= Semicolon
Semicolon "semicolon"
= ';'
Problemem jest to, że jeśli mogę umieścić coś innego niż średnik na wejściu, otrzymuję:
SyntaxError: Expected ";", "\\;" or any character but end of input found.
Jak rozwiązać ten problem? Czytałem, że PEG.js nie jest w stanie dopasować końca wejścia.
FWIW, możesz dopasować koniec wejścia za pomocą '! .' – ebohlman