Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
X
XMLSchemaCompiler
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Anders Nilsson
XMLSchemaCompiler
Commits
fc767134
Commit
fc767134
authored
17 years ago
by
Anders Nilsson
Browse files
Options
Downloads
Patches
Plain Diff
Fixed some issues with compiler generation.
parent
58f52600
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
.bzrignore
+1
-0
1 addition, 0 deletions
.bzrignore
CompilerGeneration.jrag
+10
-0
10 additions, 0 deletions
CompilerGeneration.jrag
GenCompiler.java
+46
-40
46 additions, 40 deletions
GenCompiler.java
JavaCCChunks.jrag
+1
-0
1 addition, 0 deletions
JavaCCChunks.jrag
with
58 additions
and
40 deletions
.bzrignore
+
1
−
0
View file @
fc767134
...
@@ -15,3 +15,4 @@ javadoc
...
@@ -15,3 +15,4 @@ javadoc
SchemaCompile.jar
SchemaCompile.jar
examples/configForm/config-sheet.html
examples/configForm/config-sheet.html
examples/x3d/x3d_demo.x3d
examples/x3d/x3d_demo.x3d
examples/x3d/X3DAST
This diff is collapsed.
Click to expand it.
CompilerGeneration.jrag
+
10
−
0
View file @
fc767134
...
@@ -9,6 +9,16 @@
...
@@ -9,6 +9,16 @@
import java.io.*;
import java.io.*;
import java.util.*;
import java.util.*;
aspect Misc {
private static String ASTNode.grammar = new String();
public static void ASTNode.setGrammar(String s) {
grammar = s;
}
public static String ASTNode.getGrammar() {
return grammar;
}
}
aspect AbsGrammarGeneration {
aspect AbsGrammarGeneration {
void ASTNode.genAbsGrammar(PrintStream pStream) {
void ASTNode.genAbsGrammar(PrintStream pStream) {
for (int i=0; i<getNumChild(); i++) {
for (int i=0; i<getNumChild(); i++) {
...
...
This diff is collapsed.
Click to expand it.
GenCompiler.java
+
46
−
40
View file @
fc767134
...
@@ -11,63 +11,69 @@ import java.io.File;
...
@@ -11,63 +11,69 @@ import java.io.File;
import
java.io.PrintStream
;
import
java.io.PrintStream
;
public
class
GenCompiler
extends
Parser
{
public
class
GenCompiler
extends
Parser
{
public
static
void
main
(
String
args
[])
{
public
static
void
main
(
String
args
[])
{
String
dir
=
"examples/x3d"
;
String
dir
=
"examples/x3d"
;
String
outName
=
"x3d"
;
String
outName
=
"x3d"
;
String
[]
schema
=
new
String
[
1
];
String
[]
schema
=
new
String
[
1
];
String
grammarName
=
new
String
();
boolean
first
=
true
;
boolean
first
=
true
;
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
for
(
int
i
=
0
;
i
<
args
.
length
;
i
++)
{
if
(
args
[
i
].
equals
(
"-d"
))
{
if
(
args
[
i
].
equals
(
"-d"
))
{
dir
=
args
[++
i
];
dir
=
args
[++
i
];
}
else
if
(
args
[
i
].
equals
(
"-o"
))
{
}
outName
=
args
[++
i
];
if
(
args
[
i
].
equals
(
"-g"
))
{
}
else
{
grammarName
=
args
[++
i
];
// OK, we suppose the remaing arg to be parsed.
}
else
if
(
args
[
i
].
equals
(
"-o"
))
{
schema
[
0
]
=
args
[
i
++];
outName
=
args
[++
i
];
}
}
else
{
}
// OK, we suppose the remaing arg to be parsed.
schema
[
0
]
=
args
[
i
++];
}
}
Start
ast
=
parse
(
schema
);
Start
ast
=
parse
(
schema
);
ast
.
setGrammar
(
grammarName
);
File
siarasDir
=
new
File
(
dir
);
File
siarasDir
=
new
File
(
dir
);
if
(!
siarasDir
.
isDirectory
())
{
if
(!
siarasDir
.
isDirectory
())
{
siarasDir
.
mkdir
();
siarasDir
.
mkdir
();
}
}
String
fileName
=
null
;
String
fileName
=
null
;
String
common
=
dir
+
File
.
separator
+
outName
;
String
common
=
dir
+
File
.
separator
+
outName
;
try
{
try
{
// Generate JastAdd abstract grammar
// Generate JastAdd abstract grammar
fileName
=
common
+
".ast"
;
fileName
=
common
+
".ast"
;
PrintStream
pStream
=
new
PrintStream
(
new
File
(
fileName
));
PrintStream
pStream
=
new
PrintStream
(
new
File
(
fileName
));
ast
.
genAbsGrammar
(
pStream
);
ast
.
genAbsGrammar
(
pStream
);
// Generate JavaCC input
// Generate JavaCC input
fileName
=
common
+
".jjt"
;
fileName
=
common
+
".jjt"
;
pStream
=
new
PrintStream
(
new
File
(
fileName
));
pStream
=
new
PrintStream
(
new
File
(
fileName
));
ast
.
genJavaCC
(
pStream
);
ast
.
genJavaCC
(
pStream
);
// Generate Parser.java
// Generate Parser.java
fileName
=
dir
+
"/Parser.java"
;
fileName
=
dir
+
"/Parser.java"
;
pStream
=
new
PrintStream
(
new
File
(
fileName
));
pStream
=
new
PrintStream
(
new
File
(
fileName
));
ast
.
genParser
(
pStream
);
ast
.
genParser
(
pStream
);
// Generate PrettyPrint.java
// Generate PrettyPrint.java
fileName
=
dir
+
"/PrettyPrint.java"
;
fileName
=
dir
+
"/PrettyPrint.java"
;
pStream
=
new
PrintStream
(
new
File
(
fileName
));
pStream
=
new
PrintStream
(
new
File
(
fileName
));
ast
.
genPrettyPrint
(
pStream
);
ast
.
genPrettyPrint
(
pStream
);
// Generate aspects
// Generate aspects
fileName
=
dir
+
"/GeneratedAspects.jrag"
;
fileName
=
dir
+
"/GeneratedAspects.jrag"
;
pStream
=
new
PrintStream
(
new
File
(
fileName
));
pStream
=
new
PrintStream
(
new
File
(
fileName
));
ast
.
genAspects
(
pStream
);
ast
.
genAspects
(
pStream
);
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
}
catch
(
java
.
io
.
FileNotFoundException
e
)
{
System
.
out
.
println
(
"Could not create file: "
+
fileName
);
System
.
out
.
println
(
"Could not create file: "
+
fileName
);
e
.
printStackTrace
();
e
.
printStackTrace
();
}
}
}
}
}
}
This diff is collapsed.
Click to expand it.
JavaCCChunks.jrag
+
1
−
0
View file @
fc767134
...
@@ -24,6 +24,7 @@ aspect JavaCCChunks {
...
@@ -24,6 +24,7 @@ aspect JavaCCChunks {
pStream.println("} ");
pStream.println("} ");
pStream.println();
pStream.println();
pStream.println("PARSER_BEGIN(XmlParser)");
pStream.println("PARSER_BEGIN(XmlParser)");
// pStream.println(" package "+getGrammar()+"AST;");
pStream.println(" package AST;");
pStream.println(" package AST;");
pStream.println(" public class XmlParser {");
pStream.println(" public class XmlParser {");
pStream.println("}");
pStream.println("}");
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment