commit
ffdf391687
20 changed files with 454 additions and 0 deletions
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
/.cache |
||||
/bin |
||||
/src-gen |
||||
/target |
||||
|
||||
/.classpath |
||||
/.project |
||||
/.settings |
||||
/.factorypath |
||||
|
||||
/.polyglot.metaborg.yaml |
||||
|
||||
*.aterm |
@ -0,0 +1,8 @@
@@ -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> |
@ -0,0 +1 @@
@@ -0,0 +1 @@
|
||||
--global-settings .mvn/settings.xml |
@ -0,0 +1,69 @@
@@ -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> |
@ -0,0 +1,2 @@
@@ -0,0 +1,2 @@
|
||||
# spoofax_helloworld Language Specification |
||||
|
@ -0,0 +1,10 @@
@@ -0,0 +1,10 @@
|
||||
module Analysis |
||||
|
||||
imports |
||||
|
||||
nabl2/Menus |
||||
nabl2/References |
||||
|
||||
language |
||||
|
||||
observer : editor-analyze (constraint) |
@ -0,0 +1,13 @@
@@ -0,0 +1,13 @@
|
||||
module Main |
||||
|
||||
imports |
||||
|
||||
Syntax |
||||
Analysis |
||||
|
||||
language |
||||
|
||||
extensions : hel |
||||
|
||||
provider : target/metaborg/stratego.ctree |
||||
provider : target/metaborg/stratego.jar |
@ -0,0 +1,27 @@
@@ -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 |
@ -0,0 +1,41 @@
@@ -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: |
@ -0,0 +1,64 @@
@@ -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 @@
@@ -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 @@
@@ -0,0 +1,9 @@
|
||||
package spoofax_helloworld.strategies; |
||||
|
||||
import org.strategoxt.lang.Context; |
||||
|
||||
public class Main { |
||||
public static void init(Context context) { |
||||
|
||||
} |
||||
} |
@ -0,0 +1,50 @@
@@ -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? -/- [\/].[\*] |
@ -0,0 +1,17 @@
@@ -0,0 +1,17 @@
|
||||
module spoofax_helloworld |
||||
|
||||
imports |
||||
|
||||
Common |
||||
|
||||
context-free start-symbols |
||||
|
||||
Start |
||||
|
||||
context-free sorts |
||||
|
||||
Start |
||||
|
||||
context-free syntax |
||||
|
||||
Start.Empty = <> |
@ -0,0 +1,26 @@
@@ -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 |
@ -0,0 +1,15 @@
@@ -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 |
@ -0,0 +1,49 @@
@@ -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) |
@ -0,0 +1,16 @@
@@ -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 |
Loading…
Reference in new issue