[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator 37d9fcb 260/434: Improved documentatio
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator 37d9fcb 260/434: Improved documentation |
Date: |
Mon, 29 Nov 2021 15:59:53 -0500 (EST) |
branch: externals/parser-generator
commit 37d9fcb7d95cace5f4d0361c920270a4144e82d7
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Improved documentation
---
README.md | 2 +-
docs/Lexical-Analysis.md | 4 ++-
docs/Syntax-Analysis.md | 29 ++++++++++++++--------
.../LRk.md} | 10 ++++++--
4 files changed, 31 insertions(+), 14 deletions(-)
diff --git a/README.md b/README.md
index f5c30e1..5e7c233 100644
--- a/README.md
+++ b/README.md
@@ -11,7 +11,7 @@ This is just started, so most stuff are *WIP*.
We use a regular-language based lexical analyzer that can be implemented by a
finite-state-machine (FSM). Read more [here](docs/Lexical-Analysis.md).
-## Syntax Analysis
+## Syntax Analysis / Parser
We use deterministic push down transducer (PDT) based algorithms. Read more
[here](docs/Syntax-Analysis.md).
diff --git a/docs/Lexical-Analysis.md b/docs/Lexical-Analysis.md
index 711703c..45f4b8c 100644
--- a/docs/Lexical-Analysis.md
+++ b/docs/Lexical-Analysis.md
@@ -22,6 +22,7 @@ Returns the look-ahead number of next terminals in stream.
(setq index (1+ index)))
(nreverse tokens))))
(parser-generator-lex-analyzer--reset)
+
(setq parser-generator--look-ahead-number 1)
(should
(equal
@@ -38,7 +39,7 @@ Returns the look-ahead number of next terminals in stream.
### Pop token
-Returns the next token in stream and moves index one forward.
+Returns the next token in stream and moves the index one point forward.
``` emacs-lisp
(require 'ert)
@@ -56,6 +57,7 @@ Returns the next token in stream and moves index one forward.
(setq index (1+ index)))
(nreverse tokens))))
(parser-generator-lex-analyzer--reset)
+
(should
(equal
'(a)
diff --git a/docs/Syntax-Analysis.md b/docs/Syntax-Analysis.md
index bae8d00..7bca4da 100644
--- a/docs/Syntax-Analysis.md
+++ b/docs/Syntax-Analysis.md
@@ -13,7 +13,7 @@ We use push down transducer (PDT) based algorithms.
* LL(k) *WIP*
* Deterministic Shift-Reduce Parsing *WIP*
-* [LR(k)](Deterministic-Right-Parser-for-LRk-Grammars.md)
+* [LR(k)](Syntax-Analysis/LRk.md)
* Formal Shift-Reduce Parsing Algorithms *WIP*
* Simple Precedence Grammars *WIP*
* Extended Precedence Grammars *WIP*
@@ -42,10 +42,14 @@ Grammar consists of `N`, `T`, `P` and `S`, where `N` is
non-terminals, `T` is te
(parser-generator-set-grammar '((S A B C) (a b c) ((S (A B)) (A (B a) e) (B (C
b) C) (C c e)) S))
```
-### e
+### e-identifier
The symbol defined in variable `parser-generator--e-identifier`, with
default-value: 'e`, symbolizes the e symbol. The symbol is allowed in some
grammars and not in others.
+### End-of-file identifier
+
+The symbol defined in variable `parser-generator--eof-identifier`, with
default-value: '$`, symbolizes the end-of-file symbol.
+
### Non-terminals
A non-terminal is either a symbol or a string so `"A"` and `A` are equally
valid.
@@ -86,8 +90,9 @@ Is a simple integer above zero. You set it like this:
`(parser-generator-set-loo
A optional translation is defined as a lambda function as the last element of
a production right-hand-side, example:
-```
-(parser-generator-set-grammar '((Sp S) ("a" "b") ((Sp S) (S (S "a" S "b"
(lambda(args) (nreverse args)))) (S e)) Sp))
+```emacs-lisp
+(parser-generator-set-grammar
+ '((Sp S) ("a" "b") ((Sp S) (S (S "a" S "b" (lambda(args) (nreverse args))))
(S e)) Sp))
```
You cannot have a SDT + SA on the same production right-hand side, just one or
the other.
@@ -96,8 +101,9 @@ You cannot have a SDT + SA on the same production right-hand
side, just one or t
A optional semantic action is defined as a lambda function as the last element
of a production right-hand-side, example:
-```
-(parser-generator-set-grammar '((Sp S) ("a" "b") ((Sp S) (S (S "a" S "b"
(lambda(args) (nreverse args)))) (S e)) Sp))
+```emacs-lisp
+(parser-generator-set-grammar
+ '((Sp S) ("a" "b") ((Sp S) (S (S "a" S "b" (lambda(args) (nreverse args))))
(S e)) Sp))
```
You cannot have a SDT + SA on the same production right-hand side, just one or
the other.
@@ -111,7 +117,8 @@ Calculate the first look-ahead number of terminals of the
sentential-form `S`, e
``` emacs-lisp
(require 'ert)
-(parser-generator-set-grammar '((S A B C) (a b c) ((S (A B)) (A (B a) e) (B (C
b) C) (C c e)) S))
+(parser-generator-set-grammar
+ '((S A B C) (a b c) ((S (A B)) (A (B a) e) (B (C b) C) (C c e)) S))
(parser-generator-set-look-ahead-number 2)
(parser-generator-process-grammar)
@@ -123,12 +130,13 @@ Calculate the first look-ahead number of terminals of the
sentential-form `S`, e
### E-FREE-FIRST(S)
-Calculate the e-free-first look-ahead number of terminals of sentential-form
`S`, example:
+Calculate the e-free-first look-ahead number of terminals of sentential-form
`S`, if you have multiple symbols the e-free-first will only affect the first
symbol, the rest will be treated via first-function (above). Example:
``` emacs-lisp
(require 'ert)
-(parser-generator-set-grammar '((S A B C) (a b c) ((S (A B)) (A (B a) e) (B (C
b) C) (C c e)) S))
+(parser-generator-set-grammar
+ '((S A B C) (a b c) ((S (A B)) (A (B a) e) (B (C b) C) (C c e)) S))
(parser-generator-set-look-ahead-number 2)
(parser-generator-process-grammar)
@@ -145,7 +153,8 @@ Calculate the look-ahead number of terminals possibly
following S.
``` emacs-lisp
(require 'ert)
-(parser-generator-set-grammar '((S A B) (a c d f) ((S (A a)) (A B) (B (c f)
d)) S))
+(parser-generator-set-grammar
+ '((S A B) (a c d f) ((S (A a)) (A B) (B (c f) d)) S))
(parser-generator-set-look-ahead-number 2)
(parser-generator-process-grammar)
diff --git a/docs/Deterministic-Right-Parser-for-LRk-Grammars.md
b/docs/Syntax-Analysis/LRk.md
similarity index 91%
rename from docs/Deterministic-Right-Parser-for-LRk-Grammars.md
rename to docs/Syntax-Analysis/LRk.md
index 65f7fb5..127986f 100644
--- a/docs/Deterministic-Right-Parser-for-LRk-Grammars.md
+++ b/docs/Syntax-Analysis/LRk.md
@@ -1,4 +1,6 @@
-# Deterministic Right Parser for LR(k) Grammars
+# LRk Parser
+
+LR(k) parser is the left-to-right parse calculating a right-derivation in
reverse invented by Donald Knuth.
This library contains functions to parse and translate grammar as well as
validate grammars.
@@ -89,4 +91,8 @@ Perform a right-parse of input-stream.
(parser-generator-lr-parse)))
```
-[Back to start](../../../)
+## Translate
+
+Coming soon!
+
+[Back to syntax analysis](../../Syntax-Analysis.md)
- [elpa] externals/parser-generator 47fb35e 229/434: More work on a more generalized LR Parser, (continued)
- [elpa] externals/parser-generator 47fb35e 229/434: More work on a more generalized LR Parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 9b6e076 231/434: Using lowercase epsilon for e-identifier comment, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 01173e2 230/434: Added EOF identifier, passing all unit tests, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator a76bb98 240/434: Added comments, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 3807a72 237/434: Added failing unit test for LR-items k=2, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 40473d3 252/434: Fixed bug with data in full look-ahead in parse function, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator e1315c3 246/434: Updated so E-FREE-FIRST(x) only uses E-FREE-FIRST on first symbol, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 53ae129 245/434: Commented out useless code, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 24e96cb 261/434: Improved description of LRk, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 40907b7 257/434: white-space fixes, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 37d9fcb 260/434: Improved documentation,
ELPA Syncer <=
- [elpa] externals/parser-generator 08b696f 267/434: Fixed typo in doc about token, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator b80fc6e 264/434: Updated README, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 1b9d8db 268/434: Improved wording about lexical analysis, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 3615fad 276/434: Fixed issue with lex-analyzer in LR(0) Parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 732cd78 282/434: Constants and variables are exported correctly, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator cbf9e07 278/434: Added documentation about LR(0) Parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator af71d8b 285/434: Lex-analyzer is now exported, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 500d082 284/434: Added Lex-Analyzer Rest Function to export, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator cf42e67 288/434: Exported parser passes test, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 1e0418d 295/434: Incremental parse and translate of exported parser passes tests, ELPA Syncer, 2021/11/29