Browse Source

init: Spoofax language project as generated

master
Glen Whitney 12 months ago
commit
79b9392173
  1. 11
      .gitignore
  2. 8
      .mvn/extensions.xml
  3. 1
      .mvn/jvm.config
  4. 1
      .mvn/maven.config
  5. 69
      .mvn/settings.xml
  6. 2
      README.md
  7. 10
      editor/Analysis.esv
  8. 13
      editor/Main.esv
  9. 27
      editor/Syntax.esv
  10. 41
      metaborg.yaml
  11. 64
      pom.xml
  12. 10
      src/main/strategies/spoofax_prop/strategies/InteropRegisterer.java
  13. 9
      src/main/strategies/spoofax_prop/strategies/Main.java
  14. 50
      syntax/Common.sdf3
  15. 17
      syntax/Spoofax-Propositional-Language.sdf3
  16. 26
      trans/analysis.str
  17. 15
      trans/outline.str
  18. 49
      trans/pp.str
  19. 16
      trans/spoofax_propositional_language.str
  20. 13
      trans/statics.nabl2

11
.gitignore

@ -0,0 +1,11 @@
/.cache
/bin
/src-gen
/target
/.classpath
/.project
/.settings
/.factorypath
/.polyglot.metaborg.yaml

8
.mvn/extensions.xml

@ -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

@ -0,0 +1 @@
-Xmx512m

1
.mvn/maven.config

@ -0,0 +1 @@
--global-settings .mvn/settings.xml

69
.mvn/settings.xml

@ -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>

2
README.md

@ -0,0 +1,2 @@
# Spoofax-Propositional-Language Language Specification

10
editor/Analysis.esv

@ -0,0 +1,10 @@
module Analysis
imports
nabl2/Menus
nabl2/References
language
observer : editor-analyze (constraint)

13
editor/Main.esv

@ -0,0 +1,13 @@
module Main
imports
Syntax
Analysis
language
extensions : spl
provider : target/metaborg/stratego.ctree
provider : target/metaborg/stratego.jar

27
editor/Syntax.esv

@ -0,0 +1,27 @@
module Syntax
imports
libspoofax/color/default
completion/colorer/Spoofax-Propositional-Language-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

@ -0,0 +1,41 @@
---
id: org.studioinfinity:spoofax_prop:0.1.0-SNAPSHOT
name: Spoofax-Propositional-Language
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-Propositional-Language
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

@ -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.studioinfinity</groupId>
<artifactId>spoofax_prop</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>

10
src/main/strategies/spoofax_prop/strategies/InteropRegisterer.java

@ -0,0 +1,10 @@
package spoofax_prop.strategies;
import org.strategoxt.lang.JavaInteropRegisterer;
import org.strategoxt.lang.Strategy;
public class InteropRegisterer extends JavaInteropRegisterer {
public InteropRegisterer() {
super(new Strategy[] { });
}
}

9
src/main/strategies/spoofax_prop/strategies/Main.java

@ -0,0 +1,9 @@
package spoofax_prop.strategies;
import org.strategoxt.lang.Context;
public class Main {
public static void init(Context context) {
}
}

50
syntax/Common.sdf3

@ -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-Propositional-Language.sdf3

@ -0,0 +1,17 @@
module Spoofax-Propositional-Language
imports
Common
context-free start-symbols
Start
context-free sorts
Start
context-free syntax
Start.Empty = <>

26
trans/analysis.str

@ -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

@ -0,0 +1,15 @@
module outline
imports
signatures/Spoofax-Propositional-Language-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

@ -0,0 +1,49 @@
module pp
imports
libstratego-gpp
libspoofax/sdf/pp
libspoofax/editor/refactoring/-
pp/Spoofax-Propositional-Language-parenthesize
pp/Spoofax-Propositional-Language-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-Propositional-Language-string =
parenthesize-Spoofax-Propositional-Language
; prettyprint-Spoofax-Propositional-Language-start-symbols
; !V([], <id>)
; box2text-string(|120)
pp-partial-Spoofax-Propositional-Language-string =
parenthesize-Spoofax-Propositional-Language
; prettyprint-Spoofax-Propositional-Language
; !V([], <id>)
; box2text-string(|120)
pp-partial-Spoofax-Propositional-Language-string(|sort) =
parenthesize-Spoofax-Propositional-Language
; prettyprint-Spoofax-Propositional-Language(|sort)
; !V([], <id>)
; box2text-string(|120)
pp-debug :
ast -> result
with
result := <pp-Spoofax-Propositional-Language-string> ast
<+ <bottomup(try(not(is-string); not(is-list); not(pp-Spoofax-Propositional-Language-string); debug(!"cannot pp ")))> ast
; result := ""
rules
construct-textual-change = construct-textual-change(pp-partial-Spoofax-Propositional-Language-string, parenthesize, override-reconstruction, resugar)

16
trans/spoofax_propositional_language.str

@ -0,0 +1,16 @@
module spoofax_propositional_language
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

@ -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…
Cancel
Save