Sto cercando di scrivere un semplice Grammer per PEG.js che corrisponda o meno così:Problemi con PEG.js fine dell'input
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
Quindi, in pratica questi sono alcuni testi separati da un punto e virgola. La mia grammatica semplificata simile a questa:
start
= flow:Flow
Flow
= instructions:Instruction*
Instruction
= Empty/Text
TextCharacter
= "\\;"/
.
Text
= text:TextCharacter+ ';' {return text.join('')}
Empty
= Semicolon
Semicolon "semicolon"
= ';'
il problema è che se metto qualcosa di diverso da un punto e virgola ingresso, ottengo:
SyntaxError: Expected ";", "\\;" or any character but end of input found.
Come risolvere questo problema? Ho letto che PEG.js non è in grado di eguagliare la fine dell'input.
FWIW, è possibile abbinare la fine dell'input con '! .' – ebohlman