Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
M
mouse-with-syntaxtree
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Analytics
Analytics
Repository
Value Stream
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Commits
Open sidebar
parsergenerators
mouse-with-syntaxtree
Commits
d4655f1c
Commit
d4655f1c
authored
Nov 15, 2016
by
Dr. Michael Petter
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
first part of variants integrated
parent
1b86cf3d
Changes
6
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
16 additions
and
7 deletions
+16
-7
examples/example11/Compiler.java
examples/example11/Compiler.java
+1
-1
lib/java-cup-11b-runtime.jar
lib/java-cup-11b-runtime.jar
+0
-0
src/mouse/Generate.java
src/mouse/Generate.java
+5
-4
src/mouse/runtime/ParserBase.java
src/mouse/runtime/ParserBase.java
+4
-0
src/mouse/runtime/ParserTest.java
src/mouse/runtime/ParserTest.java
+2
-2
src/mouse/runtime/Phrase.java
src/mouse/runtime/Phrase.java
+4
-0
No files found.
examples/example11/Compiler.java
View file @
d4655f1c
...
...
@@ -30,7 +30,7 @@ public class Compiler {
XMLElement
elem
=
(
XMLElement
)
sem
.
rule
.
rhs
(
0
).
get
();
// Remove unwanted unary branch chains from the syntax tree
elem
=
SyntaxTreeTransform
.
removeUnaryChains
(
elem
);
//
elem = SyntaxTreeTransform.removeUnaryChains(elem);
// Dump DoM into XML-String via output stream
XMLOutputFactory
outFactory
=
XMLOutputFactory
.
newInstance
();
...
...
lib/java-cup-11b-runtime.jar
View file @
d4655f1c
No preview for this file type
src/mouse/Generate.java
View file @
d4655f1c
...
...
@@ -486,6 +486,7 @@ public class Generate
Action
act
=
rule
.
onSucc
[
0
];
inline
(
e
,
"reject("
+
cache
+
")"
);
if
(
tree
)
{
out
.
line
(
"setVariant(0);"
);
out
.
line
(
"sem.$TREE$"
+
rule
.
name
+
"();"
);
}
if
(
act
==
null
)
...
...
@@ -511,10 +512,9 @@ public class Generate
{
Action
succ
=
rule
.
onSucc
[
i
];
Action
fail
=
rule
.
onFail
[
i
];
String
outtree
=
""
;
if
(
tree
)
outtree
=
"sem.$TREE$"
+
rule
.
name
+
"();"
;
if
(
tree
)
outtree
=
"se
tVariant("
+
i
+
");se
m.$TREE$"
+
rule
.
name
+
"();"
;
if
(
succ
==
null
)
out
.
line
(
"if ("
+
ref
(
rule
.
rhs
[
i
])
+
") { "
+
outtree
+
" return accept("
+
cache
+
"); }"
);
else
if
(
succ
.
and
)
...
...
@@ -829,7 +829,8 @@ public class Generate
out
.
line
(
" elems.add((XMLElement)rhs(i).get());"
);
out
.
line
(
" }"
);
out
.
line
(
" if (elems.size()==0) lhs().put(new XMLElement.Terminal(new Location(lhs().getStartLine(),lhs().getStartColumn(),lhs().getStartPos()),\""
+
rule
.
name
+
"\",lhs().text(),new Location(lhs().getStartLine(),lhs().getStartColumn(),lhs().getStartPos())));"
);
out
.
line
(
" else lhs().put(new XMLElement.NonTerminal(\""
+
rule
.
name
+
"\",0,elems.toArray(new XMLElement[0])));"
);
out
.
line
(
" else lhs().put(new XMLElement.NonTerminal(\""
+
rule
.
name
+
"\",lhs().getVariant(),elems.toArray(new XMLElement[0])));"
);
out
.
line
(
"}"
);
}
...
...
src/mouse/runtime/ParserBase.java
View file @
d4655f1c
...
...
@@ -179,6 +179,10 @@ public class ParserBase implements mouse.runtime.CurrentRule
current
=
p
;
}
protected
void
setVariant
(
int
var
){
current
.
variant
=
var
;
}
//-------------------------------------------------------------------
// Accept Rule
//-------------------------------------------------------------------
...
...
src/mouse/runtime/ParserTest.java
View file @
d4655f1c
...
...
@@ -149,7 +149,7 @@ public class ParserTest extends ParserMemo
//-------------------------------------------------------------------
// Accept Rule
//-------------------------------------------------------------------
protected
boolean
accept
(
Cache
c
)
protected
boolean
accept
(
Cache
c
)
{
super
.
accept
();
traceAccept
(
c
,
traceRules
);
...
...
@@ -159,7 +159,7 @@ public class ParserTest extends ParserMemo
//-------------------------------------------------------------------
// Accept Inner
//-------------------------------------------------------------------
protected
boolean
acceptInner
(
Cache
c
)
protected
boolean
acceptInner
(
Cache
c
)
{
super
.
acceptInner
();
traceAccept
(
c
,
traceInner
);
...
...
src/mouse/runtime/Phrase.java
View file @
d4655f1c
...
...
@@ -61,6 +61,7 @@ public class Phrase
final
int
start
;
final
int
startline
;
final
int
startcolumn
;
int
variant
=
-
1
;
int
end
;
int
endline
;
int
endcolumn
;
...
...
@@ -142,6 +143,9 @@ public class Phrase
public
int
getEndColumn
(){
return
endcolumn
;
}
public
int
getVariant
(){
return
variant
;
}
//-----------------------------------------------------------------
// Get text
//-----------------------------------------------------------------
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment