Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
parsing MegaL megamodels with Rascal
- Loading branch information
1 parent
e8e1ac5
commit fd7f3ed
Showing
10 changed files
with
173 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<classpath> | ||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> | ||
<classpathentry kind="con" path="org.eclipse.pde.core.requiredPlugins"/> | ||
<classpathentry kind="src" path="src"/> | ||
<classpathentry kind="output" path="bin"/> | ||
</classpath> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
bin | ||
MegaL.g |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<projectDescription> | ||
<name>megal</name> | ||
<comment></comment> | ||
<projects> | ||
</projects> | ||
<buildSpec> | ||
<buildCommand> | ||
<name>org.eclipse.jdt.core.javabuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>rascal_eclipse.rascal_builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>rascal_eclipse.term_builder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.ManifestBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
<buildCommand> | ||
<name>org.eclipse.pde.SchemaBuilder</name> | ||
<arguments> | ||
</arguments> | ||
</buildCommand> | ||
</buildSpec> | ||
<natures> | ||
<nature>rascal_eclipse.rascal_nature</nature> | ||
<nature>org.eclipse.jdt.core.javanature</nature> | ||
<nature>org.eclipse.pde.PluginNature</nature> | ||
<nature>rascal_eclipse.term_nature</nature> | ||
</natures> | ||
<linkedResources> | ||
<link> | ||
<name>eclipse</name> | ||
<type>2</type> | ||
<locationURI>rascal-library://eclipse</locationURI> | ||
</link> | ||
<link> | ||
<name>std</name> | ||
<type>2</type> | ||
<locationURI>rascal-library://rascal</locationURI> | ||
</link> | ||
</linkedResources> | ||
</projectDescription> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
Manifest-Version: 1.0 | ||
Bundle-ManifestVersion: 2 | ||
Bundle-Name: megal | ||
Bundle-SymbolicName: megal | ||
Bundle-Version: 1.0.0 | ||
Require-Bundle: org.eclipse.imp.pdb.values, | ||
rascal | ||
Bundle-RequiredExecutionEnvironment: JavaSE-1.6 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
all: | ||
make build | ||
make test | ||
|
||
build: | ||
cp ../../../101repo/capabilities/Object_XML_mapping/MegaL/*.megal tests | ||
cp ../../../101repo/languages/MegaL/parser/megal/parser/MegaL.g . | ||
|
||
test: | ||
cd src && java -Xmx1G -Xss32m -jar ../../../download/rascal.jar MegaParser.rsc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
bin.includes = META-INF/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module MegaGrammar | ||
|
||
start syntax MegaModel = MegaDesc? MegaHeader MegaInclude* MegaDecl+ L; | ||
syntax MegaHeader = "megamodel" MegaURI "."; | ||
syntax MegaURI = {ID "/"}+; | ||
syntax MegaInclude = "include" MegaURI "."; | ||
syntax MegaDecl | ||
= MegaModifier? MegaEntity "." | ||
| MegaRel "." | ||
; | ||
syntax MegaModifier = "local" | "variable" ; | ||
syntax MegaEntity | ||
= MegaArtifact "+"? {MegaIdsBin ","}+ | ||
| "Function" "+"? {MegaIdsFun ","}+ | ||
; | ||
syntax MegaIdsBin = ID (MegaBin ID)?; | ||
syntax MegaIdsFun = ID MegaFun?; | ||
syntax MegaArtifact = "Artifact" | "File" | "Language" | "Technology" | "Fragment" | "ObjectGraph" | "Program" | "Library"; | ||
syntax MegaRel | ||
= ID MegaBin ID | ||
| ID MegaFun | ||
| ID "(" ID ")" "|-\>" ID | ||
; | ||
syntax MegaBin | ||
= ( "\<" | "subsetOf" ) | ||
| ( ":" | "elementOf" ) | ||
| ( "@" | "partOf" ) | ||
| ( "=" | "correspondsTo" ) | ||
| ( "~\>" | "dependsOn" | "refersTo" ) | ||
| ( "-|" | "conformsTo" ) | ||
| ( "=\>" | "realizationOf" | "descriptionOf" | "definitionOf" ) | ||
; | ||
syntax MegaFun = ":" ID "-\>" ID; | ||
lexical ID = //@category="Constant" | ||
([a-zA-z] [a-zA-Z0-9_]* !>> [a-zA-Z0-9_]) \ Keywords ; | ||
keyword Keywords | ||
= "megamodel" | "include" | "local" | "variable" | "Artifact" | "File" | "Language" | "Technology" | "Fragment" | "ObjectGraph" | "Program" | "Library" | ||
| "subsetOf" | "elementOf" | "partOf" | "correspondsTo" | "dependsOn" | "refersTo" | "conformsTo" | "realizationOf" | "descriptionOf" | "definitionOf" | ||
; | ||
syntax STRING = [\"] ![\"]* [\"]; //" | ||
lexical MegaDesc = "{-" MegaDescEl* "-}"; | ||
lexical MegaDescEl = ![\-] | [\-] !>> [}]; | ||
|
||
layout L = LAYOUT* !>> [\ \t\n\r] !>> "--"; | ||
lexical LAYOUT | ||
= [\ \t\n\r] | ||
| @category="Comment" "--" ![\n]* $ | ||
; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module MegaParser | ||
|
||
import MegaGrammar; | ||
import Ambiguity; | ||
import ParseTree; | ||
import String; | ||
import IO; | ||
|
||
// public void main() | ||
// { | ||
// registerLanguage("MegaL", "megal", MegaModel(str input, loc org) {return parse(#MegaModel, input, org);}); | ||
// println("MegaL is registered"); | ||
// } | ||
|
||
public void main(list[str] args) | ||
{ | ||
loc base = |cwd:///../tests|; | ||
for (f <- listEntries(base), endsWith(f,".megal")) | ||
{ | ||
println("Parsing <base+f>..."); | ||
parse(#MegaModel,base+f); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
@contributor{Vadim Zaytsev - vadim@grammarware.net - SWAT, CWI} | ||
module Plugin | ||
|
||
import MegaGrammar; | ||
|
||
import util::IDE; | ||
import ParseTree; | ||
import IO; | ||
|
||
public void main() | ||
{ | ||
registerLanguage("MegaL", "megal", MegaModel(str input, loc org) {return parse(#MegaModel, input, org);}); | ||
println("MegaL is registered"); | ||
} | ||
|
||
public void t() | ||
{ | ||
parse(#MegaModel,|project://megal/tests/annotation.megal|); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
*.megal |