[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator 53980d4 102/434: More documentation
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator 53980d4 102/434: More documentation |
Date: |
Mon, 29 Nov 2021 15:59:18 -0500 (EST) |
branch: externals/parser-generator
commit 53980d44e55cf280731e17931a354789690a810a
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
More documentation
---
README.md | 77 ++++++++++++++++++++++++++++++++++++++-------------------------
1 file changed, 47 insertions(+), 30 deletions(-)
diff --git a/README.md b/README.md
index 66e088d..6a7c9af 100644
--- a/README.md
+++ b/README.md
@@ -42,6 +42,44 @@ Example with grammar with production: S -> SaSb and S is
non-terminal and a, b a
* B, C is parts of the production RHS, if the dot is the left B is nil and C
is the entire RHS. If the dot is at the right then B is the production RHS and
C is nil, otherwise B and C contains parts of the RHS
* L is the terminal look-ahead
+### LR items for prefix (S)
+
+Calculate the set of LR items valid for any viable prefix S.
+
+### Functions
+
+``` emacs-lisp
+(require 'ert)
+
+(parser--set-grammar '((Sp S) (a b) ((Sp S) (S (S a S b)) (S e)) Sp))
+(parser--set-look-ahead-number 1)
+(parser--process-grammar)
+
+(should
+ (equal
+ '((S nil (S a S b) (a))
+ (S nil (S a S b) (e))
+ (S nil nil (a))
+ (S nil nil (e))
+ (Sp nil (S) (e)))
+ (parser--lr-items-for-prefix 'e)))
+```
+
+``` emacs-lisp
+(require 'ert)
+
+(parser--set-grammar '((Sp S) (a b) ((Sp S) (S (S a S b)) (S e)) Sp))
+(parser--set-look-ahead-number 1)
+(parser--process-grammar)
+
+(should
+ (equal
+ '((S (S) (a S b) (a))
+ (S (S) (a S b) (e))
+ (Sp (S) nil (e)))
+ (parser--lr-items-for-prefix 'S)))
+```
+
#### Formal Shift-Reduce Parsing Algorithms
#### Simple Precedence Grammars
#### Extended Precedence Grammars
@@ -120,8 +158,11 @@ Calculate the first look-ahead number of terminals of the
sentential-form `S`, e
``` emacs-lisp
(require 'ert)
+
(parser--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--set-look-ahead-number 2)
+(parser--process-grammar)
+
(should
(equal
'((a) (a c) (a b) (c a) (b a) (e) (c) (b) (c b))
@@ -134,8 +175,11 @@ Calculate the e-free-first look-ahead number of terminals
of sentential-form `S`
``` emacs-lisp
(require 'ert)
+
(parser--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--set-look-ahead-number 2)
+(parser--process-grammar)
+
(should
(equal
'((c b) (c a))
@@ -148,44 +192,17 @@ Calculate the look-ahead number of terminals possibly
following S.
``` emacs-lisp
(require 'ert)
+
(parser--set-grammar '((S A B) (a c d f) ((S (A a)) (A B) (B (c f) d)) S))
(parser--set-look-ahead-number 2)
+(parser--process-grammar)
+
(should
(equal
'((a))
(parser--follow 'A)))
```
-### LR items for prefix (S)
-
-Calculate the set of LR items valid for any viable prefix S.
-
-``` emacs-lisp
-(require 'ert)
-(parser--set-grammar '((Sp S) (a b) ((Sp S) (S (S a S b)) (S e)) Sp))
-(parser--set-look-ahead-number 1)
-(should
- (equal
- '((S nil (S a S b) (a))
- (S nil (S a S b) (e))
- (S nil nil (a))
- (S nil nil (e))
- (Sp nil (S) (e)))
- (parser--lr-items-for-prefix 'e)))
-```
-
-``` emacs-lisp
-(require 'ert)
-(parser--set-grammar '((Sp S) (a b) ((Sp S) (S (S a S b)) (S e)) Sp))
-(parser--set-look-ahead-number 1)
-(should
- (equal
- '((S (S) (a S b) (a))
- (S (S) (a S b) (e))
- (Sp (S) nil (e)))
- (parser--lr-items-for-prefix 'S)))
-```
-
## Test
Run in terminal `make clean && make tests && make compile`
- [elpa] externals/parser-generator 21164b6 064/434: Added documentation for (lr-items), (continued)
- [elpa] externals/parser-generator 21164b6 064/434: Added documentation for (lr-items), ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator ccaf4b5 080/434: More stuff, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator bdbedf4 078/434: Suffixes in LR-items that only contain e-identifier are now set as nil, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 0e075d7 081/434: Fixed issue with algorithm 5.9, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fe6037b 088/434: Generating valid GOTO-table, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator d5284b5 091/434: Added algorithm 5.10, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 0304b78 092/434: Added a unit-test to invalidate LR-items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 69bfe16 006/434: Removed white-space, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 1613e2e 096/434: Byte-compilation and unit tests working after refactor, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 31c7ba7 098/434: Work on function that generates all possible look-aheads, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 53980d4 102/434: More documentation,
ELPA Syncer <=
- [elpa] externals/parser-generator 882d725 105/434: Added TODO item, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 65d9ce2 106/434: Fixed a bug with E-FREE-FIRST function and function that validates a set of LR-items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 343fd72 104/434: Some parts of the action-table is generated, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator b2a0d71 112/434: Passed test for action-table generation, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 1c1177f 116/434: More work on LR-parser algorithm, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 9db14cd 118/434: Added TODO items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 5784f3f 126/434: Updated README with link to separate document for grammar, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator edfb7b4 131/434: Moved lex-analyzer to separate file, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 8cda060 149/434: Made some functions public, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator c1d3707 150/434: Passing test for including SDT in Produductions, ELPA Syncer, 2021/11/29