Questions tagged [pegjs]

PEG.js is a simple parser generator for JavaScript that produces fast parsers with excellent error reporting. Forked to a now-maintained version called Peggy.

PEG.js is a simple parser generator for JavaScript that produces fast parsers with excellent error reporting.

See https://pegjs.org/

The project was forked to create Peggy, which is now maintained at:

https://peggyjs.org/

123 questions
0
votes
2 answers

PEGjs: Fallback (backtrack?) to string if floating point rule fail

I have an atom rule that tries to parse everything as either a number or a quoted string first, if that fails, then treat the thing as a string. Everything parses fine except one particular case that is this very specific string: DUD 123abc Which…
chakrit
  • 61,017
  • 25
  • 133
  • 162
-1
votes
2 answers

Join letters to 1 word

I'm playing around with PEG.js. This is my grammar: start = expression expression = a:[a-z]+ {return a.join("");} When I execute it in my browser: obj = parser.parse("test"); for (var i = 0; i <= obj.length; i++) { console.log(i + " - " +…
Evgenij Reznik
  • 17,916
  • 39
  • 104
  • 181
-1
votes
3 answers

How can I write a simple pegjs grammar for this text file?

I just want to segment this text file into lines and to classify the lines. If the line starts with "Qty" then the next lines are the order items until the line starts with "GST". If the line starts with "Total Amount" Then this is the total amount…
Phil
  • 46,436
  • 33
  • 110
  • 175
1 2 3
8
9