forked from glen/fostr
init: SDF3/Statix project as initialized by Spoofax
This commit is contained in:
commit
9ecfa63f58
11
.gitignore
vendored
Normal file
11
.gitignore
vendored
Normal file
@ -0,0 +1,11 @@
|
||||
/.cache
|
||||
/bin
|
||||
/src-gen
|
||||
/target
|
||||
|
||||
/.classpath
|
||||
/.project
|
||||
/.settings
|
||||
/.factorypath
|
||||
|
||||
/.polyglot.metaborg.yaml
|
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.6.0-SNAPSHOT</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>
|
18
README.md
Normal file
18
README.md
Normal file
@ -0,0 +1,18 @@
|
||||
# fostr Language Specification
|
||||
|
||||
## Using Statix for multi-file analysis
|
||||
|
||||
By default the project is configured to analyze all files of your language in
|
||||
isolation -- single-file analysis. It is also possible to configure the project
|
||||
such that all files are analyzed together, and files can refer to each other --
|
||||
multi-file analysis.
|
||||
|
||||
To enable multi-file analysis, do the following:
|
||||
1. Uncomment the `(multifile)` option in `editor/Analysis.esv`
|
||||
2. Uncomment the multi-file definition, and comment the single-file version, of
|
||||
`editor-analyze` in `trans/analysis.str`.
|
||||
|
||||
NB. When working in an IDE such as Eclipse, it is necessary to _restart the IDE_
|
||||
after switching from single-file to multi-file analysis or vice versa. Failure to
|
||||
do so will result in exceptions during analysis.
|
||||
|
24
editor/Analysis.esv
Normal file
24
editor/Analysis.esv
Normal file
@ -0,0 +1,24 @@
|
||||
module Analysis
|
||||
|
||||
imports
|
||||
|
||||
statix/Menus
|
||||
|
||||
language
|
||||
|
||||
// see README.md for details on how to switch to multi-file analysis
|
||||
|
||||
observer : editor-analyze (constraint) // (multifile)
|
||||
|
||||
references
|
||||
|
||||
reference _ : editor-resolve
|
||||
|
||||
hover _ : editor-hover
|
||||
|
||||
menus
|
||||
|
||||
menu: "Analysis" (openeditor)
|
||||
|
||||
action: "Show pre-analyzed AST" = debug-show-pre-analyzed (source)
|
||||
action: "Show analyzed AST" = debug-show-analyzed
|
13
editor/Main.esv
Normal file
13
editor/Main.esv
Normal file
@ -0,0 +1,13 @@
|
||||
module Main
|
||||
|
||||
imports
|
||||
|
||||
Syntax
|
||||
Analysis
|
||||
|
||||
language
|
||||
|
||||
extensions : fos
|
||||
|
||||
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/fostr-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
|
43
metaborg.yaml
Normal file
43
metaborg.yaml
Normal file
@ -0,0 +1,43 @@
|
||||
---
|
||||
id: org.studioinfinity:fostr:0.1.0-SNAPSHOT
|
||||
name: fostr
|
||||
dependencies:
|
||||
compile:
|
||||
- org.metaborg:org.metaborg.meta.lang.esv:${metaborgVersion}
|
||||
- org.metaborg:org.metaborg.meta.lang.template:${metaborgVersion}
|
||||
- org.metaborg:statix.lang:${metaborgVersion}
|
||||
- org.metaborg:sdf3.ext.statix:${metaborgVersion}
|
||||
- org.metaborg:dynsem:${metaborgVersion}
|
||||
source:
|
||||
- org.metaborg:meta.lib.spoofax:${metaborgVersion}
|
||||
- org.metaborg:statix.runtime:${metaborgVersion}
|
||||
pardonedLanguages:
|
||||
- EditorService
|
||||
- Stratego-Sugar
|
||||
- SDF
|
||||
language:
|
||||
sdf:
|
||||
pretty-print: fostr
|
||||
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:
|
||||
- language: ATerm
|
||||
directory: src-gen/statix
|
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.studioinfinity</groupId>
|
||||
<artifactId>fostr</artifactId>
|
||||
<version>0.1.0-SNAPSHOT</version>
|
||||
<packaging>spoofax-language</packaging>
|
||||
|
||||
<parent>
|
||||
<groupId>org.metaborg</groupId>
|
||||
<artifactId>parent.language</artifactId>
|
||||
<version>2.6.0-SNAPSHOT</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/fostr/strategies/InteropRegisterer.java
Normal file
10
src/main/strategies/fostr/strategies/InteropRegisterer.java
Normal file
@ -0,0 +1,10 @@
|
||||
package fostr.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/fostr/strategies/Main.java
Normal file
9
src/main/strategies/fostr/strategies/Main.java
Normal file
@ -0,0 +1,9 @@
|
||||
package fostr.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/fostr.sdf3
Normal file
17
syntax/fostr.sdf3
Normal file
@ -0,0 +1,17 @@
|
||||
module fostr
|
||||
|
||||
imports
|
||||
|
||||
Common
|
||||
|
||||
context-free start-symbols
|
||||
|
||||
Start
|
||||
|
||||
context-free sorts
|
||||
|
||||
Start
|
||||
|
||||
context-free syntax
|
||||
|
||||
Start.Empty = <>
|
46
trans/analysis.str
Normal file
46
trans/analysis.str
Normal file
@ -0,0 +1,46 @@
|
||||
module analysis
|
||||
|
||||
imports
|
||||
|
||||
statixruntime
|
||||
statix/api
|
||||
|
||||
pp
|
||||
injections/-
|
||||
|
||||
libspoofax/term/origin
|
||||
|
||||
rules // Analysis
|
||||
|
||||
// single-file analysis
|
||||
editor-analyze = stx-editor-analyze(pre-analyze, post-analyze|"statics", "programOk")
|
||||
|
||||
// see README.md for details on how to switch to multi-file analysis
|
||||
// multi-file analysis
|
||||
// editor-analyze = stx-editor-analyze(pre-analyze, post-analyze|"statics", "projectOk", "fileOk")
|
||||
|
||||
pre-analyze = origin-track-forced(explicate-injections-fostr-Start)
|
||||
post-analyze = origin-track-forced(implicate-injections-fostr-Start)
|
||||
|
||||
rules // Editor Services
|
||||
|
||||
editor-resolve = stx-editor-resolve
|
||||
|
||||
editor-hover = stx-editor-hover
|
||||
|
||||
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 pre-analyzed abstract syntax ATerm of a selection.
|
||||
debug-show-pre-analyzed: (selected, _, _, path, project-path) -> (filename, result)
|
||||
with filename := <guarantee-extension(|"pre-analyzed.aterm")> path
|
||||
; result := <pre-analyze> 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
|
16
trans/fostr.str
Normal file
16
trans/fostr.str
Normal file
@ -0,0 +1,16 @@
|
||||
module fostr
|
||||
|
||||
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
|
15
trans/outline.str
Normal file
15
trans/outline.str
Normal file
@ -0,0 +1,15 @@
|
||||
module outline
|
||||
|
||||
imports
|
||||
|
||||
signatures/fostr-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/fostr-parenthesize
|
||||
pp/fostr-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-fostr-string =
|
||||
parenthesize-fostr
|
||||
; prettyprint-fostr-start-symbols
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-partial-fostr-string =
|
||||
parenthesize-fostr
|
||||
; prettyprint-fostr
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-partial-fostr-string(|sort) =
|
||||
parenthesize-fostr
|
||||
; prettyprint-fostr(|sort)
|
||||
; !V([], <id>)
|
||||
; box2text-string(|120)
|
||||
|
||||
pp-debug :
|
||||
ast -> result
|
||||
with
|
||||
result := <pp-fostr-string> ast
|
||||
<+ <bottomup(try(not(is-string); not(is-list); not(pp-fostr-string); debug(!"cannot pp ")))> ast
|
||||
; result := ""
|
||||
|
||||
rules
|
||||
|
||||
construct-textual-change = construct-textual-change(pp-partial-fostr-string, parenthesize, override-reconstruction, resugar)
|
24
trans/statics.stx
Normal file
24
trans/statics.stx
Normal file
@ -0,0 +1,24 @@
|
||||
module statics
|
||||
|
||||
// see README.md for details on how to switch to multi-file analysis
|
||||
|
||||
rules // single-file entry point
|
||||
|
||||
programOk : Start
|
||||
|
||||
programOk(Empty()).
|
||||
|
||||
rules // multi-file entry point
|
||||
|
||||
projectOk : scope
|
||||
|
||||
projectOk(s).
|
||||
|
||||
fileOk : scope * Start
|
||||
|
||||
fileOk(s, Empty()).
|
||||
|
||||
signature
|
||||
|
||||
sorts Start constructors
|
||||
Empty : Start
|
Loading…
Reference in New Issue
Block a user