[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/parser-generator 71e4eaa 145/434: Merge branch 'master'
From: |
ELPA Syncer |
Subject: |
[elpa] externals/parser-generator 71e4eaa 145/434: Merge branch 'master' of git.cvj.se:/home/git/emacs-parser-generator |
Date: |
Mon, 29 Nov 2021 15:59:28 -0500 (EST) |
branch: externals/parser-generator
commit 71e4eaa54d0f4e3336e5142871c6f17d3b02867b
Merge: fa7089e 0695275
Author: Christian Johansson <christian@cvj.se>
Commit: Christian Johansson <christian@cvj.se>
Merge branch 'master' of git.cvj.se:/home/git/emacs-parser-generator
---
README.md | 209 +----------------------------------
docs/Lexical-Analysis.md | 73 ++++++++++++
README.md => docs/Syntax-Analysis.md | 92 +--------------
3 files changed, 81 insertions(+), 293 deletions(-)
diff --git a/README.md b/README.md
index 7a87dbe..9408ea4 100644
--- a/README.md
+++ b/README.md
@@ -9,214 +9,11 @@ This is just started, so most stuff are *WIP*.
## Lexical Analysis
-We use a regular-language based lexical analyzer that can be implemented by a
finite-state-machine (FSM). Set lexical analysis function by setting variable
`parser-generator-lex-analyzer--function`. Optionally set reset function by
setting variable `parser-generator-lex-analyzer--reset-function`. The lexical
analysis is indexed on variable `parser-generator-lex-analyzer--index`. All
parsers expect a list of tokens as response from lexical-analysis.
+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).
-### Peek next look-ahead
+## Syntax Analysis
-Returns the look-ahead number of next terminals in stream.
-
-``` emacs-lisp
-(require 'ert)
-(setq
- parser-generator-lex-analyzer--function
- (lambda (index length)
- (let* ((string '(a a b b b))
- (string-length (length string))
- (max-index (+ index length))
- (tokens))
- (while (and
- (< index string-length)
- (< index max-index))
- (push (nth index string) tokens)
- (setq index (1+ index)))
- (nreverse tokens))))
-(parser-generator-lex-analyzer--reset)
-(setq parser-generator--look-ahead-number 1)
- (should
- (equal
- '(a)
- (parser-generator-lex-analyzer--peek-next-look-ahead)))
-
- (setq parser-generator--look-ahead-number 2)
- (should
- (equal
- '(a b)
- (parser-generator-lex-analyzer--peek-next-look-ahead)))
-
-```
-
-### Pop token
-
-Returns the next token in stream and moves index one forward.
-
-``` emacs-lisp
-(require 'ert)
-(setq
- parser-generator-lex-analyzer--function
- (lambda (index length)
- (let* ((string '(a b))
- (string-length (length string))
- (max-index (+ index length))
- (tokens))
- (while (and
- (< index string-length)
- (< index max-index))
- (push (nth index string) tokens)
- (setq index (1+ index)))
- (nreverse tokens))))
-(parser-generator-lex-analyzer--reset)
-(should
- (equal
- '(a)
- (parser-generator-lex-analyzer--pop-token)))
- (should
- (equal
- '(b)
- (parser-generator-lex-analyzer--pop-token)))
- (should
- (equal
- nil
- (parser-generator-lex-analyzer--pop-token)))
-```
-
-## Syntax Analysis / Parsing
-
-We use push down transducer (PDT) based algorithms.
-
-### With Backtracking
-
-* The Bottom-Up Parsing Algorithm *WIP*
-* The Top-Down Parsing Algorithm *WIP*
-* The Cocke-Younger-Kasami Algorithm *WIP*
-* The Parsing Method of Earley *WIP*
-
-### Without Backtracking
-
-* LL(k) *WIP*
-* Deterministic Shift-Reduce Parsing *WIP*
-* [LR(k)](docs/Deterministic-Right-Parser-for-LRk-Grammars.md)
-* Formal Shift-Reduce Parsing Algorithms *WIP*
-* Simple Precedence Grammars *WIP*
-* Extended Precedence Grammars *WIP*
-*Weak Precedence Grammars *WIP*
-* Bounded-Right-Context Grammars *WIP*
-* Mixed Strategy Precedence Grammars *WIP*
-* Operator Precedence Grammars *WIP*
-* Floyd-Evans Production Language *WIP*
-
-## Grammar
-
-Grammar consists of `N`, `T`, `P` and `S`, where `N` is non-terminals, `T` is
terminals, `P` is productions and `S` is start-production. Example:
-
-* N = `'(S A B C)`
-* T = `'(a b c)`
-* P = `'((S (A B)) (A (B a) e) (B (C b) C) (C c e))`
-* S = `'S`
-
-``` emacs-lisp
-(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
-
-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.
-
-### Non-terminals
-
-A non-terminal is either a symbol or a string so `"A"` and `A` are equally
valid.
-
-### Terminals
-
-A terminal is either a symbol or a string so `"{"` and `A` are equally valid.
-
-### Sentential-form
-
-A list of one or more non-terminals and terminals, example `'(A "A" c ":")`,
the e-symbol is allowed depending on grammar.
-
-### Productions
-
-A production consists of a list of at least two elements. The first element is
the left-hand-side (LHS) and should contain at least one element. The
right-hand-side (RHS) consists of the rest of the elements, if there is more
than one list in RHS then each list will be treated as a alternative production
RHS.
-
-Example, production `S -> A | B` is defined as:
-
-``` emacs-lisp
-'(S A B)
-```
-
-Another example, production `S -> IF "{" EXPRESSION "}" | EXIT` is declared as:
-
-``` emacs-lisp
-'(S (IF "{" EXPRESSION "}") EXIT)
-```
-
-### Start
-
-The start symbol is the entry-point of the grammar and should be either a
string or a symbol and should exists in the list of productions as the LHS.
-
-### Look-ahead number
-
-Is a simple integer above zero. You set it like this:
`(parser-generator--set-look-ahead-number 1)` for `1` number look-ahead.
-
-### Syntax-directed-translation (SDT)
-
-*WIP* Where should this be defined?
-
-### Semantic-actions (SA)
-
-*WIP* Where should this be defined?
-
-## Functions
-
-### FIRST(S)
-
-Calculate the first look-ahead number of terminals of the sentential-form `S`,
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-look-ahead-number 2)
-(parser-generator--process-grammar)
-
-(should
- (equal
- '((a) (a c) (a b) (c a) (b a) (e) (c) (b) (c b))
- (parser-generator--first 'S)))
-```
-
-### E-FREE-FIRST(S)
-
-Calculate the e-free-first look-ahead number of terminals of sentential-form
`S`, 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-look-ahead-number 2)
-(parser-generator--process-grammar)
-
-(should
- (equal
- '((c b) (c a))
- (parser-generator--e-free-first 'S)))
-```
-
-### FOLLOW(S)
-
-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-look-ahead-number 2)
-(parser-generator--process-grammar)
-
-(should
- (equal
- '((a))
- (parser-generator--follow 'A)))
-```
+We use deterministic push down transducer (PDT) based algorithms. Read more
[here](docs/Syntax-Analysis.md).
## Test
diff --git a/docs/Lexical-Analysis.md b/docs/Lexical-Analysis.md
new file mode 100644
index 0000000..711703c
--- /dev/null
+++ b/docs/Lexical-Analysis.md
@@ -0,0 +1,73 @@
+# Lexical Analysis
+
+Set lexical analysis function by setting variable
`parser-generator-lex-analyzer--function`. Optionally set reset function by
setting variable `parser-generator-lex-analyzer--reset-function`. The lexical
analysis is indexed on variable `parser-generator-lex-analyzer--index`. All
parsers expect a list of tokens as response from lexical-analysis.
+
+### Peek next look-ahead
+
+Returns the look-ahead number of next terminals in stream.
+
+``` emacs-lisp
+(require 'ert)
+(setq
+ parser-generator-lex-analyzer--function
+ (lambda (index length)
+ (let* ((string '(a a b b b))
+ (string-length (length string))
+ (max-index (+ index length))
+ (tokens))
+ (while (and
+ (< index string-length)
+ (< index max-index))
+ (push (nth index string) tokens)
+ (setq index (1+ index)))
+ (nreverse tokens))))
+(parser-generator-lex-analyzer--reset)
+(setq parser-generator--look-ahead-number 1)
+ (should
+ (equal
+ '(a)
+ (parser-generator-lex-analyzer--peek-next-look-ahead)))
+
+ (setq parser-generator--look-ahead-number 2)
+ (should
+ (equal
+ '(a b)
+ (parser-generator-lex-analyzer--peek-next-look-ahead)))
+
+```
+
+### Pop token
+
+Returns the next token in stream and moves index one forward.
+
+``` emacs-lisp
+(require 'ert)
+(setq
+ parser-generator-lex-analyzer--function
+ (lambda (index length)
+ (let* ((string '(a b))
+ (string-length (length string))
+ (max-index (+ index length))
+ (tokens))
+ (while (and
+ (< index string-length)
+ (< index max-index))
+ (push (nth index string) tokens)
+ (setq index (1+ index)))
+ (nreverse tokens))))
+(parser-generator-lex-analyzer--reset)
+(should
+ (equal
+ '(a)
+ (parser-generator-lex-analyzer--pop-token)))
+ (should
+ (equal
+ '(b)
+ (parser-generator-lex-analyzer--pop-token)))
+ (should
+ (equal
+ nil
+ (parser-generator-lex-analyzer--pop-token)))
+```
+
+[Back to start](../../../)
diff --git a/README.md b/docs/Syntax-Analysis.md
similarity index 54%
copy from README.md
copy to docs/Syntax-Analysis.md
index 7a87dbe..eb7ce9b 100644
--- a/README.md
+++ b/docs/Syntax-Analysis.md
@@ -1,100 +1,19 @@
-# Emacs Parser Generator
-
-[![License GPL
3](https://img.shields.io/badge/license-GPL_3-green.svg)](https://www.gnu.org/licenses/gpl-3.0.txt)
-[![Build
Status](https://travis-ci.org/cjohansson/emacs-parser-generator.svg?branch=master)](https://travis-ci.org/cjohansson/emacs-parser-generator)
-
-The idea of this plugin is to provide functions for various kinds of
context-free grammar parser generations with support for
syntax-directed-translations (SDT) and semantic-actions. This project is about
implementing algorithms described in the book `The Theory of Parsing,
Translation and Compiling (Volume 1)` by `Alfred V. Aho and Jeffrey D. Ullman`
(1972). Also this project is about me learning how to parse languages.
-
-This is just started, so most stuff are *WIP*.
-
-## Lexical Analysis
-
-We use a regular-language based lexical analyzer that can be implemented by a
finite-state-machine (FSM). Set lexical analysis function by setting variable
`parser-generator-lex-analyzer--function`. Optionally set reset function by
setting variable `parser-generator-lex-analyzer--reset-function`. The lexical
analysis is indexed on variable `parser-generator-lex-analyzer--index`. All
parsers expect a list of tokens as response from lexical-analysis.
-
-### Peek next look-ahead
-
-Returns the look-ahead number of next terminals in stream.
-
-``` emacs-lisp
-(require 'ert)
-(setq
- parser-generator-lex-analyzer--function
- (lambda (index length)
- (let* ((string '(a a b b b))
- (string-length (length string))
- (max-index (+ index length))
- (tokens))
- (while (and
- (< index string-length)
- (< index max-index))
- (push (nth index string) tokens)
- (setq index (1+ index)))
- (nreverse tokens))))
-(parser-generator-lex-analyzer--reset)
-(setq parser-generator--look-ahead-number 1)
- (should
- (equal
- '(a)
- (parser-generator-lex-analyzer--peek-next-look-ahead)))
-
- (setq parser-generator--look-ahead-number 2)
- (should
- (equal
- '(a b)
- (parser-generator-lex-analyzer--peek-next-look-ahead)))
-
-```
-
-### Pop token
-
-Returns the next token in stream and moves index one forward.
-
-``` emacs-lisp
-(require 'ert)
-(setq
- parser-generator-lex-analyzer--function
- (lambda (index length)
- (let* ((string '(a b))
- (string-length (length string))
- (max-index (+ index length))
- (tokens))
- (while (and
- (< index string-length)
- (< index max-index))
- (push (nth index string) tokens)
- (setq index (1+ index)))
- (nreverse tokens))))
-(parser-generator-lex-analyzer--reset)
-(should
- (equal
- '(a)
- (parser-generator-lex-analyzer--pop-token)))
- (should
- (equal
- '(b)
- (parser-generator-lex-analyzer--pop-token)))
- (should
- (equal
- nil
- (parser-generator-lex-analyzer--pop-token)))
-```
-
-## Syntax Analysis / Parsing
+# Syntax Analysis / Parsing
We use push down transducer (PDT) based algorithms.
-### With Backtracking
+## With Backtracking
* The Bottom-Up Parsing Algorithm *WIP*
* The Top-Down Parsing Algorithm *WIP*
* The Cocke-Younger-Kasami Algorithm *WIP*
* The Parsing Method of Earley *WIP*
-### Without Backtracking
+## Without Backtracking
* LL(k) *WIP*
* Deterministic Shift-Reduce Parsing *WIP*
-* [LR(k)](docs/Deterministic-Right-Parser-for-LRk-Grammars.md)
+* [LR(k)](Deterministic-Right-Parser-for-LRk-Grammars.md)
* Formal Shift-Reduce Parsing Algorithms *WIP*
* Simple Precedence Grammars *WIP*
* Extended Precedence Grammars *WIP*
@@ -218,6 +137,5 @@ Calculate the look-ahead number of terminals possibly
following S.
(parser-generator--follow 'A)))
```
-## Test
-Run in terminal `make clean && make tests && make compile`
+[Back to start](../../../)
- [elpa] externals/parser-generator 044f33a 151/434: Added more support for SDT, (continued)
- [elpa] externals/parser-generator 044f33a 151/434: Added more support for SDT, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 96f128f 155/434: More various stuff, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator a586a0e 162/434: More work on incremental parsing, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 6d323a4 120/434: Implemented reduce action of LR-parser algorithm, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 9b44827 124/434: Optimized LR-parser with hash-tables, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 01fc56f 127/434: Updated list of grammars, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 4ef0430 133/434: White-space fix, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator b2fd896 136/434: Added support for indexed tokens, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 4746c64 137/434: Updated example for LR parse with indexed tokens, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 04a3ec5 141/434: Added separate file for syntax analysis, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 71e4eaa 145/434: Merge branch 'master' of git.cvj.se:/home/git/emacs-parser-generator,
ELPA Syncer <=
- [elpa] externals/parser-generator 173fe94 152/434: Preparations for translation, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator be557ba 013/434: More work on refactor, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator fdbdff7 157/434: Added unit test for SDT in LR-parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 2d56ab0 160/434: Made separate functions for parse and translate in LR-parser, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 7cfdea2 165/434: Passing tests for incremental lexer, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator b072fdd 175/434: Passed test for trailing e-identifier in EFF function, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator d435e50 122/434: Passing unit test for LR-parse, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator a31da28 173/434: Updated Parser WIP items, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator aaec6fa 189/434: Work on e-free first tests, ELPA Syncer, 2021/11/29
- [elpa] externals/parser-generator 922033f 198/434: Various stuff, ELPA Syncer, 2021/11/29