init: The Spoofax "helloworld" example as generated
This commit is contained in:
commit
ffdf391687
13
.gitignore
vendored
Normal file
13
.gitignore
vendored
Normal file
@ -0,0 +1,13 @@
|
||||
/.cache
|
||||
/bin
|
||||
/src-gen
|
||||
/target
|
||||
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
/.factorypath
|
||||
|
||||
/.polyglot.metaborg.yaml
|
||||
|
||||
*.aterm
|
8
.mvn/extensions.xml
Normal file
8
.mvn/extensions.xml
Normal file
@ -0,0 +1,8 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<extensions>
|
||||
<extension>
|
||||
<groupId>org.metaborg</groupId>
|
||||
<artifactId>spoofax-maven-plugin-pomless</artifactId>
|
||||
<version>2.5.13</version>
|
||||
</extension>
|
||||
</extensions>
|
1
.mvn/jvm.config
Normal file
1
.mvn/jvm.config
Normal file
@ -0,0 +1 @@
|
||||
-Xmx512m
|
1
.mvn/maven.config
Normal file
1
.mvn/maven.config
Normal file
@ -0,0 +1 @@
|
||||
--global-settings .mvn/settings.xml
|
69
.mvn/settings.xml
Normal file
69
.mvn/settings.xml
Normal file
@ -0,0 +1,69 @@
|
||||
<?xml version="1.0" ?>
|
||||
<settings
|
||||
xmlns="http://maven.apache.org/SETTINGS/1.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/SETTINGS/1.0.0 http://maven.apache.org/xsd/settings-1.0.0.xsd"
|
||||
>
|
||||
<profiles>
|
||||
<profile>
|
||||
<id>add-metaborg-release-repos</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>metaborg-release-repo</id>
|
||||
<url>https://artifacts.metaborg.org/content/repositories/releases/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>metaborg-release-repo</id>
|
||||
<url>https://artifacts.metaborg.org/content/repositories/releases/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
|
||||
<profile>
|
||||
<id>add-metaborg-snapshot-repos</id>
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>metaborg-snapshot-repo</id>
|
||||
<url>https://artifacts.metaborg.org/content/repositories/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>metaborg-snapshot-repo</id>
|
||||
<url>https://artifacts.metaborg.org/content/repositories/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</profile>
|
||||
</profiles>
|
||||
|
||||
<activeProfiles>
|
||||
<activeProfile>add-metaborg-release-repos</activeProfile>
|
||||
<activeProfile>add-metaborg-snapshot-repos</activeProfile>
|
||||
</activeProfiles>
|
||||
</settings>
|
10
editor/Analysis.esv
Normal file
10
editor/Analysis.esv
Normal file
@ -0,0 +1,10 @@
|
||||
module Analysis
|
||||
|
||||
imports
|
||||
|
||||
nabl2/Menus
|
||||
nabl2/References
|
||||
|
||||
language
|
||||
|
||||
observer : editor-analyze (constraint)
|
13
editor/Main.esv
Normal file
13
editor/Main.esv
Normal file
@ -0,0 +1,13 @@
|
||||
module Main
|
||||
|
||||
imports
|
||||
|
||||
Syntax
|
||||
Analysis
|
||||
|
||||
language
|
||||
|
||||
extensions : hel
|
||||
|
||||
provider : target/metaborg/stratego.ctree
|
||||
provider : target/metaborg/stratego.jar
|
27
editor/Syntax.esv
Normal file
27
editor/Syntax.esv
Normal file
@ -0,0 +1,27 @@
|
||||
module Syntax
|
||||
|
||||
imports
|
||||
|
||||
libspoofax/color/default
|
||||
completion/colorer/spoofax_helloworld-cc-esv
|
||||
|
||||
language
|
||||
|
||||
table : target/metaborg/sdf.tbl
|
||||
start symbols : Start
|
||||
|
||||
line comment : "//"
|
||||
block comment : "/*" * "*/"
|
||||
fences : [ ] ( ) { }
|
||||
|
||||
menus
|
||||
|
||||
menu: "Syntax" (openeditor)
|
||||
|
||||
action: "Format" = editor-format (source)
|
||||
action: "Show parsed AST" = debug-show-aterm (source)
|
||||
|
||||
views
|
||||
|
||||
outline view: editor-outline (source)
|
||||
expand to level: 3
|
41
metaborg.yaml
Normal file
41
metaborg.yaml
Normal file
@ -0,0 +1,41 @@
|
||||
---
|
||||
id: org.example:spoofax_helloworld:0.1.0-SNAPSHOT
|
||||
name: spoofax_helloworld
|
||||
dependencies:
|
||||
compile:
|
||||
- org.metaborg:org.metaborg.meta.lang.esv:${metaborgVersion}
|
||||
- org.metaborg:org.metaborg.meta.lang.template:${metaborgVersion}
|
||||
- org.metaborg:org.metaborg.meta.nabl2.lang:${metaborgVersion}
|
||||
- org.metaborg:dynsem:${metaborgVersion}
|
||||
source:
|
||||
- org.metaborg:meta.lib.spoofax:${metaborgVersion}
|
||||
- org.metaborg:org.metaborg.meta.nabl2.shared:${metaborgVersion}
|
||||
- org.metaborg:org.metaborg.meta.nabl2.runtime:${metaborgVersion}
|
||||
pardonedLanguages:
|
||||
- EditorService
|
||||
- Stratego-Sugar
|
||||
- SDF
|
||||
language:
|
||||
sdf:
|
||||
pretty-print: spoofax_helloworld
|
||||
sdf2table: java
|
||||
placeholder:
|
||||
prefix: "$"
|
||||
stratego:
|
||||
format: ctree
|
||||
args:
|
||||
- -la
|
||||
- stratego-lib
|
||||
- -la
|
||||
- stratego-sglr
|
||||
- -la
|
||||
- stratego-gpp
|
||||
- -la
|
||||
- stratego-xtc
|
||||
- -la
|
||||
- stratego-aterm
|
||||
- -la
|
||||
- stratego-sdf
|
||||
- -la
|
||||
- strc
|
||||
exports:
|
64
pom.xml
Normal file
64
pom.xml
Normal file
@ -0,0 +1,64 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"
|
||||
xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<groupId>org.example</groupId>
|
||||
<artifactId>spoofax_helloworld</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<packaging>spoofax-language</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.metaborg</groupId>
|
||||
<artifactId>parent.language</artifactId>
|
||||
<version>2.5.13</version>
|
||||
</parent>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>metaborg-release-repo</id>
|
||||
<url>https://artifacts.metaborg.org/content/repositories/releases/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>metaborg-snapshot-repo</id>
|
||||
<url>https://artifacts.metaborg.org/content/repositories/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>metaborg-release-repo</id>
|
||||
<url>https://artifacts.metaborg.org/content/repositories/releases/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>false</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>metaborg-snapshot-repo</id>
|
||||
<url>https://artifacts.metaborg.org/content/repositories/snapshots/</url>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
</snapshots>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
@ -0,0 +1,10 @@
|
||||
package spoofax_helloworld.strategies;
|
||||
|
||||
import org.strategoxt.lang.JavaInteropRegisterer;
|
||||
import org.strategoxt.lang.Strategy;
|
||||
|
||||
public class InteropRegisterer extends JavaInteropRegisterer {
|
||||
public InteropRegisterer() {
|
||||
super(new Strategy[] { });
|
||||
}
|
||||
}
|
@ -0,0 +1,9 @@
|
||||
package spoofax_helloworld.strategies;
|
||||
|
||||
import org.strategoxt.lang.Context;
|
||||
|
||||
public class Main {
|
||||
public static void init(Context context) {
|
||||
|
||||
}
|
||||
}
|
50
syntax/Common.sdf3
Normal file
50
syntax/Common.sdf3
Normal file
@ -0,0 +1,50 @@
|
||||
module Common
|
||||
|
||||
lexical sorts
|
||||
ID INT STRING
|
||||
STRING_CHAR BACKSLASH_CHAR
|
||||
COMMENT_CHAR INSIDE_COMMENT
|
||||
NEWLINE_EOF EOF
|
||||
|
||||
lexical syntax
|
||||
|
||||
ID = [a-zA-Z] [a-zA-Z0-9]*
|
||||
INT = "-"? [0-9]+
|
||||
STRING = "\"" STRING_CHAR* "\""
|
||||
STRING_CHAR = ~[\"\n]
|
||||
STRING_CHAR = "\\\""
|
||||
STRING_CHAR = BACKSLASH_CHAR
|
||||
BACKSLASH_CHAR = "\\"
|
||||
LAYOUT = [\ \t\n\r]
|
||||
COMMENT_CHAR = [\*]
|
||||
LAYOUT = "/*" INSIDE_COMMENT* "*/"
|
||||
INSIDE_COMMENT = ~[\*]
|
||||
INSIDE_COMMENT = COMMENT_CHAR
|
||||
LAYOUT = "//" ~[\n\r]* NEWLINE_EOF
|
||||
NEWLINE_EOF = [\n\r]
|
||||
NEWLINE_EOF = EOF
|
||||
EOF =
|
||||
|
||||
lexical restrictions
|
||||
|
||||
// Ensure greedy matching for lexicals
|
||||
|
||||
COMMENT_CHAR -/- [\/]
|
||||
INT -/- [0-9]
|
||||
ID -/- [a-zA-Z0-9\_]
|
||||
|
||||
// EOF may not be followed by any char
|
||||
|
||||
EOF -/- ~[]
|
||||
|
||||
// Backslash chars in strings may not be followed by "
|
||||
|
||||
BACKSLASH_CHAR -/- [\"]
|
||||
|
||||
context-free restrictions
|
||||
|
||||
// Ensure greedy matching for comments
|
||||
|
||||
LAYOUT? -/- [\ \t\n\r]
|
||||
LAYOUT? -/- [\/].[\/]
|
||||
LAYOUT? -/- [\/].[\*]
|
17
syntax/spoofax_helloworld.sdf3
Normal file
17
syntax/spoofax_helloworld.sdf3
Normal file
@ -0,0 +1,17 @@
|
||||
module spoofax_helloworld
|
||||
|
||||
imports
|
||||
|
||||
Common
|
||||
|
||||
context-free start-symbols
|
||||
|
||||
Start
|
||||
|
||||
context-free sorts
|
||||
|
||||
Start
|
||||
|
||||
context-free syntax
|
||||
|
||||
Start.Empty = <>
|
26
trans/analysis.str
Normal file
26
trans/analysis.str
Normal file
@ -0,0 +1,26 @@
|
||||
module analysis
|
||||
|
||||
imports
|
||||
|
||||
nabl2/api
|
||||
nabl2/runtime
|
||||
|
||||
statics
|
||||
|
||||
pp
|
||||
|
||||
rules // Analysis
|
||||
|
||||
editor-analyze = nabl2-analyze(id)
|
||||
|
||||
rules // Debugging
|
||||
|
||||
// Prints the abstract syntax ATerm of a selection.
|
||||
debug-show-aterm: (selected, _, _, path, project-path) -> (filename, result)
|
||||
with filename := <guarantee-extension(|"aterm")> path
|
||||
; result := selected
|
||||
|
||||
// Prints the analyzed annotated abstract syntax ATerm of a selection.
|
||||
debug-show-analyzed: (selected, _, _, path, project-path) -> (filename, result)
|
||||
with filename := <guarantee-extension(|"analyzed.aterm")> path
|
||||
; result := selected
|
15
trans/outline.str
Normal file
15
trans/outline.str
Normal file
@ -0,0 +1,15 @@
|
||||
module outline
|
||||
|
||||
imports
|
||||
|
||||
signatures/spoofax_helloworld-sig
|
||||
libspoofax/editor/outline
|
||||
|
||||
rules
|
||||
|
||||
editor-outline:
|
||||
(_, _, ast, path, project-path) -> outline
|
||||
where
|
||||
outline := <simple-label-outline(to-outline-label)> ast
|
||||
|
||||
to-outline-label = fail
|
49
trans/pp.str
Normal file
49
trans/pp.str
Normal file
@ -0,0 +1,49 @@
|
||||
module pp
|
||||
|
||||
imports
|
||||
|
||||
libstratego-gpp
|
||||
libspoofax/sdf/pp
|
||||
libspoofax/editor/refactoring/-
|
||||
pp/spoofax_helloworld-parenthesize
|
||||
pp/spoofax_helloworld-pp
|
||||
|
||||
rules
|
||||
|
||||
editor-format:
|
||||
(node, _, ast, path, project-path) -> (filename, result)
|
||||
with
|
||||
ext := <get-extension> path
|
||||
; filename := <guarantee-extension(|$[pp.[ext]])> path
|
||||
; result := <pp-debug> node
|
||||
|
||||
rules
|
||||
|
||||
pp-spoofax_helloworld-string =
|
||||
parenthesize-spoofax_helloworld
|
||||
; prettyprint-spoofax_helloworld-start-symbols
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-partial-spoofax_helloworld-string =
|
||||
parenthesize-spoofax_helloworld
|
||||
; prettyprint-spoofax_helloworld
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-partial-spoofax_helloworld-string(|sort) =
|
||||
parenthesize-spoofax_helloworld
|
||||
; prettyprint-spoofax_helloworld(|sort)
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-debug :
|
||||
ast -> result
|
||||
with
|
||||
result := <pp-spoofax_helloworld-string> ast
|
||||
<+ <bottomup(try(not(is-string); not(is-list); not(pp-spoofax_helloworld-string); debug(!"cannot pp ")))> ast
|
||||
; result := ""
|
||||
|
||||
rules
|
||||
|
||||
construct-textual-change = construct-textual-change(pp-partial-spoofax_helloworld-string, parenthesize, override-reconstruction, resugar)
|
16
trans/spoofax_helloworld.str
Normal file
16
trans/spoofax_helloworld.str
Normal file
@ -0,0 +1,16 @@
|
||||
module spoofax_helloworld
|
||||
|
||||
imports
|
||||
|
||||
completion/completion
|
||||
pp
|
||||
outline
|
||||
analysis
|
||||
|
||||
rules // Debugging
|
||||
|
||||
debug-show-aterm:
|
||||
(node, _, _, path, project-path) -> (filename, result)
|
||||
with
|
||||
filename := <guarantee-extension(|"aterm")> path
|
||||
; result := node
|
13
trans/statics.nabl2
Normal file
13
trans/statics.nabl2
Normal file
@ -0,0 +1,13 @@
|
||||
module statics
|
||||
|
||||
imports
|
||||
|
||||
signatures/-
|
||||
|
||||
rules
|
||||
|
||||
init ^ (s) := new s.
|
||||
|
||||
[[ Empty() ^ (s) ]] :=
|
||||
false | note "Specify name binding and typing rules in statics.nabl2".
|
||||
|
Loading…
Reference in New Issue
Block a user