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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/parser-generator 5784f3f 126/434: Updated README with l


From: ELPA Syncer
Subject: [elpa] externals/parser-generator 5784f3f 126/434: Updated README with link to separate document for grammar
Date: Mon, 29 Nov 2021 15:59:24 -0500 (EST)

branch: externals/parser-generator
commit 5784f3f8940b6ccecf48865bd87a18f3a5a0b6de
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>

    Updated README with link to separate document for grammar
---
 README.md                                          | 57 +---------------------
 .../Deterministic Right Parser for LRk Grammars.md | 57 ++++++++++++++++++++++
 2 files changed, 58 insertions(+), 56 deletions(-)

diff --git a/README.md b/README.md
index 6a7c9af..c77777c 100644
--- a/README.md
+++ b/README.md
@@ -24,62 +24,7 @@ We use push down transducer (PDT) based algorithms:
 #### LL(k)
 #### Deterministic Shift-Reduce Parsing
 #### LR(k)
-#### Deterministic Right Parser for LR(k) Grammars
-
-A valid LR-item for a viable prefix has this structure:
-
-``` emacs-lisp
-(A B C L)
-```
-
-Example with grammar with production: S -> SaSb and S is non-terminal and a, b 
are terminals. Look-ahead number: 1
-
-``` emacs-lisp
-(S nil (S a S b) (a))
-```
-
-* A is the production LHS
-* 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)))
-```
-
+#### [Deterministic Right Parser for LR(k) Grammars](docs/Deterministic Right 
Parser for LRk Grammars.md)
 #### Formal Shift-Reduce Parsing Algorithms
 #### Simple Precedence Grammars
 #### Extended Precedence Grammars
diff --git a/docs/Deterministic Right Parser for LRk Grammars.md 
b/docs/Deterministic Right Parser for LRk Grammars.md
new file mode 100644
index 0000000..d449001
--- /dev/null
+++ b/docs/Deterministic Right Parser for LRk Grammars.md       
@@ -0,0 +1,57 @@
+# Deterministic Right Parser for LR(k) Grammars
+
+A valid LR-item for a viable prefix has this structure:
+
+``` emacs-lisp
+(A B C L)
+```
+
+Example with grammar with production: S -> SaSb and S is non-terminal and a, b 
are terminals. Look-ahead number: 1
+
+``` emacs-lisp
+(S nil (S a S b) (a))
+```
+
+* A is the production LHS
+* 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)))
+```
+
+[Back to start](../../../)



reply via email to

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