emacs-elpa-diffs
[Top][All Lists]
Advanced

[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`



reply via email to

[Prev in Thread] Current Thread [Next in Thread]