PEG: Difference between revisions

From Lojban
Jump to navigation Jump to search
m (Gleki moved page jbocre: PEG to PEG without leaving a redirect: Text replace - "jbocre: ([A-Z])" to "$1")
m (Text replace - "jbocre: ([A-K])" to "$1")
Line 8: Line 8:
==  4th Baseline Machine Grammar Proposal ==
==  4th Baseline Machine Grammar Proposal ==


[[jbocre: .alyn.post.|.alyn.post.]] is working on a proposal for a 4th Machine Grammar Baseline, replacing the 3rd baseline's [[jbocre: YACC|YACC]] grammar with a PEG grammar.  This work is scheduled for inclusion into [[jbocre: Suggestions for CLL, second edition LL version 2.0]] or [[jbocre: CLL Peg Errata LL version 2.1]].
[[jbocre: .alyn.post.|.alyn.post.]] is working on a proposal for a 4th Machine Grammar Baseline, replacing the 3rd baseline's [[jbocre: YACC|YACC]] grammar with a PEG grammar.  This work is scheduled for inclusion into [[jbocre: Suggestions for CLL, second edition LL version 2.0]] or [[CLL Peg Errata LL version 2.1]].


===  Morphology ===
===  Morphology ===
Line 27: Line 27:
The CLL will need to be updated to account for changes resulting from the translation of the grammar to PEG.
The CLL will need to be updated to account for changes resulting from the translation of the grammar to PEG.


Main Article: [[jbocre: CLL PEG Errata|CLL PEG Errata]]
Main Article: [[CLL PEG Errata|CLL PEG Errata]]


===  Uncategorized Material ===
===  Uncategorized Material ===


** [[jbocre: Practicable syntax changes|Practicable syntax changes]]
** [[jbocre: Practicable syntax changes|Practicable syntax changes]]
** [[jbocre: Exploiting the preparser|Exploiting the preparser]]
** [[Exploiting the preparser|Exploiting the preparser]]


*** [[jbocre: rant about "exploiting the preparser"|rant about "exploiting the preparser"]]
*** [[jbocre: rant about "exploiting the preparser"|rant about "exploiting the preparser"]]
Line 50: Line 50:


* [http://www.teddyb.org/~rlpowell/hobbies/lojban/grammar/ obin Powell's PEG Grammar Page].  This document builds on the work [[camgusmis|camgusmis]] and [[User:xorxes|xorxes]] have done, documented on this page.
* [http://www.teddyb.org/~rlpowell/hobbies/lojban/grammar/ obin Powell's PEG Grammar Page].  This document builds on the work [[camgusmis|camgusmis]] and [[User:xorxes|xorxes]] have done, documented on this page.
* [[jbocre: Grammar|Grammar]], for a discussion of Lojban's grammar beyond PEG.
* [[Grammar|Grammar]], for a discussion of Lojban's grammar beyond PEG.


* [[jbocre: YACC|YACC]], the language in which Lojban's official grammar is defined.
* [[jbocre: YACC|YACC]], the language in which Lojban's official grammar is defined.
* [[BNF|BNF]], widely considered easier to read than the YACC grammar.
* [[BNF|BNF]], widely considered easier to read than the YACC grammar.

Revision as of 14:51, 23 March 2014

Parsing Expression grammars. Parsing expression grammars allow for full lookahead and backtracking in time linear to the input size. This makes them more expressive than YACC or BNF, which are limited in the how far they look ahead, and as a consequence how far they can backtrack. They also require more memory than either YACC or BNF to parse an equivalently sized input.

PEG grammars also do not have a separate lexing stage. Lexing and parsing are performed at the same time, using the same language for both.

See wikipedia for additional general information on arsing Expression Grammars.

4th Baseline Machine Grammar Proposal

.alyn.post. is working on a proposal for a 4th Machine Grammar Baseline, replacing the 3rd baseline's YACC grammar with a PEG grammar. This work is scheduled for inclusion into jbocre: Suggestions for CLL, second edition LL version 2.0 or CLL Peg Errata LL version 2.1.

Morphology

Since PEG does not have a separate lexing stage, any PEG Machine Grammar will also need to express the Lojban Morphology in PEG.

Technical Points of the PEG language

  • The '.' characters means any character, in any character set. It is only used after fa'o, which unconditionally consumes the remaining characters.
  • '!.' is the way EOF is tested in PEG.
  • space is defined as the literal '.' (as opposed to the '.' operator of PEG), whitespace, and all punctuation other than ',' and .

CLL

The CLL will need to be updated to account for changes resulting from the translation of the grammar to PEG.

Main Article: CLL PEG Errata

Uncategorized Material

Open Discussion Points

  • jbogenturfa'i further transforms the PEG grammar into an idealized representation. This parse tree is suitable for programmatic manipulation. Why is this idealized parse tree not the way the PEG is written?

Lojban parsers that use PEG

See Also

  • YACC, the language in which Lojban's official grammar is defined.
  • BNF, widely considered easier to read than the YACC grammar.