aboutsummaryrefslogtreecommitdiff
path: root/elymas
diff options
context:
space:
mode:
authorDrahflow <drahflow@gmx.de>2016-01-04 12:30:30 +0100
committerDrahflow <drahflow@gmx.de>2016-01-04 12:30:30 +0100
commita5e76400d3f0fe3244e366a624bfbf83f382c861 (patch)
tree748e6ec8644e9d274b28f2432d1900e2cc6a0324 /elymas
parent176e3bd5fe52fc68f1f0d050899aee4f5f06ece0 (diff)
LALR(1) parser generator
Diffstat (limited to 'elymas')
-rw-r--r--elymas/lib/parser.ey35
-rw-r--r--elymas/loaded.ey1
-rw-r--r--elymas/shared.ey1
3 files changed, 21 insertions, 16 deletions
diff --git a/elymas/lib/parser.ey b/elymas/lib/parser.ey
index 1d9636e..0afceba 100644
--- a/elymas/lib/parser.ey
+++ b/elymas/lib/parser.ey
@@ -1,6 +1,14 @@
<
- { =*body { 0 ==again { 1 =again } body again } { } loop } /redoing deffst
- { =*wasNew ==m ==k k m .has not { 1 k m =[] wasNew } rep } /enlarge deffst
+ { =*body { 0 ==again { 1 =again } body again } { } loop } /redoing deffd
+ { =*wasNew ==m ==k k m .has not { 1 k m =[] wasNew } rep } /enlarge deffd
+ <
+ 0 10 range { ==i
+ { .states i { 0 -01* } rep 2 -01* } i txt .produce .u }
+ { defmd }' ; each
+
+ { < ==states > }
+ > -- /children deffd
+ 0 10 range { _ { { 0 -01* } rep 2 -01* }_ -01 txt .produce .u deffd }' each
{
[ ] ==rules 0 ==nextNonTerminalName
@@ -174,7 +182,7 @@
"n" nt cat ==label
label outgoing .has {
label outgoing * itemsetIndices * ==target
- { ==states [ 0 states * target ] }
+ { [ target -1302 ] }
} { |unexpectedNonterminal } ? * nt actions =[]
} each
} rep
@@ -193,18 +201,19 @@
[
{ "t" t cat outgoing .has } {
"t" t cat outgoing * itemsetIndices * ==target
- { [ -01 target ] 0 } t actions =[]
+ { [ target -1302 ] 0 } t actions =[]
# 0 => lookahead consumed, quit statemachine loop
}
{ itemset t canReduce } { ==rule
0 rule * .name ==nt
1 rule * len ==tokill
- { ==states
- # rule dump # DEBUG
+ 2 rule * =*reduceAction
+ { -- ==states # value dropped
+ states reduceAction ==value
tokill { 0 states * =states }' rep
states len 0 gt {
nt 1 states * nonterminalActions * * =*action
- states action =states
+ states value action =states
# states len 0 gt { # DEBUG
# 1 states * theItemSets * dumpItemSet
@@ -221,21 +230,15 @@
<
{
- [ [ ] 0 ] ==states
- { ==lookahead
+ [ [ ] 0 0 ] ==states
+ { ==lookahead ==value
# 1 states * theItemSets * dumpItemSet # DEBUG
# [ "received: " lookahead ] |cat fold dump # DEBUG
- { states
+ { states value
lookahead 1 states * terminalActions * * *
-01 =states states len and
} { } loop
-
- states len 0 eq {
- lookahead "" eq {
- # "parse done" dump # DEBUG
- } { "parse failed" dump } ? *
- } rep
}
} /run deffst
>
diff --git a/elymas/loaded.ey b/elymas/loaded.ey
index b422637..0e8ef86 100644
--- a/elymas/loaded.ey
+++ b/elymas/loaded.ey
@@ -22,6 +22,7 @@
"lib/wrapper.ey"
"lib/sort.ey"
"lib/crypt.ey"
+ "lib/parser.ey"
] { _ dump include }' each
{
diff --git a/elymas/shared.ey b/elymas/shared.ey
index 0770612..ab65273 100644
--- a/elymas/shared.ey
+++ b/elymas/shared.ey
@@ -23,6 +23,7 @@
"lib/wrapper.ey"
"lib/sort.ey"
"lib/crypt.ey"
+ "lib/parser.ey"
] { _ dump include }' each
{