init commit again

This commit is contained in:
Peter
2023-11-01 09:24:46 +01:00
commit 42da98a132
34 changed files with 1786 additions and 0 deletions

11
IBAF-Editor/.gitignore vendored Normal file
View File

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

View 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.18</version>
</extension>
</extensions>

View File

@@ -0,0 +1 @@
-Xmx512m

View File

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

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

2
IBAF-Editor/README.md Normal file
View File

@@ -0,0 +1,2 @@
# IBAF Language Specification

View File

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

View File

@@ -0,0 +1,15 @@
module Main
imports
Menus
Syntax
Analysis
Refactoring
language
extensions : iba
// Add this provider when switching Stratego to interpreted mode:
// provider : target/metaborg/stratego.ctree
provider : target/metaborg/stratego.jar

View File

@@ -0,0 +1,7 @@
module Menus
menus
menu: "Generation" (openeditor) (realtime)
action: "Generate Funcons" = generate-fct

View File

@@ -0,0 +1,7 @@
module Refactoring
menus
menu: "Refactoring"
action: "Rename" = rename-menu-action

View File

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

View File

@@ -0,0 +1,937 @@
definition
module Stratego-Sugar-Overlays
imports
Stratego-Core-Identifiers
Stratego-Sugar-Terms
exports
sorts Overlay
context-free syntax
Id "=" Term -> Overlay {cons("OverlayNoArgs")}
Id "(" {Id ","}* ")" "=" Term -> Overlay {cons("Overlay")}
module Stratego-Sugar-DynamicRules
imports
Stratego-Core-Identifiers
Stratego-Sugar-Strategies
Stratego-Sugar-Rules
exports
sorts ScopeLabels
context-free syntax
"{|" ScopeLabels ":" Strategy "|}" -> Strategy {cons("DynRuleScope")}
{DynRuleScopeId ","}* -> ScopeLabels
"~" Term -> ScopeLabels {cons("ScopeLabels")}
sorts DynRuleDef DynRuleId DynRuleScopeId RuleDec
context-free syntax
"rules" "(" DynRuleDef* ")" -> Strategy {cons("GenDynRules")}
Id "+" Term -> DynRuleDef {cons("AddScopeLabel")}
DynRuleId ":-" Term -> DynRuleDef {cons("UndefineDynRule")}
DynRuleId ":" Rule -> DynRuleDef {cons("SetDynRule")}
DynRuleId ":+" Rule -> DynRuleDef {cons("AddDynRule")}
DynRuleId ":" Term -> DynRuleDef {cons("SetDynRuleMatch")}
DynRuleId ":=" Term -> DynRuleDef {cons("DynRuleAssign")}
DynRuleId ":+=" Term -> DynRuleDef {cons("DynRuleAssignAdd")}
DynRuleId ":" Rule "depends" "on" Term -> DynRuleDef {cons("SetDynRuleDepends")}
RuleDec "." Term -> DynRuleId {cons("LabeledDynRuleId")}
RuleDec "+" Term -> DynRuleId {cons("AddLabelDynRuleId")}
RuleDec -> DynRuleId {cons("DynRuleId")}
Id "." Term -> DynRuleScopeId {cons("LabeledDynRuleScopeId")}
Id -> DynRuleScopeId {cons("DynRuleScopeId")}
context-free syntax
Id -> RuleDec {cons("RDecNoArgs")}
Id "(" {Typedid ","}* ")" -> RuleDec {cons("RDec")}
Id "(" {Typedid ","}*
"|" {Typedid ","}* ")" -> RuleDec {cons("RDecT")}
sorts RuleNames
context-free syntax
{Id ","}* -> RuleNames
"~" Term -> RuleNames {cons("RuleNames")}
"/" RuleNames "\\*" Strategy -> Strategy {cons("DynRuleIntersectFix")}
syntax
%% no space after RuleNames
"\\" <LAYOUT?-CF> <RuleNames-CF> "/*" <LAYOUT?-CF> <Strategy-CF>
-> <Strategy-CF> {cons("DynRuleUnionFix")}
%% 1 space after RuleNames
"\\" <LAYOUT?-CF> <RuleNames-CF> " /*" <LAYOUT?-CF> <Strategy-CF>
-> <Strategy-CF> {cons("DynRuleUnionFix")}
%% no space after RuleNames
"/" <LAYOUT?-CF> <RuleNames-CF> <LAYOUT?-CF> "\\"
<LAYOUT?-CF> <RuleNames-CF> "/*" <LAYOUT?-CF> <Strategy-CF>
-> <Strategy-CF> {cons("DynRuleIntersectUnionFix")}
%% 1 space after RuleNames
"/" <LAYOUT?-CF> <RuleNames-CF> <LAYOUT?-CF> "\\"
<LAYOUT?-CF> <RuleNames-CF> " /*" <LAYOUT?-CF> <Strategy-CF>
-> <Strategy-CF> {cons("DynRuleIntersectUnionFix")}
context-free syntax
Strategy "/" RuleNames"\\" Strategy -> Strategy {cons("DynRuleIntersect"),right}
Strategy "\\" RuleNames "/" Strategy -> Strategy {cons("DynRuleUnion"),right}
Strategy "/" RuleNames "\\"
RuleNames "/" Strategy -> Strategy {cons("DynRuleIntersectUnion"),right}
priorities
<StrategyAngle-CF> <LAYOUT?-CF> <Term-CF> -> <Strategy-CF> {cons("BA")}
> {
%% no space after RuleNames
"\\" <LAYOUT?-CF> <RuleNames-CF> "/*" <LAYOUT?-CF> <Strategy-CF>
-> <Strategy-CF> {cons("DynRuleUnionFix")}
%% 1 space after RuleNames
"\\" <LAYOUT?-CF> <RuleNames-CF> " /*" <LAYOUT?-CF> <Strategy-CF>
-> <Strategy-CF> {cons("DynRuleUnionFix")}
%% no space after RuleNames
"/" <LAYOUT?-CF> <RuleNames-CF> <LAYOUT?-CF> "\\"
<LAYOUT?-CF> <RuleNames-CF> "/*" <LAYOUT?-CF> <Strategy-CF>
-> <Strategy-CF> {cons("DynRuleIntersectUnionFix")}
%% 1 space after RuleNames
"/" <LAYOUT?-CF> <RuleNames-CF> <LAYOUT?-CF> "\\"
<LAYOUT?-CF> <RuleNames-CF> " /*" <LAYOUT?-CF> <Strategy-CF>
-> <Strategy-CF> {cons("DynRuleIntersectUnionFix")}
}
> <Strategy-CF> <LAYOUT?-CF> "=>" <LAYOUT?-CF> <Term-CF> -> <Strategy-CF> {cons("AM")}
context-free priorities
StrategyAngle Term -> Strategy {cons("BA")}
> "/" RuleNames "\\*" Strategy -> Strategy {cons("DynRuleIntersectFix")}
> Strategy "=>" Term -> Strategy {cons("AM")}
> Strategy "/" RuleNames "\\" Strategy -> Strategy {cons("DynRuleIntersect"),right}
> Strategy "\\" RuleNames "/" Strategy -> Strategy {cons("DynRuleUnion"),right}
> Strategy "/" RuleNames "\\"
RuleNames "/" Strategy -> Strategy {cons("DynRuleIntersectUnion"),right}
> Strategy ";" Strategy -> Strategy {cons("Seq"),right}
module Stratego-Sugar-Rules
imports Stratego-Sugar-Strategies
exports
sorts RuleDef
context-free syntax
Id ":" Rule -> RuleDef {cons("RDefNoArgs")}
Anno+ RuleDef -> Def {cons("AnnoDef")}
Id "(" {Typedid ","}* ")" ":" Rule -> RuleDef {cons("RDef")}
Id "(" {Typedid ","}*
"|" {Typedid ","}* ")" ":" Rule -> RuleDef {cons("RDefT")}
%% Rule definition with pattern matched term parameters
Id "(" {Typedid ","}*
"|" {Term ","}* ")" ":" Rule -> RuleDef {cons("RDefP"), avoid}
sorts Rule RuleCond
context-free syntax
Term "->" Term -> Rule {cons("RuleNoCond")} %% backward comp.
Term "->" Term "where" Strategy -> Rule {cons("Rule")} %% backward comp.
Term "->" Term RuleCond+ -> Rule {cons("Rule"), avoid}
"where" Strategy -> RuleCond {cons("WhereClause")}
"with" Strategy -> RuleCond {cons("WithClause")}
module Stratego-Sugar-Strategies
imports
Stratego-Core-Strategies
Stratego-Sugar-Terms
Stratego-Sugar-Constants
Stratego-Sugar-Signatures
exports
context-free syntax
Id "=" Strategy -> StrategyDef {cons("SDefNoArgs")}
Id "(" {Typedid ","}* ")" "=" Strategy -> StrategyDef {cons("SDef")}
%% Strategy definition with pattern matched term parameters
Id "(" {Typedid ","}* "|" {Term ","}* ")" "=" Strategy -> StrategyDef {cons("SDefP"), avoid}
context-free syntax
ID -> Typedid {cons("DefaultVarDec")}
sorts Rule
sorts StrategyParen StrategyCurly StrategyAngle
context-free syntax
%% Abstraction
SVar "(" {Strategy ","}* ")" -> Strategy {cons("Call")}
%% Match and build
"{" Strategy "}" -> Strategy {cons("ScopeDefault")}
%%"<" Strategy ">" Term -> Strategy {cons("BA")}
StrategyAngle Term -> Strategy {cons("BA")}
"<" Strategy ">" -> StrategyAngle {bracket} %% {cons("AngleStrat")}
%% Combinators
Strategy "<+" Strategy -> Strategy {cons("LChoice"),right}
"rec" Id "(" Strategy ")" -> Strategy {cons("Rec")}
"not" "(" Strategy ")" -> Strategy {cons("Not")}
"where" "(" Strategy ")" -> Strategy {cons("Where")}
"with" "(" Strategy ")" -> Strategy {cons("With"), prefer}
"test" "(" Strategy ")" -> Strategy {cons("Test")}
%% Primitives
"prim" "(" String ")" -> Strategy {cons("PrimNoArgs")}
"prim" "(" String "," {Term ","}* ")" -> Strategy {cons("Prim")}
%% Congruence operators
String -> Strategy {cons("StrCong")}
Int -> Strategy {cons("IntCong")}
Real -> Strategy {cons("RealCong")}
Char -> Strategy {cons("CharCong")}
String "(" {Strategy ","}* ")" -> Strategy {cons("CongQ")}
%%"(" {Strategy ","}* ")" -> Strategy {cons("TupleCong"),avoid}
Strategy StrategyCurly -> Strategy {cons("AnnoCong")}
"{" Strategy "}" -> StrategyCurly {cons("StrategyCurly")}
"(" ")" -> Strategy {cons("EmptyTupleCong")}
"(" Strategy ")" -> Strategy {bracket}
"(" Strategy "," {Strategy ","}+ ")" -> Strategy {cons("TupleCong")}
%% Mod -> Strategy {cons("ModCongNoArgs")}
%% Mod "(" {Strategy ","}* ")" -> Strategy {cons("ModCong")}
%% Id "^" Id -> Mod {cons("Mod")}
"[" {Strategy ","}* "]" -> Strategy {cons("ListCongNoTail")}
"[" {Strategy ","}* "|" Strategy "]" -> Strategy {cons("ListCong")}
%% Strategy "#" "(" StrategyInj ")" -> Strategy {cons("ExplodeCong")}
%% Strategy "#" "(" Strategy ")" -> Strategy {cons("ExplodeCong")}
Strategy "#" StrategyParen -> Strategy {cons("ExplodeCong")}
%% Syntactic sugar sugar
sorts SwitchCase
context-free syntax
SVar -> Strategy {cons("CallNoArgs")}
"\\" Rule "\\" -> Strategy {cons("LRule")}
"(" Rule ")" -> Strategy {cons("SRule")}
Strategy "+" Strategy -> Strategy {cons("Choice"),right}
Strategy "+>" Strategy -> Strategy {cons("RChoice"),right}
"proceed" "(" {Strategy "," }+ ")" -> Strategy {cons("Proceed"), prefer}
"if" Strategy "then" Strategy
"else" Strategy "end" -> Strategy {cons("CondChoice")}
"if" Strategy "then" Strategy "end" -> Strategy {cons("IfThen")}
"switch" Strategy SwitchCase* "end" -> Strategy {cons("SwitchChoiceNoOtherwise")}
"switch" Strategy SwitchCase*
"otherwise" ":" Strategy "end" -> Strategy {cons("SwitchChoice")}
"case" Strategy ":" Strategy -> SwitchCase {cons("SwitchCase")}
Strategy "=>" Term -> Strategy {cons("AM")}
Term ":=" Term -> Strategy {cons("Assign")}
%% Priorities
context-free priorities
{ Strategy StrategyCurly -> Strategy
Strategy "#" StrategyParen -> Strategy
}
> { "!" Term -> Strategy
"?" Term -> Strategy
}
> StrategyAngle Term -> Strategy
> Strategy "=>" Term -> Strategy
> Strategy ";" Strategy -> Strategy
> {right:
Strategy "+" Strategy -> Strategy
Strategy "<+" Strategy -> Strategy
Strategy "+>" Strategy -> Strategy
Strategy "<" StrategyMid
"+" Strategy -> Strategy
}
context-free priorities
Strategy -> StrategyMid
> Strategy "+" Strategy -> Strategy
context-free priorities
{ Strategy StrategyCurly -> Strategy
Strategy "#" StrategyParen -> Strategy
}
.> Term ":=" Term -> Strategy
module Stratego-Sugar-Terms
imports
Stratego-Core-Terms
Stratego-Sugar-Strategies
exports
sorts LID
context-free syntax
LId -> LID {cons("ListVar")}
LID -> Var {cons("Var")}
LID -> ID
context-free syntax
"_" PreTerm -> PreTerm {cons("BuildDefaultPT")}
"_" Term -> Term {cons("BuildDefault"),prefer}
Char -> PreTerm {cons("Char")}
PreTerm "{" {Term ","}* "}" -> Term {cons("AnnoList")}
PreTerm -> Term {cons("NoAnnoList")}
"<" Strategy ">" Term -> PreTerm {cons("App")}
"<" Strategy ">" Term -> Term {cons("App"),prefer}
StrategyAngle -> PreTerm {cons("RootApp")}
StrategyAngle -> Term {cons("RootApp"),prefer}
"(" {Term ","}* ")" -> PreTerm {cons("Tuple")}
"[" {Term ","}* "]" -> PreTerm {cons("List")}
"[" {Term ","}* "|" Term "]" -> PreTerm {cons("ListTail")}
context-free priorities
Term "#" "(" Term ")" -> PreTerm {cons("Explode")}
> PreTerm "{" {Term ","}* "}" -> Term {cons("AnnoList")}
> Var "@" Term -> Term {cons("As")}
module Stratego-Sugar-Signatures
imports
Stratego-Core-Signatures
Stratego-Sugar-Constants
exports
sorts Sort
context-free syntax
"[" {Sort ","}* "]" -> Sort {cons("SortList")}
"[" {Sort ","}* "|" Sort "]" -> Sort {cons("SortListTl")}
"(" {Sort ","}* ")" -> Sort {cons("SortTuple")}
sorts Kind
context-free syntax
"*" -> Kind {cons("Star")}
"**" -> Kind {cons("StarStar")}
module Stratego-Core-Signatures
imports
Stratego-Core-Identifiers
Stratego-Core-Constants
exports
sorts Sdecl
context-free syntax
"sorts" Sort* -> Sdecl {cons("Sorts")}
"constructors" Opdecl* -> Sdecl {cons("Constructors")}
sorts Sort
context-free syntax
LCID -> Sort {cons("SortVar")}
UCID -> Sort {cons("SortNoArgs")}
Id "(" {Sort ","}* ")" -> Sort {cons("Sort")}
sorts Opdecl
context-free syntax
Id ":" Type -> Opdecl {cons("OpDecl")}
String ":" Type -> Opdecl {cons("OpDeclQ")}
":" Type -> Opdecl {cons("OpDeclInj")}
context-free syntax
"external" Id ":" Type -> Opdecl {cons("ExtOpDecl")}
"external" String ":" Type -> Opdecl {cons("ExtOpDeclQ")}
"external" ":" Type -> Opdecl {cons("ExtOpDeclInj")}
sorts Type ArgType ConstType FunType RetType
context-free syntax
Sort -> ConstType {cons("ConstType")}
{ArgType "*"}+ "->" RetType -> FunType {cons("FunType")}
"(" Type ")" -> ArgType {bracket}
ConstType -> ArgType
Type -> RetType
FunType -> RetType {reject}
FunType -> Type
ConstType -> Type
%%%
%% Restriction is required for the Sort* in Sdecl: List(a) is
%% ambiguous.
%%%
context-free restrictions
Sort -/- [\(]
module Stratego-Core-Terms
imports
Stratego-Core-Identifiers
Stratego-Core-Constants
exports
sorts ID Var Wld
context-free syntax
Id -> Var {cons("Var")}
Id -> ID
%% ":" Var -> Var {cons("SeqVar")}
sorts Term PreTerm
context-free syntax
Var -> PreTerm
Var -> Term {prefer}
"_" -> Wld {cons("Wld")}
Wld -> PreTerm
Wld -> Term {prefer}
Int -> PreTerm {cons("Int")}
Real -> PreTerm {cons("Real")}
String -> PreTerm {cons("Str")}
Id "(" {Term ","}* ")" -> PreTerm {cons("Op")}
String "(" {Term ","}* ")" -> PreTerm {cons("OpQ")}
Term "#" "(" Term ")" -> PreTerm {cons("Explode")}
PreTerm "{^" PreTerm "}" -> Term {cons("Anno")}
Var "@" Term -> Term {cons("As"),prefer}
Var "@" PreTerm -> PreTerm {cons("As")}
context-free priorities
Term "#" "(" Term ")" -> PreTerm {cons("Explode")}
> Var "@" Term -> Term {cons("As")}
module Stratego-Core-Strategies
imports
Stratego-Core-Terms
Stratego-Core-Constants
Stratego-Core-Signatures
exports
sorts Def
context-free syntax
StrategyDef -> Def
Id -> SVar {cons("SVar")}
"let" Def* "in" Strategy "end" -> Strategy {cons("Let")}
SVar "(" {Strategy ","}* "|" {Term ","}* ")" -> Strategy {cons("CallT")}
"call" "(" Term "|" {Strategy ","}* "|" {Term ","}* ")" -> Strategy {cons("CallDynamic")}
sorts StrategyDef
context-free syntax
Id "(" {Typedid ","}*
"|" {Typedid ","}* ")" "=" Strategy -> StrategyDef {cons("SDefT")}
Anno+ StrategyDef -> Def {cons("AnnoDef")}
"external"
Id "(" {Typedid ","}*
"|" {Typedid ","}* ")" "=" Strategy -> StrategyDef {cons("ExtSDefInl")}
"external"
Id "(" {Typedid ","}*
"|" {Typedid ","}* ")" -> StrategyDef {cons("ExtSDef")}
"external"
EmptyId "(" {Typedid ","}*
"|" {Typedid ","}* ")" -> StrategyDef {cons("ExtSDef")}
sorts EmptyId
lexical syntax
-> EmptyId
sorts Anno
context-free syntax
"extend" -> Anno {cons("Extend")}
"override" -> Anno {cons("Override")}
"internal" -> Anno {cons("Internal")}
%% "sealed" -> Anno {cons("Sealed")}
%% "extensible" -> Anno {cons("Extensible")}
%% "overridable" -> Anno {cons("Overridable")}
lexical syntax
"extend" -> Keyword
"override" -> Keyword
"internal" -> Keyword
"sealed" -> Keyword
"extensible" -> Keyword
"overridable" -> Keyword
lexical restrictions
"extend"
"override"
"internal"
"sealed"
"extensible"
"overridable" -/- [a-zA-Z0-9\'\-\_]
sorts Typedid
context-free syntax
ID ":" Type -> Typedid {cons("VarDec")}
sorts Strategy SVar StrategyParen StrategyMid
context-free syntax
"(" Strategy ")" -> StrategyParen {cons("ParenStrat")}
"fail" -> Strategy {cons("Fail")}
"id" -> Strategy {cons("Id")}
"proceed" "(" {Strategy ","}* "|" {Term ","}* ")" -> Strategy {cons("ProceedT"), prefer}
"proceed" -> Strategy {cons("ProceedNoArgs"), prefer}
%% Match and build
"?" Term -> Strategy {cons("Match")}
"!" Term -> Strategy {cons("Build")}
"{" {ID ","}* ":" Strategy "}" -> Strategy {cons("Scope")}
%% Combinators
Strategy ";" Strategy -> Strategy {cons("Seq"),right}
Strategy "<" StrategyMid
"+" Strategy -> Strategy {cons("GuardedLChoice"),right}
Strategy -> StrategyMid
%% Primitives
"prim" "(" String "," {Strategy ","}* "|" {Term ","}*")" -> Strategy {cons("PrimT")}
%% Traversal
"some" "(" Strategy ")" -> Strategy {cons("Some")}
"one" "(" Strategy ")" -> Strategy {cons("One")}
"all" "(" Strategy ")" -> Strategy {cons("All")}
%% Priorities
context-free priorities
{ "!" Term -> Strategy {cons("Build")}
"?" Term -> Strategy {cons("Match")}
}
> Strategy ";" Strategy -> Strategy {cons("Seq"),right}
> {right:
Strategy "<" StrategyMid
"+" Strategy -> Strategy {cons("GuardedLChoice"),right}
}
context-free syntax
"import-term" "(" ModName ")" -> Strategy {cons("ImportTerm")}
module Stratego-Core-Modules
imports
Stratego-Core-Identifiers
Stratego-Core-Strategies
Stratego-Core-Signatures
exports
sorts Module
context-free syntax
"module" ModName Decl* -> Module {cons("Module")}
"specification" Decl* -> Module {cons("Specification")}
sorts Decl
context-free syntax
"imports" ImportModName* -> Decl {cons("Imports")}
"strategies" Def* -> Decl {cons("Strategies")}
"signature" Sdecl* -> Decl {cons("Signature")}
sorts ImportModName
context-free syntax
ModName -> ImportModName {cons("Import")}
syntax
<ModName-CF> "/" "-" -> <ImportModName-CF> {cons("ImportWildcard")}
module Stratego-Sugar-Modules
imports
Stratego-Core-Modules
Stratego-Sugar-Strategies
Stratego-Sugar-Signatures
Stratego-Sugar-Overlays
Stratego-Sugar-Rules
exports
sorts Decl Def
context-free syntax
"rules" Def* -> Decl {cons("Rules")}
"overlays" Overlay* -> Decl {cons("Overlays")}
RuleDef -> Def
module Stratego-Sugar-StringQuotations
exports
sorts
StringQuotation
StringQuotedPart1 StringQuotedChars1 DollarOpen1 DollarClose1 QuotedBracket1 Dollar1
StringQuotedPart2 StringQuotedChars2 DollarOpen2 DollarClose2 QuotedBracket2 Dollar2
StringQuotedPart3 StringQuotedChars3 DollarOpen3 DollarClose3 QuotedBracket3 Dollar3
StringQuotedPart4 StringQuotedChars4 DollarOpen4 DollarClose4 QuotedBracket4 Dollar4
Padding
context-free syntax
StringQuotation -> PreTerm
syntax
StringQuotation -> <PreTerm-CF>
"$" "[" Padding StringQuotedPart1* "]" -> StringQuotation {cons("StringQuotation1") }
Padding "[" <LAYOUT?-CF> <Term-CF> <LAYOUT?-CF> "]" -> StringQuotedPart1 {cons("StringEscape1")}
<StringQuotedChars1-LEX> -> StringQuotedPart1 {cons("QStr")}
<Dollar1-LEX> -> StringQuotedPart1 {cons("QDollar")}
"$" <QuotedBracket1-LEX> "$" -> StringQuotedPart1 {cons("QBr")}
~[\[\]\$]+ -> <StringQuotedChars1-LEX>
[\[\]] -> <QuotedBracket1-LEX>
"$" -> <Dollar1-LEX>
"$" "{" Padding StringQuotedPart2* "}" -> StringQuotation {cons("StringQuotation2") }
Padding "{" <LAYOUT?-CF> <Term-CF> <LAYOUT?-CF> "}" -> StringQuotedPart2 {cons("StringEscape2")}
<StringQuotedChars2-LEX> -> StringQuotedPart2 {cons("QStr")}
<Dollar2-LEX> -> StringQuotedPart2 {cons("QDollar")}
"$" <QuotedBracket2-LEX> "$" -> StringQuotedPart2 {cons("QBr")}
~[\{\}\$]+ -> <StringQuotedChars2-LEX>
[\{\}] -> <QuotedBracket2-LEX>
"$" -> <Dollar2-LEX>
"$" "(" Padding StringQuotedPart3* ")" -> StringQuotation {cons("StringQuotation3") }
Padding "(" <LAYOUT?-CF> <Term-CF> <LAYOUT?-CF> ")" -> StringQuotedPart3 {cons("StringEscape3")}
<StringQuotedChars3-LEX> -> StringQuotedPart3 {cons("QStr")}
<Dollar3-LEX> -> StringQuotedPart3 {cons("QDollar")}
"$" <QuotedBracket3-LEX> "$" -> StringQuotedPart3 {cons("QBr")}
~[\(\)\$]+ -> <StringQuotedChars3-LEX>
[\(\)] -> <QuotedBracket3-LEX>
"$" -> <Dollar3-LEX>
"$" "<" Padding StringQuotedPart4* ">" -> StringQuotation {cons("StringQuotation4") }
Padding "<" <LAYOUT?-CF> <Term-CF> <LAYOUT?-CF> ">" -> StringQuotedPart4 {cons("StringEscape4")}
<StringQuotedChars4-LEX> -> StringQuotedPart4 {cons("QStr")}
<Dollar4-LEX> -> StringQuotedPart4 {cons("QDollar")}
"$" <QuotedBracket4-LEX> "$" -> StringQuotedPart4 {cons("QBr")}
~[\<\>\$]+ -> <StringQuotedChars4-LEX>
[\<\>] -> <QuotedBracket4-LEX>
"$" -> <Dollar4-LEX>
%% Padding is a dummy lexical that will contain the indentation prefix of every quotation
<Padding-LEX> -> Padding
-> <Padding-LEX> {indentpadding}
lexical restrictions
StringQuotedChars1 -/- ~[\[\]\$]
StringQuotedChars2 -/- ~[\{\}\$]
StringQuotedChars3 -/- ~[\(\)\$]
StringQuotedChars4 -/- ~[\<\>\$]
Dollar1 -/- [\[\]] . [\$]
Dollar2 -/- [\{\}] . [\$]
Dollar3 -/- [\(\)] . [\$]
Dollar4 -/- [\<\>] . [\$]
module Stratego-Core-Constants
exports
sorts Int Real String StrChar
lexical syntax
[\-]? [0-9]+ -> Int
[\-]? [0-9]+ [\.] [0-9]+ -> Real
"\"" StrChar* "\"" -> String
~[\"\\] -> StrChar
[\\] [\"tnr\\] -> StrChar
module Stratego-Sugar-Constants
imports
Stratego-Core-Identifiers
Stratego-Core-Constants
Stratego-Sugar-StringQuotations
exports
sorts Char CharChar
lexical syntax
"'" CharChar "'" -> Char
~[\'] -> CharChar
[\\] [\'ntr\ ] -> CharChar
Char -> Id {reject}
module Stratego-Core-Identifiers
exports
sorts ModName ModNamePart
lexical syntax
{ModNamePart "/"}+ -> ModName
[a-zA-Z\.\_] [a-zA-Z0-9\'\.\-\_]* -> ModNamePart
lexical restrictions
ModName -/- [a-zA-Z0-9\'\.\-\_]
lexical syntax
"imports" -> ModName {reject}
"overlays" -> ModName {reject}
"rules" -> ModName {reject}
"signature" -> ModName {reject}
"strategies" -> ModName {reject}
sorts Id LId LCID UCID Wld
lexical syntax
[a-zA-Z\_] [a-zA-Z0-9\'\-\_]* -> Id
[a-zA-Z\_] [a-zA-Z0-9\'\-\_]* "*" -> LId
[\'] [a-z]+ -> Id
[a-z] [a-zA-Z0-9\'\-\_]* -> LCID
[A-Z] [a-zA-Z0-9\'\-\_]* -> UCID
lexical restrictions
Id -/- [a-zA-Z0-9\'\_\*]
Id -/- [\-].~[\>]
LId -/- [a-zA-Z0-9\'\-\_]
LCID -/- [a-zA-Z0-9\'\-\_]
UCID -/- [a-zA-Z0-9\'\-\_]
lexical syntax
"_" -> Id {reject}
"'" -> Id {reject}
Keyword -> Id {reject}
Keyword -> LId {reject}
Keyword -> LCID {reject}
Keyword -> UCID {reject}
lexical restrictions
"all"
"case" %% not reserved kw
"constructors"
"else" %% not reserved kw
"end" %% not reserved kw
"external" %% not reserved kw
"fail"
"id"
"if" %% not reserved kw
"in"
"imports" %% not reserved kw
"let"
"module"
"not"
"one"
"overlays"
"otherwise" %% not reserved kw
"prim"
"rec" %% not reserved kw
"rules"
"script"
"signature"
"some"
"sorts"
"strategies"
"stratego"
"switch" %% not reserved kw
"test"
"then" %% not reserved kw
"where"
"import-term"
-/- [a-zA-Z0-9\'\-\_]
context-free restrictions
Wld -/- [a-zA-Z0-9\'\-\_]
sorts Keyword
lexical syntax
"all" -> Keyword
"constructors" -> Keyword
"fail" -> Keyword
"id" -> Keyword
"in" -> Keyword
"let" -> Keyword
"module" -> Keyword
"not" -> Keyword
"one" -> Keyword
"overlays" -> Keyword
"prim" -> Keyword
"rules" -> Keyword
"script" -> Keyword
"signature" -> Keyword
"some" -> Keyword
"sorts" -> Keyword
"strategies" -> Keyword
"stratego" -> Keyword
"test" -> Keyword
"where" -> Keyword
"import-term" -> Keyword
module Stratego-Core-Layout
exports
sorts Ws ShortCom LongCom CommChar Asterisk Eof
lexical syntax
[\t\ \n\r] -> Ws
"//" ~[\n]* ([\n] | Eof) -> ShortCom
"/*" CommChar* "*/" -> LongCom
-> Eof
~[\*] -> CommChar
"*" -> Asterisk
Asterisk -> CommChar
lexical restrictions
Asterisk -/- [\/]
Eof -/- ~[]
lexical syntax
ShortCom -> LAYOUT
LongCom -> LAYOUT
Ws -> LAYOUT
context-free restrictions
LAYOUT? -/- [\ \t\n\r]
LAYOUT? -/- [\/].[\*]
LAYOUT? -/- [\/].[\/]
module Stratego-Sugar-Layout
imports Stratego-Core-Layout
%%exports
%% sorts VeryLongCom Eof VLCchar Backslash
%% lexical syntax
%% "\\end{code}" VLCchar* "\\begin{code}" -> VeryLongCom
%% "\\begin{code}" -> VeryLongCom
%% "\\end{code}" VLCchar* Eof -> VeryLongCom
%% "\\literate" VLCchar* "\\begin{code}" -> VeryLongCom
%% ~[\\] -> VLCchar
%% Backslash -> VLCchar
%% [\\] -> Backslash
%% lexical restrictions
%% Backslash -/- [b].[e].[g].[i].[n].[\{].[c].[o].[d].[e].[\}]
%% Eof -/- ~[]
%% lexical syntax
%% VeryLongCom -> LAYOUT
module Stratego-Sugar
imports
Stratego-Sugar-Layout
Stratego-Core-Identifiers
Stratego-Sugar-Constants
Stratego-Sugar-Modules
Stratego-Sugar-Signatures
Stratego-Sugar-Terms
Stratego-Sugar-Strategies
Stratego-Sugar-Rules
Stratego-Sugar-DynamicRules
Stratego-Sugar-Overlays
hiddens
context-free start-symbols Module
module Stratego
imports Stratego-Sugar
hiddens
context-free start-symbols Module
module StrategoMix[Ctx0]
imports Stratego
[ RuleNames => RuleNames[[Ctx0]]
RuleDec => RuleDec[[Ctx0]]
DynRuleScopeId => DynRuleScopeId[[Ctx0]]
DynRuleId => DynRuleId[[Ctx0]]
DynRuleDef => DynRuleDef[[Ctx0]]
ScopeLabels => ScopeLabels[[Ctx0]]
RuleCond => RuleCond[[Ctx0]]
Rule => Rule[[Ctx0]]
RuleDef => RuleDef[[Ctx0]]
Overlay => Overlay[[Ctx0]]
SwitchCase => SwitchCase[[Ctx0]]
StrategyCurly => StrategyCurly[[Ctx0]]
StrategyAngle => StrategyAngle[[Ctx0]]
Kind => Kind[[Ctx0]]
LID => LID[[Ctx0]]
ImportModName => ImportModName[[Ctx0]]
Decl => Decl[[Ctx0]]
Module => Module[[Ctx0]]
StrategyParen => StrategyParen[[Ctx0]]
Typedid => Typedid[[Ctx0]]
Anno => Anno[[Ctx0]]
EmptyId => EmptyId[[Ctx0]]
StrategyDef => StrategyDef[[Ctx0]]
SVar => SVar[[Ctx0]]
Def => Def[[Ctx0]]
Type => Type[[Ctx0]]
RetType => RetType[[Ctx0]]
ArgType => ArgType[[Ctx0]]
FunType => FunType[[Ctx0]]
ConstType => ConstType[[Ctx0]]
Opdecl => Opdecl[[Ctx0]]
Sort => Sort[[Ctx0]]
Sdecl => Sdecl[[Ctx0]]
Wld => Wld[[Ctx0]]
ID => ID[[Ctx0]]
Var => Var[[Ctx0]]
CharChar => CharChar[[Ctx0]]
Char => Char[[Ctx0]]
Padding => Padding[[Ctx0]]
Dollar4 => Dollar4[[Ctx0]]
QuotedBracket4 => QuotedBracket4[[Ctx0]]
StringQuotedChars4 => StringQuotedChars4[[Ctx0]]
StringQuotedPart4 => StringQuotedPart4[[Ctx0]]
Dollar3 => Dollar3[[Ctx0]]
QuotedBracket3 => QuotedBracket3[[Ctx0]]
StringQuotedChars3 => StringQuotedChars3[[Ctx0]]
StringQuotedPart3 => StringQuotedPart3[[Ctx0]]
Dollar2 => Dollar2[[Ctx0]]
QuotedBracket2 => QuotedBracket2[[Ctx0]]
StringQuotedChars2 => StringQuotedChars2[[Ctx0]]
StringQuotedPart2 => StringQuotedPart2[[Ctx0]]
Dollar1 => Dollar1[[Ctx0]]
QuotedBracket1 => QuotedBracket1[[Ctx0]]
StringQuotedChars1 => StringQuotedChars1[[Ctx0]]
StringQuotedPart1 => StringQuotedPart1[[Ctx0]]
StringQuotation => StringQuotation[[Ctx0]]
StrChar => StrChar[[Ctx0]]
String => String[[Ctx0]]
Real => Real[[Ctx0]]
Int => Int[[Ctx0]]
Keyword => Keyword[[Ctx0]]
UCID => UCID[[Ctx0]]
LCID => LCID[[Ctx0]]
LId => LId[[Ctx0]]
Id => Id[[Ctx0]]
ModNamePart => ModNamePart[[Ctx0]]
ModName => ModName[[Ctx0]]
PreTerm => PreTerm[[Ctx0]]
Term => Term[[Ctx0]]
StrategyMid => StrategyMid[[Ctx0]]
Strategy => Strategy[[Ctx0]] ]

42
IBAF-Editor/metaborg.yaml Normal file
View File

@@ -0,0 +1,42 @@
---
id: org.example:IBAF-Editor:0.1.0-SNAPSHOT
name: IBAF
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}
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:
enabled: true
pretty-print: IBAF
sdf2table: java
placeholder:
prefix: "$"
stratego:
enabled: true
format: jar
args:
- -la
- stratego-lib
- -la
- stratego-gpp
- -la
- stratego-sglr
- -la
- stratego-xtc
- -la
- stratego-aterm
- -la
- stratego-sdf
- -la
- strc
exports:

64
IBAF-Editor/pom.xml Normal file
View 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>IBAF-Editor</artifactId>
<version>0.1.0-SNAPSHOT</version>
<packaging>spoofax-language</packaging>
<parent>
<groupId>org.metaborg</groupId>
<artifactId>parent.language</artifactId>
<version>2.5.18</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>

View File

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

View File

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

View File

@@ -0,0 +1,9 @@
module Funcons-pp
imports Funcons
context-free syntax
FCT.FCTAppComp = <
<{NAME " "}+>
<FCT> > // for pp only

View File

@@ -0,0 +1,87 @@
module Funcons
context-free start-symbols
Start
context-free syntax
Start = FCT {avoid}
FCT-SEQ.FCTSequence = <
<FCT-SEQ>,
<FCT-SEQ>> {right}
FCT-SEQ.FCTEmpty =
FCT-SEQ = FCT
FCT.FCTInt =
INT
FCT.FCTFloat =
FLOAT
FCT.FCTChar =
CHAR
FCT.FCTString =
STRING
FCT.FCTDoubleQuoted =
<\\"<FCT-Quoted>\\">
FCT.FCTVar
= VAR
FCT.FCTName
= NAME
FCT.FCTApp = <
<NAME> <FCT> >
// FCT.FCTSemantics = SEM-NAME PHRASE-FCT FCT?
FCT.FCTTyped = <
<FCT>:<FCT> > {non-assoc}
FCT.FCTComplement = <
~ <FCT> >
FCT.FCTComputes = <
<FCT?> =\> <FCT> > {non-assoc}
FCT.FCTPostfix = <
<FCT><POSTFIX> >
FCT.FCTUnion = <
<FCT> | <{FCT " | "}+> >
FCT.FCTIntersect = <
<FCT> & <{FCT " & "}+> >
FCT.FCTGroup = <
(<FCT-SEQ>) >
FCT.FCTList = <
[<FCT-SEQ>] >
FCT.FCTSet = <
{<FCT-SEQ>} >
FCT.FCTMap = <
{<{FCT-POINT ",\n"}*>} >
FCT-POINT.Point = <
<FCT> |-\> <FCT> >
FCT-Quoted.FCTQuotedEmpty =
lexical syntax
INT = "-"? [0-9]+
FLOAT = "-"? [0-9]+ "." [0-9]+
CHAR = "'" ~[] "'"
STRING = "\"" STRING-CHAR* "\""
STRING-CHAR = ~[\"\n] | "\\\"" | BACKSLASH
BACKSLASH = "\\"
NAME = [a-z] [a-zA-Z0-9\-]*
VAR = [A-Z] [a-zA-Z]* ([\-] [a-zA-Z]+)* SUFFIX? POSTFIX?
SUFFIX = [0-9]+ | [\']+ | ([0-9]+ [\']+)
POSTFIX = "*" | "+" | "?"
LAYOUT = [\ \t\n\r]
LAYOUT = "/*" (~[\*] | STAR)* "*/"
STAR = "*"
LAYOUT = "//" ~[\n\r]* ([\n\r] | EOF)
EOF =
lexical restrictions
INT -/- [0-9]
FLOAT -/- [0-9]
NAME -/- [a-zA-Z0-9\-]
BACKSLASH -/- [\"]
STAR -/- [\/]
EOF -/- ~[]
context-free restrictions
LAYOUT? -/- [\ \t\n\r]
LAYOUT? -/- [\/].[\/]
LAYOUT? -/- [\/].[\*]

View File

@@ -0,0 +1,12 @@
module IBAF
imports
IBAF-Start
context-free start-symbols
Start
context-free syntax
Start = L-start

View File

@@ -0,0 +1,11 @@
module Stratego-IBAF
imports
Stratego
IBAF
exports context-free syntax
Module -> Start
"|[" FCT-SEQ "]|" -> Term {cons("ToTerm"),prefer}
variables
"START" -> L-start {prefer}

View File

@@ -0,0 +1,72 @@
module IBAF-Start
imports
Funcons
// Language "IBAFlang"
lexical syntax // Language
LEX-int = ( [0-9] )+
LEX-id = ( [a-z] ) ( [a-z] | [0-9] )*
syntax // Language
context-free syntax // Language
L-start.L-start--L-exp =
L-exp
L-exp.L-exp--L-int =
L-int
L-exp.L-exp--L-id =
L-id
L-exp.L-exp--R-lambda-L-id-DOT-L-exp =
"lambda" L-id "." L-exp
L-exp.L-exp--L-exp-LPAREN-L-exp-RPAREN =
L-exp "(" L-exp ")"
L-exp.L-exp--R-let-L-id-EQUALS-L-exp-R-in-L-exp =
"let" L-id "=" L-exp "in" L-exp
L-exp.L-exp--LPAREN-L-exp-RPAREN =
"(" L-exp ")"
L-int.LEX-int =
LEX-int
L-id.LEX-id =
LEX-id
context-free syntax // Semantics
FCT.T-start =
"start" "[:" L-start ":]"
FCT.T-eval =
"eval" "[:" L-exp ":]"
FCT-Quoted.L-int = L-int
FCT.T-int =
"int" "[:" L-int ":]"
FCT-Quoted.L-id = L-id
FCT.T-id =
"id" "[:" L-id ":]"
context-free syntax // Desugaring
variables // Meta-variables
L-start = "(:START" [1-9]? ":)" {prefer}
L-start? = "(:START" [1-9]? "?:)" {prefer}
L-start* = "(:START" [1-9]? "*:)" {prefer}
L-start+ = "(:START" [1-9]? "+:)" {prefer}
L-exp = "(:E" [1-9]? ":)" {prefer}
L-exp? = "(:E" [1-9]? "?:)" {prefer}
L-exp* = "(:E" [1-9]? "*:)" {prefer}
L-exp+ = "(:E" [1-9]? "+:)" {prefer}
L-int = "(:N" [1-9]? ":)" {prefer}
L-int? = "(:N" [1-9]? "?:)" {prefer}
L-int* = "(:N" [1-9]? "*:)" {prefer}
L-int+ = "(:N" [1-9]? "+:)" {prefer}
L-id = "(:X" [1-9]? ":)" {prefer}
L-id? = "(:X" [1-9]? "?:)" {prefer}
L-id* = "(:X" [1-9]? "*:)" {prefer}
L-id+ = "(:X" [1-9]? "+:)" {prefer}
// SDF comments
sorts // ASTs
T-start

View File

@@ -0,0 +1,34 @@
module analysis
imports
libstratego-lib
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
rules // Rename refactoring
// change last strategy argument to id if multi-file analysis is enabled
rename-menu-action = nabl2-rename-action(construct-textual-change, editor-analyze, fail)

View File

@@ -0,0 +1 @@
Meta([Syntax("Stratego-IBAF")])

View File

@@ -0,0 +1,53 @@
module IBAF-Start
imports
libstratego-gpp
signatures/-
pp/IBAF-parenthesize
pp/IBAF-pp
imports
// Language "IBAFlang"
rules
to-funcons:
|[ start[: (:E:) :] ]| ->
|[ initialise-binding finalise-failing eval[: (:E:) :] ]|
to-funcons:
|[ eval[: (:N:) :] ]| ->
|[ int[: (:N:) :] ]|
to-funcons:
|[ eval[: (:X:) :] ]| ->
|[ bound id[: (:X:) :] ]|
to-funcons:
|[ eval[: lambda(:X:).(:E:) :] ]| ->
|[ function closure scope (bind (id[: (:X:) :],
given),
eval[: (:E:) :]) ]|
to-funcons:
|[ eval[: (:E1:)((:E2:)) :] ]| ->
|[ apply (eval[: (:E1:) :],
eval[: (:E2:) :]) ]|
to-funcons:
|[ eval[: let(:X:)=(:E1:)in(:E2:) :] ]| ->
|[ scope (bind (id[: (:X:) :],
eval[: (:E1:) :]),
eval[: (:E2:) :]) ]|
to-funcons:
|[ eval[: ((:E:)) :] ]| ->
|[ eval[: (:E:) :] ]|
to-funcons-lex:
FCTDoubleQuoted(L-int(LEX-int(str))) ->
FCTString(<double-quote> str)
to-funcons:
|[ int[: (:N:) :] ]| ->
|[ decimal \"(:N:)\" ]|
to-funcons-lex:
FCTDoubleQuoted(L-id(LEX-id(str))) ->
FCTString(<double-quote> str)
to-funcons:
|[ id[: (:X:) :] ]| ->
|[ \"(:X:)\" ]|

View File

@@ -0,0 +1 @@
Meta([Syntax("Stratego-IBAF")])

View File

@@ -0,0 +1,118 @@
module generate
imports
libstratego-gpp
signatures/-
pp/IBAF-parenthesize
pp/IBAF-pp
pp/Funcons-pp-pp
cbs-gen/IBAF-Start
rules // Builder
// Generates a funcon term for selected AST.
generate-fct:
(selected, position, ast, path, project-path) -> (filename, result)
where <not(has-extension(|"fct"))> <debug> path
with
filename := <guarantee-extension(|"fct")> path;
funcons := <to-funcons-top> selected;
result := <prettyprint-IBAF-string> funcons
generate-fct:
(selected, position, ast, path, project-path) -> None()
where <has-extension(|"fct")> path
prettyprint-IBAF-string =
parenthesize-IBAF
; prettyprint-IBAF-Start
; !V([], <id>)
; box2text-string(|80)
to-funcons-start: START -> |[ start[: START :] ]|
to-funcons-top =
to-funcons-start;
innermost(to-desugared <+ to-funcons <+ to-funcons-default);
bottomup(try(to-funcons-lex));
innermost(to-funcons-sequences <+ to-funcons-groups);
innermost(to-funcons-apps)
to-funcons = fail
to-funcons-default = fail
to-desugared = fail
// Funcons involved in simplification rules:
rules
to-funcons-sequences:
FCTSequence(FCTEmpty(),seq) -> seq
to-funcons-sequences:
FCTSequence(seq,FCTEmpty()) -> seq
to-funcons-sequences:
FCTApp("sequential",FCTGroup(FCTSequence(fct,FCTApp("sequential",FCTGroup(seq))))) ->
FCTApp("sequential",FCTGroup(FCTSequence(fct,seq)))
to-funcons-groups:
FCTGroup(FCTGroup(seq)) -> FCTGroup(seq)
to-funcons-apps:
FCTApp(f1,FCTApp(f2,fct)) -> FCTAppComp([f1,f2],fct)
to-funcons-apps:
FCTApp(f,FCTAppComp(fs,fct)) -> FCTAppComp([f|fs],fct)
to-funcons-apps:
FCTApp(f,FCTGroup(seq)) -> FCTAppComp([f],FCTGroup(seq))
rules
to-funcons-lex:
FCTString(str) -> FCTString(<double-quote> str)
to-funcons-lex = ?FCTInt(_)
to-funcons-lex = ?FCTChar(_)
to-funcons-lex: FCTApp("integer-add",FCTGroup(FCTSequence(FCTInt(s),FCTInt(t)))) ->
FCTInt(<addi;int-to-string>(<string-to-int> s, <string-to-int> t))
to-funcons-lex: FCTApp("string-append",FCTGroup(FCTSequence(FCTString(str1),FCTString(str2)))) ->
FCTString(<concat-strings;double-quote> [<un-double-quote> str1, <un-double-quote> str2])
to-funcons-lex: FCTApp("string-append",FCTGroup(FCTSequence(FCTString(str1),FCTSequence(FCTString(str2),FCTString(str3))))) ->
FCTString(<concat-strings;double-quote>
[<un-double-quote> str1, <un-double-quote> str2, <un-double-quote> str3])
// generalise to nested sequences
to-funcons-lex: FCTList(seq) ->
FCTString(<concat-strings;double-quote> l)
where
<not(?FCTEmpty())> seq;
l := <to-funcons-string-list>(seq, [])
// l accumulates a list of strings, initially []:
to-funcons-string-list: (FCTSequence(seq1, seq2), l) ->
<to-funcons-string-list>(seq1, <to-funcons-string-list>(seq2, l))
to-funcons-string-list: (FCTEmpty(), l) -> l
// 'C':
to-funcons-string-list: (FCTString(str), l) ->
[<un-single-quote>str | l]
// ascii-character("C"):
to-funcons-string-list:
(FCTApp("ascii-character", FCTGroup(FCTString(str))), l) ->
[<un-double-quote>str | l]
// ascii-character("\C"):
to-funcons-string-list:
(FCTApp("ascii-character", FCTApp("list-to-string", FCTList(seq))), l) ->
<to-funcons-string-list>(seq, l)

View File

@@ -0,0 +1,21 @@
module ibaf
imports
libstratego-lib
imports
completion/completion
pp
outline
analysis
imports
generate
rules // Debugging
debug-show-aterm:
(node, _, _, path, project-path) -> (filename, result)
with
filename := <guarantee-extension(|"aterm")> path
; result := node

View File

@@ -0,0 +1,18 @@
module outline
imports
libstratego-lib
imports
signatures/IBAF-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

52
IBAF-Editor/trans/pp.str Normal file
View File

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

View File

@@ -0,0 +1,12 @@
module statics
imports
signatures/-
rules
init ^ (s) := new s.
[[ _ ^ (s) ]].

17
IBAF-cbs/.project Normal file
View File

@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>IBAF-cbs</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.metaborg.spoofax.eclipse.builder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.metaborg.spoofax.eclipse.nature</nature>
</natures>
</projectDescription>

1
IBAF-cbs/Funcons-beta Symbolic link
View File

@@ -0,0 +1 @@
/home/peter/cbs-all/CBS-beta/Funcons-beta

View File

@@ -0,0 +1,47 @@
Language "IBAFlang"
Syntax START:start ::= exp
Semantics start[[ _:start ]] : =>values
Rule start[[ E ]] =
initialise-binding finalise-failing eval[[ E ]]
Syntax E:exp ::= int
| id
| 'lambda' id '.' exp
| exp '(' exp ')'
| 'let' id '=' exp 'in' exp
| '(' exp ')'
Semantics eval[[ _:exp ]] : => values
Rule eval[[ N ]] = int[[ N ]]
Rule eval[[ X ]] = bound id[[ X ]]
Rule eval[[ 'lambda' X '.' E ]] =
function closure
scope( bind( id[[ X ]], given ),
eval[[ E ]] )
Rule eval[[ E1 '(' E2 ')' ]] =
apply( eval[[ E1 ]], eval[[ E2 ]] )
Rule eval[[ 'let' X '=' E1 'in' E2 ]] =
scope( bind( id[[ X ]], eval[[ E1 ]] ),
eval[[ E2 ]] )
Rule eval[[ '(' E ')' ]] = eval[[ E ]]
Lexis N:int ::= ('0'-'9')+
Semantics int[[ N:int ]] : => integers
= decimal \"N\"
Lexis X:id ::= ('a'-'z') ('a'-'z'|'0'-'9')*
Semantics id[[ X:id ]] : => identifiers
= \"X\"