Questions tagged [peg]

A “Parsing Expression Grammar” (“PEG”) is a formal language to describe formal languages.

A Parsing Expression Grammar (“PEG”) is a formal language that defines a set of rules to describe a certain class of formal languages similar to context-free grammars.

In comparison to context-free grammars, PEGs have the advantage of always being unambiguous, and of mapping naturally to recursive descent parsers, which makes them easy to implement.

288 questions
-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
-4
votes
1 answer

Writing a small app using Rust, pest; how can I fix this error?

Have been doing a small project on Rust. My app must paint a graph of a linear expression that it has been given. The libraries I am using are pest and plotters. The issue is in the PEG grammar. Here are two versions (both don't work): 1. number =…
effrereal
  • 1
  • 1
1 2 3
19
20