diff --git a/Makefile b/Makefile deleted file mode 100644 index 043824d..0000000 --- a/Makefile +++ /dev/null @@ -1,33 +0,0 @@ -# The ueber-based test approach -test: - @swipl -q -f main.pro - -# Force file creation -create: - @swipl -q -f main.pro -- create - -# Force file overriding -override: - @swipl -q -f main.pro -- override - -# create and override combined -force: - @swipl -q -f main.pro -- create override - -# Broken, old tests; still some porting needed -test-old: - make prelude.test - make term.test - make cfg.test - make dict.test - make graph.test - make mm.test - make mt.test - make plt.test - make dgl.test - make java.test - -%.test: - @echo Testing package $* ... - @swipl -q -f packages/$*.pro -g $*_main - diff --git a/README.md b/README.md deleted file mode 100644 index b7b4bda..0000000 --- a/README.md +++ /dev/null @@ -1,7 +0,0 @@ -This code base captures some part of the body of knowledge on Software Language Engineering. This effort covers some elements of parsing, unparsing, editing, transformation, analysis, semantics, metamodeling, model transformations, and yet others. A more profound description is on its way. All rights reserved for the code, as it stands. A liberal license will be applied soon. Disclaimer: this material is under construction. - -Ralf Lämmel, 27 October 2013 - -README last revised on 2 October 2014 - -PS: I am making this code openly available, as I am using bits in tutorials. (I have given related tutorials at SPLASH 2013 and MODELS 2014.) Discalimer: again, this material is not polished and probably needs a lot more work to be operationally useful for others. diff --git a/TODO b/TODO deleted file mode 100644 index 6fb2a5d..0000000 --- a/TODO +++ /dev/null @@ -1,37 +0,0 @@ -- Parsing - * Support separator lists; see, e.g., cs-to-as.pro in languages/ddl. - * Flatten lexical parse trees -- An FSM language - - Concrete syntax for FSMs - - Code generator for Java - - Export to GraphViz - - Simulation as semantics - - Determinism/Termination as static semantics -- Grow a language like Anya - * SimplTrivial.rsc - * SimplVars.rsc - * SimplFuns.rsc - * SimplExpr.rsc? -- Demonstrate megamodeling; see attic/ontologies -- Add operators for figures -- What other cool but simple DSL? -- Something based on a solver -- Add prelude/rewriting.pro -- Use strategies in expr language -- Use strategies in yafpl language -- Consider a variation on expr with integers -- QVT/TGG/ATL -- Some (what?) ontology use -- Concrete object syntax -- Partial evaluation for yafpl -- Semantics for expr -- Semantics for figure (GraphViz) -- Name binding etc. -- Attributed trees -- Attribute grammars -- Attribute evaluation -- Felleisen style semantics -- Concept extraction and traceability across artifacts -- Lambda calculi -- Object calculi -- Soundness proof diff --git a/attic/ontology/languages.pro b/attic/ontology/languages.pro deleted file mode 100644 index 601088e..0000000 --- a/attic/ontology/languages.pro +++ /dev/null @@ -1,53 +0,0 @@ -language( - 'Prolog', - [], - [pro] -). - -language( - 'Text', - [], - [txt] -). - -language( - 'Term', - ['Prolog terms as used by this chrestomathy'], - [term] -). - -language( - 'Haskell', - [Haskell programs], - [hs] -). - -language( - 'BSL', - ['Basic Signature Language as used by this chrestomathy'], - [] -). - -language( - 'ESL', - ['Extended Signature Language as used by this chrestomathy'], - [] -). - -language( - 'BGL', - ['Basic Grammar Language as used by this chrestomathy'], - [] -). - -language( - 'EGL', - ['Extended Grammar Language as used by this chrestomathy'], - [egn] -). - -language( - 'MML', - ['Metamodeling Language as used by this chrestomathy'], - [mml] -). diff --git a/attic/oocfg-oocfg.term b/attic/oocfg-oocfg.term deleted file mode 100644 index 0e534e4..0000000 --- a/attic/oocfg-oocfg.term +++ /dev/null @@ -1,52 +0,0 @@ -( - grammar, - [ - (n, rules- - ] -) - - -grammar : - rules # rule* - ; - -rule : chain ; -rule : struct ; - -chain : - super # name - ':' - sub # name - ';' - ; - -struct : - lhs # name - ':' - rhs # symbol* - ';' - ; - -symbol : t ; -symbol : n ; - -t : - terminal # qstring - ; - -n : - selector # name - '#' - nonterminal # name - cardinality # cardinality - ; - -cardinality : star ; -cardinality : plus ; -cardinality : option ; -cardinality : one ; - -star : '*' ; -plus : '+' ; -option : '?' ; -one : ; diff --git a/attic/oocfg-oocfg.txt b/attic/oocfg-oocfg.txt deleted file mode 100644 index 54adbfa..0000000 --- a/attic/oocfg-oocfg.txt +++ /dev/null @@ -1,44 +0,0 @@ -grammar : - rules # rule* - ; - -rule : chain ; -rule : struct ; - -chain : - super # name - ':' - sub # name - ';' - ; - -struct : - lhs # name - ':' - rhs # symbol* - ';' - ; - -symbol : t ; -symbol : n ; - -t : - terminal # qstring - ; - -n : - selector # name - '#' - nonterminal # name - cardinality # cardinality - ; - -cardinality : star ; -cardinality : plus ; -cardinality : option ; -cardinality : one ; - -star : '*' ; -plus : '+' ; -option : '?' ; -one : ; diff --git a/languages/.ueber b/languages/.ueber deleted file mode 100644 index 0dbd0fd..0000000 --- a/languages/.ueber +++ /dev/null @@ -1,2 +0,0 @@ -[ -]. diff --git a/languages/bfpl/.ueber b/languages/bfpl/.ueber deleted file mode 100644 index 00e44f3..0000000 --- a/languages/bfpl/.ueber +++ /dev/null @@ -1,25 +0,0 @@ -[ - % Syntax and sample - macro(eglSyntax(bfpl)), - macro(eslSyntax(bfpl)), - macro(parse(bfpl)), - - % Wellness - language(bfpl(ok(term))), - membership(bfpl(ok(term)), okProg, []), - elementOf('sample.term', bfpl(ok(term))), - - % Results of interpretation - language(bfpl(value(term))), - language(bfpl(normal(term))), - membership(bfpl(value(term)), value, []), - membership(bfpl(normal(term)), normal, []), - elementOf('sample.value', bfpl(value(term))), - elementOf('sample.normal', bfpl(normal(term))), - - % Interpretation - mapsTo(bigStep, ['sample.term'], ['sample.value']), - mapsTo(smallStep, ['sample.term'], ['sample.normal']), - mapsTo(denotational, ['sample.term'], ['sample.value']) - -]. diff --git a/languages/bfpl/README.md b/languages/bfpl/README.md deleted file mode 100644 index a6ad5c4..0000000 --- a/languages/bfpl/README.md +++ /dev/null @@ -1,26 +0,0 @@ -# Yet Another Functional Programming Language - -This folder contains the specification/implementation of YAFPL, a small subset of Haskell - -### Syntax - -* [cs.egl](cs.egl) specifies the concrete syntax of the language -* [ls.egl](ls.egl) specifies the lexical syntax of the language -* [cs-to-as.pro](cs-to-as.pro) maps concrete syntax trees to abstract syntax trees -* [as.esl](as.esl) specifies the signature of the abstract syntax -* [as-to-cs.pro](as-to-cs.pro) maps (unparses) abstract syntax trees to concrete syntax trees - -### Semantics - -* [big-step](big-step/) contains dynamic semantics specified as big-step rules -* [small-step](small-step/) contains dynamics semantics specified as small-step rules -* [denotational](denotational/) contains a denotational semantics specification of dynamic semantics -* [wellness](wellness/) contains static semantics, disguised as a wellness-checker (typechecker) - -### Examples - -* [sample-factorial.hs](sample-factorial.hs) is a small example program - -### Other - -The `*.term` files contain Prolog terms, usually the AST or CST of the corresponding file. diff --git a/languages/bfpl/as-to-cs.pro b/languages/bfpl/as-to-cs.pro deleted file mode 100644 index 1aec0a3..0000000 --- a/languages/bfpl/as-to-cs.pro +++ /dev/null @@ -1,120 +0,0 @@ -% Render lists of functions -ppProg(L, S) :- - map(ppFun, L, Bs), - pp(vlist(Bs), S). - -% Render functions -ppFun( - (Sig, N, Args, Body), - vlist([ - B1, - hlist([text(N), B2, text(' =')]), - indent(indent(B3)) - ]) -) :- - ppSig(Sig, B1), - ppArgs(Args, B2), - ppExpr(Body, B3). - -% Render function signatures -ppSig( - (N, [Arg|Args], Res), - hlist([ - text(N), - text(' :: '), - B1, - B2, - text(' -> '), - B3 - ]) -) :- - ppType(Arg, B1), - ppArgTypes(Args, B2), - ppType(Res, B3). - -% Render more argument types -ppArgTypes([], empty). -ppArgTypes( - [Arg|Args], - hlist(text(' -> '), B1, B2) -) :- - ppType(Arg, B1), - ppArgTypes(Args, B2). - -% Render types -ppType(inttype, text('Int')). -ppType(booltype, text('Bool')). - -% Render arguments -ppArgs([], empty). -ppArgs( - [Arg|Args], - indent(hbox(text(Arg), B)) -) :- - ppArgs(Args, B). - -% Render constants -ppExpr(intconst(I), text(I)). -ppExpr(boolconst(true), text('True')). -ppExpr(boolconst(false), text('False')). - -% Render variable names -ppExpr(name(N), text(N)). - -% Render conditionals -ppExpr( - if(E1, E2, E3), - vbox( - hlist([text('if'), indent(B1)]), - indent(indent(vbox( - hbox(text('then'), indent(B2)), - hbox(text('else'), indent(B3)) - ))) - ) -) :- - ppExpr(E1, B1), - ppExpr(E2, B2), - ppExpr(E3, B3). - -% Render operator applications -ppExpr( - op(O, E1, E2), - hlist([ - text('('), - text('('), - B0, - text(')'), - indent(B1), - indent(B2), - text(')') - ]) -) :- - ppOp(O, B0), - ppExpr(E1, B1), - ppExpr(E2, B2). - -ppExpr( - apply(N, Es), - hlist([ - text('('), - text(N), - B, - text(')') - ]) -) :- - ppArgExprs(Es, B). - -% Render operators -ppOp(add, text('+')). -ppOp(sub, text('-')). -ppOp(mult, text('*')). -ppOp(eq, text('==')). - -% Render argument expresssions -ppArgExprs([], empty). -ppArgExprs( - [Arg|Args], - indent(hbox(B1, B2)) -) :- - ppExpr(Arg, B1), - ppArgExprs(Args, B2). diff --git a/languages/bfpl/as.esl b/languages/bfpl/as.esl deleted file mode 100644 index 559dcf2..0000000 --- a/languages/bfpl/as.esl +++ /dev/null @@ -1,19 +0,0 @@ -type program = (function*, main); -type function = (funsig, fundef); -type funsig = (name, simpletype*, simpletype); -type fundef = (name, name*, expr); -type main = expr; -symbol inttype : -> simpletype; -symbol booltype : -> simpletype; -symbol intconst : integer -> expr; -symbol boolconst : boolean -> expr; -symbol name : name -> expr; -symbol if : expr x expr x expr -> expr; -symbol op : op x expr x expr -> expr; -symbol apply : name x expr* -> expr; -symbol add : -> op; -symbol sub : -> op; -symbol mult : -> op; -symbol eq : -> op; -type name = atom; - diff --git a/languages/bfpl/as.term b/languages/bfpl/as.term deleted file mode 100644 index b122688..0000000 --- a/languages/bfpl/as.term +++ /dev/null @@ -1 +0,0 @@ -[type(program,tuple([star(sort(function)),sort(main)])),type(function,tuple([sort(funsig),sort(fundef)])),type(funsig,tuple([sort(name),star(sort(simpletype)),sort(simpletype)])),type(fundef,tuple([sort(name),star(sort(name)),sort(expr)])),type(main,sort(expr)),symbol(inttype,[],simpletype),symbol(booltype,[],simpletype),symbol(intconst,[integer],expr),symbol(boolconst,[boolean],expr),symbol(name,[sort(name)],expr),symbol(if,[sort(expr),sort(expr),sort(expr)],expr),symbol(op,[sort(op),sort(expr),sort(expr)],expr),symbol(apply,[sort(name),star(sort(expr))],expr),symbol(add,[],op),symbol(sub,[],op),symbol(mult,[],op),symbol(eq,[],op),type(name,atom)]. \ No newline at end of file diff --git a/languages/bfpl/big-step/.ueber b/languages/bfpl/big-step/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/bfpl/big-step/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/bfpl/big-step/evaluate.pro b/languages/bfpl/big-step/evaluate.pro deleted file mode 100644 index b6806c7..0000000 --- a/languages/bfpl/big-step/evaluate.pro +++ /dev/null @@ -1,33 +0,0 @@ -% Evaluate main expression of program -bigStep((Fs, E), V) :- - evaluate(Fs, [], E, V). - -% A constant evaluates to itself -evaluate(_, _, intconst(I), intval(I)). - -% A variable evaluates to its binding -evaluate(_, X, name(N), V) :- - member((N, V), X). - -% True condition -evaluate(P, X, if(E1, E2, _), V) :- - evaluate(P, X, E1, boolval(true)), - evaluate(P, X, E2, V). - -% False condition -evaluate(P, X, if(E1, _, E2), V) :- - evaluate(P, X, E1, boolval(false)), - evaluate(P, X, E2, V). - -% Evaluate operator application -evaluate(P, X, op(O, E1, E2), V0) :- - evaluate(P, X, E1, V1), - evaluate(P, X, E2, V2), - opVal(O, V1, V2, V0). - -% Evaluate function application -evaluate(P, X1, apply(N, Es), V) :- - map(evaluate(P, X1), Es, Vs), - member((_, (N, Ns, E)), P), - zip(Ns, Vs, X2), - evaluate(P, X2, E, V). diff --git a/languages/bfpl/big-step/op.pro b/languages/bfpl/big-step/op.pro deleted file mode 100644 index e9686e1..0000000 --- a/languages/bfpl/big-step/op.pro +++ /dev/null @@ -1,11 +0,0 @@ -opVal(add, intval(I1), intval(I2), intval(I0)) :- - I0 is I1 + I2. - -opVal(sub, intval(I1), intval(I2), intval(I0)) :- - I0 is I1 - I2. - -opVal(mult, intval(I1), intval(I2), intval(I0)) :- - I0 is I1 * I2. - -opVal(eq, intval(I1), intval(I2), boolval(B0)) :- - toBoolean((I1==I2), B0). diff --git a/languages/bfpl/big-step/value.pro b/languages/bfpl/big-step/value.pro deleted file mode 100644 index fb5303d..0000000 --- a/languages/bfpl/big-step/value.pro +++ /dev/null @@ -1,2 +0,0 @@ -value(intval(_)). -value(boolval(_)). diff --git a/languages/bfpl/cs-to-as.pro b/languages/bfpl/cs-to-as.pro deleted file mode 100644 index e7d6960..0000000 --- a/languages/bfpl/cs-to-as.pro +++ /dev/null @@ -1,18 +0,0 @@ -% Mapping for function types -bfplMapping(type, (T1, Ts1), ([T1|Ts2], T2)) :- - append(Ts2, [T2], Ts1). - -% Eliminate layering in expressions -bfplMapping(expr, subexpr(E), E). - -% Eliminate brackets in expressions -bfplMapping(subexpr, brackets(E), E). - -% Lexical mapping for int -bfplMapping(int, Digits, Int) :- - number_codes(Int, Digits). - -% Lexical mapping for name -bfplMapping(name, (Char, String), Atom) :- - name(Atom, [Char|String]). - diff --git a/languages/bfpl/cs.egl b/languages/bfpl/cs.egl deleted file mode 100644 index 9442eaf..0000000 --- a/languages/bfpl/cs.egl +++ /dev/null @@ -1,22 +0,0 @@ -program : { function }* main ; -function : funsig fundef ; -funsig : name '::' type ; -fundef : name { name }* '=' expr ; -type : simpletype { '->' simpletype }* ; -main : 'main' '=' 'print' '$' expr ; - -[inttype] simpletype : 'Int' ; -[booltype] simpletype : 'Bool' ; - -[op] expr : '(' op ')' subexpr subexpr ; -[subexpr] expr : subexpr ; -[apply] expr : name { subexpr }+ ; -[intconst] subexpr : int ; -[brackets] subexpr : '(' expr ')' ; -[if] subexpr : 'if' expr 'then' expr 'else' expr ; -[name] subexpr : name ; - -[add] op : '+' ; -[sub] op : '-' ; -[mult] op : '*' ; -[eq] op : '==' ; diff --git a/languages/bfpl/cs.term b/languages/bfpl/cs.term deleted file mode 100644 index d0fbbe6..0000000 --- a/languages/bfpl/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],program,[star([n(function)]),n(main)]), ([],function,[n(funsig),n(fundef)]), ([],funsig,[n(name),t(::),n(type)]), ([],fundef,[n(name),star([n(name)]),t(=),n(expr)]), ([],type,[n(simpletype),star([t(->),n(simpletype)])]), ([],main,[t(main),t(=),t(print),t($),n(expr)]), ([inttype],simpletype,[t('Int')]), ([booltype],simpletype,[t('Bool')]), ([op],expr,[t('('),n(op),t(')'),n(subexpr),n(subexpr)]), ([subexpr],expr,[n(subexpr)]), ([apply],expr,[n(name),plus([n(subexpr)])]), ([intconst],subexpr,[n(int)]), ([brackets],subexpr,[t('('),n(expr),t(')')]), ([if],subexpr,[t(if),n(expr),t(then),n(expr),t(else),n(expr)]), ([name],subexpr,[n(name)]), ([add],op,[t(+)]), ([sub],op,[t(-)]), ([mult],op,[t(*)]), ([eq],op,[t(==)])]. \ No newline at end of file diff --git a/languages/bfpl/functional/.ueber b/languages/bfpl/functional/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/bfpl/functional/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/bfpl/functional/efpl/Main.efpl b/languages/bfpl/functional/efpl/Main.efpl deleted file mode 100644 index 55ea37f..0000000 --- a/languages/bfpl/functional/efpl/Main.efpl +++ /dev/null @@ -1,11 +0,0 @@ -module Main where - -import Stdlib -import Sample -import Semantics - -showValue :: Option Value -> String -showValue (Some (IntVal x)) = show x -showValue (Some (BoolVal x)) = show x - -main = putStrLn (showValue (evalP sample)) diff --git a/languages/bfpl/functional/efpl/Main.hs b/languages/bfpl/functional/efpl/Main.hs deleted file mode 120000 index 3497ff0..0000000 --- a/languages/bfpl/functional/efpl/Main.hs +++ /dev/null @@ -1 +0,0 @@ -Main.efpl \ No newline at end of file diff --git a/languages/bfpl/functional/efpl/Sample.efpl b/languages/bfpl/functional/efpl/Sample.efpl deleted file mode 100644 index 0fe4070..0000000 --- a/languages/bfpl/functional/efpl/Sample.efpl +++ /dev/null @@ -1,18 +0,0 @@ -module Sample where - -import Stdlib -import Syntax - -sample :: Program -sample = Program - (Cons - (Function - (FunSig "factorial" (Cons IntType Nil) IntType ) - (FunDef "factorial" (Cons "x" Nil) - (If (Op Eq (Name "x") (IntConst 0)) - (IntConst 1) - (Op Mult (Name "x") - (Apply "factorial" - (Cons (Op Sub (Name "x") (IntConst 1)) Nil)))))) - Nil) - (Apply "factorial" (Cons (IntConst 5) Nil)) diff --git a/languages/bfpl/functional/efpl/Sample.hs b/languages/bfpl/functional/efpl/Sample.hs deleted file mode 120000 index c4201b1..0000000 --- a/languages/bfpl/functional/efpl/Sample.hs +++ /dev/null @@ -1 +0,0 @@ -Sample.efpl \ No newline at end of file diff --git a/languages/bfpl/functional/efpl/Semantics.efpl b/languages/bfpl/functional/efpl/Semantics.efpl deleted file mode 100644 index a50ebfe..0000000 --- a/languages/bfpl/functional/efpl/Semantics.efpl +++ /dev/null @@ -1,47 +0,0 @@ -module Semantics where - -import Stdlib -import Syntax - -data Value - = IntVal Int - | BoolVal Bool - -type Env = List (Pair String Value) - -evalP :: Program -> Option Value -evalP (Program fs e) = evalE fs Nil e - -evalE :: List Function -> Env -> Expr -> Option Value -evalE _ _ (IntConst x) = Some (IntVal x) -evalE _ _ (BoolConst x) = Some (BoolVal x) -evalE fs env (Name x) = Some (second (find (testName x) env)) -evalE fs env (If e0 e1 e2) - = cond - (evalE fs env e0) - (evalE fs env e1) - (evalE fs env e2) -evalE fs env (Op o e1 e2) - = op o - (evalE fs env e1) - (evalE fs env e2) -evalE fs env (Apply f args) - = apply fs - (find (testFunction f) fs) - (optionlist (maplist (evalE fs env) args)) - -apply :: List Function -> Function -> Option (List Value) -> Option Value -apply _ _ None = None -apply fs (Function _ (FunDef _ formals e)) (Some actuals) = - evalE fs (ziplist formals actuals) e - -cond :: Option Value -> Option Value -> Option Value -> Option Value -cond (Some (BoolVal b)) v1 v2 = if b then v1 else v2 -cond _ _ _ = None - -op :: Op -> Option Value -> Option Value -> Option Value -op Add (Some (IntVal x)) (Some (IntVal y)) = Some (IntVal (x+y)) -op Sub (Some (IntVal x)) (Some (IntVal y)) = Some (IntVal (x-y)) -op Mult (Some (IntVal x)) (Some (IntVal y)) = Some (IntVal (x*y)) -op Eq (Some (IntVal x)) (Some (IntVal y)) = Some (BoolVal (x==y)) -op _ _ _ = None diff --git a/languages/bfpl/functional/efpl/Semantics.hs b/languages/bfpl/functional/efpl/Semantics.hs deleted file mode 120000 index 36c9abd..0000000 --- a/languages/bfpl/functional/efpl/Semantics.hs +++ /dev/null @@ -1 +0,0 @@ -Semantics.efpl \ No newline at end of file diff --git a/languages/bfpl/functional/efpl/Stdlib.efpl b/languages/bfpl/functional/efpl/Stdlib.efpl deleted file mode 100644 index 3ac61c8..0000000 --- a/languages/bfpl/functional/efpl/Stdlib.efpl +++ /dev/null @@ -1,41 +0,0 @@ -module Stdlib where - -data Pair x y = Pair x y -data Option x = None | Some x -data List x = Nil | Cons x (List x) - -first :: Pair a b -> a -first (Pair x _) = x - -second :: Pair a b -> b -second (Pair _ y) = y - -isNone :: Option x -> Bool -isNone None = True -isNone (Some _) = False - -isSome :: Option x -> Bool -isSome None = False -isSome (Some _) = True - -maplist :: (a -> b) -> List a -> List b -maplist f Nil = Nil -maplist f (Cons x l) = Cons (f x) (maplist f l) - -ziplist :: List a -> List b -> List (Pair a b) -ziplist Nil Nil = Nil -ziplist (Cons x1 l1) (Cons x2 l2) = Cons (Pair x1 x2) (ziplist l1 l2) -ziplist _ _ = error "ziplist" - -find :: (a -> Bool) -> List a -> a -find f Nil = error "find" -find f (Cons x l) = if f x then x else find f l - -optionlist :: List (Option a) -> Option (List a) -optionlist Nil = Some Nil -optionlist (Cons x l) = optionlist2 x (optionlist l) - -optionlist2 :: Option a -> Option (List a) -> Option (List a) -optionlist2 None _ = None -optionlist2 _ None = None -optionlist2 (Some x) (Some l) = Some (Cons x l) diff --git a/languages/bfpl/functional/efpl/Stdlib.hs b/languages/bfpl/functional/efpl/Stdlib.hs deleted file mode 120000 index 8152521..0000000 --- a/languages/bfpl/functional/efpl/Stdlib.hs +++ /dev/null @@ -1 +0,0 @@ -Stdlib.efpl \ No newline at end of file diff --git a/languages/bfpl/functional/efpl/Syntax.efpl b/languages/bfpl/functional/efpl/Syntax.efpl deleted file mode 100644 index 82d1549..0000000 --- a/languages/bfpl/functional/efpl/Syntax.efpl +++ /dev/null @@ -1,23 +0,0 @@ -module Syntax where - -import Stdlib - -data Program = Program (List Function) Expr -data Function = Function FunSig FunDef -data FunSig = FunSig String (List SimpleType) SimpleType -data FunDef = FunDef String (List String) Expr -data SimpleType = IntType | BoolType -data Expr - = IntConst Int - | BoolConst Bool - | Name String - | If Expr Expr Expr - | Op Op Expr Expr - | Apply String (List Expr) -data Op = Add | Sub | Mult | Eq - -testName :: String -> Pair String a -> Bool -testName x (Pair y _) = x == y - -testFunction :: String -> Function -> Bool -testFunction x (Function (FunSig y _ _) _) = x == y diff --git a/languages/bfpl/functional/efpl/Syntax.hs b/languages/bfpl/functional/efpl/Syntax.hs deleted file mode 120000 index 80cbb91..0000000 --- a/languages/bfpl/functional/efpl/Syntax.hs +++ /dev/null @@ -1 +0,0 @@ -Syntax.efpl \ No newline at end of file diff --git a/languages/bfpl/functional/efpl/Types.efpl b/languages/bfpl/functional/efpl/Types.efpl deleted file mode 100644 index c9ed29f..0000000 --- a/languages/bfpl/functional/efpl/Types.efpl +++ /dev/null @@ -1,45 +0,0 @@ -module Types where - -import Stdlib -import Syntax - -type TypeEnv = List (Pair String SimpleType) - -okP :: Program -> Bool -okP (Program fs e) = okE fs Nil e - -okE :: List Function -> TypeEnv -> Expr -> SimpleType -okE _ _ (IntConst _) = IntType -okE _ _ (BoolConst _) = BoolType - -{- -okE fs env (Name x) = second (find (testName x) env) -okE fs env (If e0 e1 e2) - = cond - (okE fs env e0) - (okE fs env e1) - (okE fs env e2) -okE fs env (Op o e1 e2) - = op o - (okE fs env e1) - (okE fs env e2) -okE fs env (Apply f args) - = apply fs - (find (testFunction f) fs) - (maplist (okE fs env) args) - -apply :: List Function -> Function -> List Value -> Value -apply fs (Function _ (FunDef _ formals e)) actuals = - okE fs (ziplist formals actuals) e - -cond :: Value -> Value -> Value -> Value -cond (BoolVal b) v1 v2 = if b then v1 else v2 -cond _ _ _ = ErrorVal - -op :: Op -> Value -> Value -> Value -op Add (IntVal x) (IntVal y) = IntVal (x+y) -op Sub (IntVal x) (IntVal y) = IntVal (x-y) -op Mult (IntVal x) (IntVal y) = IntVal (x*y) -op Eq (IntVal x) (IntVal y) = BoolVal (x==y) -op _ _ _ = ErrorVal --} diff --git a/languages/bfpl/functional/efpl/Types.hs b/languages/bfpl/functional/efpl/Types.hs deleted file mode 120000 index 4a52053..0000000 --- a/languages/bfpl/functional/efpl/Types.hs +++ /dev/null @@ -1 +0,0 @@ -Types.efpl \ No newline at end of file diff --git a/languages/bfpl/functional/prolog/.ueber b/languages/bfpl/functional/prolog/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/bfpl/functional/prolog/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/bfpl/functional/prolog/combinators.pro b/languages/bfpl/functional/prolog/combinators.pro deleted file mode 100644 index 09b7e86..0000000 --- a/languages/bfpl/functional/prolog/combinators.pro +++ /dev/null @@ -1,39 +0,0 @@ -% Helper function for environment passing -passTo(X, F, V) :- - apply(F, [X, V]). - -% Apply a 'lazy' meaning in conditional -lazyApply(M, X, V) :- - apply(M, [F]), - passTo(X, F, V). - -% Lookup function on lists of pairs -lookup(N, X, V) :- - once(member((N, V), X)). - -% Semantical conditional -conditional(F0, M1, M2, X, V) :- - passTo(X, F0, B), - ( B == boolval(true), - lazyApply(M1, X, V) - ; B == boolval(false), - lazyApply(M2, X, V) - ). - -% Operation application on environments -operation(O, F1, F2, X, V0) :- - passTo(X, F1, V1), - passTo(X, F2, V2), - apply(O, [V1, V2, V0]). - -% Function application on environments -application( - Ns, % Names to be bound in argument - Fs, % Meanings of arguments - F, % Meaning of function definition - X1, % Environment - V % Result -) :- - map(passTo(X1), Fs, Vs), - zip(Ns, Vs, X2), - passTo(X2, F, V). diff --git a/languages/bfpl/functional/prolog/expr.pro b/languages/bfpl/functional/prolog/expr.pro deleted file mode 100644 index b1ae888..0000000 --- a/languages/bfpl/functional/prolog/expr.pro +++ /dev/null @@ -1,48 +0,0 @@ -% Meaning of constants -meaningExpr( - _, % Program irrelevant - intconst(I), % Syntactical phrase - const(intval(I)) % Constant function on the environment -). - -% Meaning of names -meaningExpr( - _, % Program irrelevant - name(N), % Name - lookup(N) % Lookup function on the environment -). - -% Meaning of conditionals -meaningExpr( - P, % Program to be passed on - if(E1, E2, E3), % Syntactical phrase - conditional( % Semantical conditional - F1, - meaningExpr(P, E2), % Lazy - meaningExpr(P, E3) % Lazy - ) -) :- - meaningExpr(P, E1, F1). - -% Meaning of operator applications -meaningExpr( - P, % Program to be passed on - op(O, E1, E2), % Syntactical phrase - operation(opVal(O), F1, F2) -) :- - meaningExpr(P, E1, F1), - meaningExpr(P, E2, F2). - -% Meaning of function applications -meaningExpr( - P, % Program to be passed on - apply(N, Es), % Syntactical phrase - application( % Function on environment - Ns, % Names to be bound in argument - Fs, % Meanings of arguments - F % Meaning of definition - ) -) :- - member((_, (N, Ns, E)), P), - map(meaningExpr(P), Es, Fs), - meaningExpr(P, E, F). diff --git a/languages/bfpl/functional/prolog/op.pro b/languages/bfpl/functional/prolog/op.pro deleted file mode 100644 index 754c1e2..0000000 --- a/languages/bfpl/functional/prolog/op.pro +++ /dev/null @@ -1,19 +0,0 @@ -meaningOp(add, F1, F2, X, intval(I0)) :- - passTo(F1, [X, I1]), - apply(F2, [X, I2]), - I0 is I1 + I2. - -meaningOp(sub, F1, F2, X, intval(I0)) :- - apply(F1, [X, I1]), - apply(F2, [X, I2]), - I0 is I1 - I2. - -meaningOp(mult, F1, F2, X, intval(I0)) :- - apply(F1, [X, I1]), - apply(F2, [X, I2]), - I0 is I1 * I2. - -meaningOp(eq, F1, F2, boolval(B0)) :- - apply(F1, [X, I1]), - apply(F2, [X, I2]), - toBoolean((I1==I2), B0). diff --git a/languages/bfpl/functional/prolog/prog.pro b/languages/bfpl/functional/prolog/prog.pro deleted file mode 100644 index 7f83f40..0000000 --- a/languages/bfpl/functional/prolog/prog.pro +++ /dev/null @@ -1,4 +0,0 @@ -% Evaluate main expression of program -denotational((Fs, E), V) :- - meaningExpr(Fs, E, F), - passTo([], F, V). diff --git a/languages/bfpl/ls.egl b/languages/bfpl/ls.egl deleted file mode 100644 index 0d87f37..0000000 --- a/languages/bfpl/ls.egl +++ /dev/null @@ -1,3 +0,0 @@ -name : lower { alpha }* ; -int : { digit }+ ; -layout : { space }+ ; diff --git a/languages/bfpl/ls.term b/languages/bfpl/ls.term deleted file mode 100644 index 82c232b..0000000 --- a/languages/bfpl/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],name,[n(lower),star([n(alpha)])]), ([],int,[plus([n(digit)])]), ([],layout,[plus([n(space)])])]. diff --git a/languages/bfpl/sample.bfpl b/languages/bfpl/sample.bfpl deleted file mode 100644 index f2165ba..0000000 --- a/languages/bfpl/sample.bfpl +++ /dev/null @@ -1,6 +0,0 @@ -factorial :: Int -> Int -factorial x = - if ((==) x 0) - then 1 - else ((*) x (factorial ((-) x 1))) -main = print $ factorial 5 diff --git a/languages/bfpl/sample.hs b/languages/bfpl/sample.hs deleted file mode 120000 index 54dd452..0000000 --- a/languages/bfpl/sample.hs +++ /dev/null @@ -1 +0,0 @@ -sample.bfpl \ No newline at end of file diff --git a/languages/bfpl/sample.normal b/languages/bfpl/sample.normal deleted file mode 100644 index de5b513..0000000 --- a/languages/bfpl/sample.normal +++ /dev/null @@ -1,2 +0,0 @@ -intconst(120). - diff --git a/languages/bfpl/sample.term b/languages/bfpl/sample.term deleted file mode 100644 index 32f13ca..0000000 --- a/languages/bfpl/sample.term +++ /dev/null @@ -1 +0,0 @@ -[ ((factorial,[inttype],inttype),factorial,[x],if(op(eq,name(x),intconst(0)),intconst(1),op(mult,name(x),apply(factorial,[op(sub,name(x),intconst(1))]))))],apply(factorial,[intconst(5)]). \ No newline at end of file diff --git a/languages/bfpl/sample.value b/languages/bfpl/sample.value deleted file mode 100644 index edc23f0..0000000 --- a/languages/bfpl/sample.value +++ /dev/null @@ -1,2 +0,0 @@ -intval(120). - diff --git a/languages/bfpl/small-step/.ueber b/languages/bfpl/small-step/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/bfpl/small-step/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/bfpl/small-step/normal.pro b/languages/bfpl/small-step/normal.pro deleted file mode 100644 index 9fdf295..0000000 --- a/languages/bfpl/small-step/normal.pro +++ /dev/null @@ -1,2 +0,0 @@ -normal(intconst(_)). -normal(boolconst(_)). diff --git a/languages/bfpl/small-step/op.pro b/languages/bfpl/small-step/op.pro deleted file mode 100644 index 4b7b5bb..0000000 --- a/languages/bfpl/small-step/op.pro +++ /dev/null @@ -1,11 +0,0 @@ -opConst(add, intconst(X1), intconst(X2), intconst(X0)) :- - X0 is X1 + X2. - -opConst(sub, intconst(X1), intconst(X2), intconst(X0)) :- - X0 is X1 - X2. - -opConst(mult, intconst(X1), intconst(X2), intconst(X0)) :- - X0 is X1 * X2. - -opConst(eq, intconst(X1), intconst(X2), boolconst(X0)) :- - toBoolean((X1==X2), X0). diff --git a/languages/bfpl/small-step/reduction.pro b/languages/bfpl/small-step/reduction.pro deleted file mode 100644 index b7318f9..0000000 --- a/languages/bfpl/small-step/reduction.pro +++ /dev/null @@ -1,12 +0,0 @@ -% Evaluate main expression of program -smallStep((Fs, E1), E2) :- - reduce(Fs, E1, E2). - -% Reflexive case -reduce(_, E, E) :- - normal(E). - -% Transitive case -reduce(Fs, E1, E3) :- - step(Fs, E1, E2), - reduce(Fs, E2, E3). diff --git a/languages/bfpl/small-step/step.pro b/languages/bfpl/small-step/step.pro deleted file mode 100644 index 2974bdb..0000000 --- a/languages/bfpl/small-step/step.pro +++ /dev/null @@ -1,38 +0,0 @@ -% Simplify condition -step(P, if(E1a, E2, E3), if(E1b, E2, E3)) :- - step(P, E1a, E1b). - -% Commit to then branch -step(_, if(boolconst(true), E, _), E). - -% Commit to else branch -step(_, if(boolconst(false), _, E), E). - -% Simplify left operand -step(P, op(O, E1a, E2), op(O, E1b, E2)) :- - step(P, E1a, E1b). - -% Simplify right operand -step(P, op(O, E1, E2a), op(O, E1, E2b)) :- - normal(E1), - step(P, E2a, E2b). - -% Apply operator -step(_, op(O, E1, E2), E0) :- - normal(E1), - normal(E2), - opConst(O, E1, E2, E0). - -% Simplify operand of function application -step(P, apply(F, Es1), apply(F, Es4)) :- - append(Es2, [E1|Es3], Es1), - map(normal, Es2), - step(P, E1, E2), - append(Es2, [E2|Es3], Es4). - -% Apply function -step(P, apply(N, Es), E2) :- - map(normal, Es), - member((_, (N, Ns, E1)), P), - zip(Ns, Es, L), - star(substitute, L, E1, E2). diff --git a/languages/bfpl/small-step/substitution.pro b/languages/bfpl/small-step/substitution.pro deleted file mode 100644 index 5e57004..0000000 --- a/languages/bfpl/small-step/substitution.pro +++ /dev/null @@ -1,14 +0,0 @@ -% Substitution -substitute(_, intconst(I), intconst(I)). -substitute(_, boolconst(B), boolconst(B)). -substitute((N,E), name(N), E). -substitute((N1,_), name(N2), name(N2)) :- N1 \= N2. -substitute(S, if(E1a, E2a, E3a), if(E1b, E2b, E3b)) :- - substitute(S, E1a, E1b), - substitute(S, E2a, E2b), - substitute(S, E3a, E3b). -substitute(S, op(O, Left1, Right1), op(O, Left2, Right2)) :- - substitute(S, Left1, Left2), - substitute(S, Right1, Right2). -substitute(S, apply(F, Es1), apply(F, Es2)) :- - map(substitute(S), Es1, Es2). diff --git a/languages/bfpl/wellness/.ueber b/languages/bfpl/wellness/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/bfpl/wellness/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/bfpl/wellness/expr.pro b/languages/bfpl/wellness/expr.pro deleted file mode 100644 index 80ee15b..0000000 --- a/languages/bfpl/wellness/expr.pro +++ /dev/null @@ -1,23 +0,0 @@ -% An int constant is of the int type -okExpr(_, _, intconst(_), inttype). - -% The context provides the type of a variable -okExpr(_, X, name(N), T) :- - member((N, T), X). - -% Condition is of boolean type; others are of the same type -okExpr(P, X, if(E1, E2, E3), T) :- - okExpr(P, X, E1, booltype), - okExpr(P, X, E2, T), - okExpr(P, X, E3, T). - -% Check operator application -okExpr(P, X, op(O, E1, E2), T0) :- - okExpr(P, X, E1, T1), - okExpr(P, X, E2, T2), - okOp(O, T1, T2, T0). - -% Check function application -okExpr(P, X, apply(F, Es), T) :- - map(okExpr(P, X), Es, Ts), - member(((F, Ts, T), _), P). diff --git a/languages/bfpl/wellness/fun.pro b/languages/bfpl/wellness/fun.pro deleted file mode 100644 index 4020f86..0000000 --- a/languages/bfpl/wellness/fun.pro +++ /dev/null @@ -1,6 +0,0 @@ -% Wellness of function declarations -okFun(P, ((N, Ts, T), (N, Ns, E))) :- - set(Ns), - zip(Ns, Ts, X), - okExpr(P, X, E, T). - diff --git a/languages/bfpl/wellness/op.pro b/languages/bfpl/wellness/op.pro deleted file mode 100644 index 1cf0016..0000000 --- a/languages/bfpl/wellness/op.pro +++ /dev/null @@ -1,5 +0,0 @@ -% Operand types of operators -okOp(add, inttype, inttype, inttype). -okOp(sub, inttype, inttype, inttype). -okOp(mult, inttype, inttype, inttype). -okOp(eq, inttype, inttype, booltype). diff --git a/languages/bfpl/wellness/prog.pro b/languages/bfpl/wellness/prog.pro deleted file mode 100644 index fb55d69..0000000 --- a/languages/bfpl/wellness/prog.pro +++ /dev/null @@ -1,8 +0,0 @@ -% Wellness of collection of function declarations -okProg((Fs, E)) :- - map(toFunName, Fs, Ns), - set(Ns), - map(okFun(Fs), Fs), - okExpr(Fs, [], E, _). - -toFunName(((N, _, _), _), N). diff --git a/languages/bgl/.ueber b/languages/bgl/.ueber deleted file mode 100644 index 5d0fc40..0000000 --- a/languages/bgl/.ueber +++ /dev/null @@ -1,7 +0,0 @@ -[ - language(bgl(text)), - membership(bgl(text), elementOfBgl, []), - function(parser, [bgl(text)], [bgl(term)], parserOfBgl, []), - function(projection, [bgl(term)], [bsl(term)], bglToBsl, []) -]. - diff --git a/languages/bgl/accept-bu.pro b/languages/bgl/accept-bu.pro deleted file mode 100644 index 645e878..0000000 --- a/languages/bgl/accept-bu.pro +++ /dev/null @@ -1,23 +0,0 @@ -% Accept input bottom-up -acceptBottomUp(Rules, Input) :- - Rules = [(_, Root, _)|_], - acceptBottomUp(Rules, Root, [], Input). - -% Acceptance completed -acceptBottomUp(_, Root, [n(Root)], []). - -% Shift terminal from input to stack -acceptBottomUp(Rules, Root, Stack0, [T|Input0]) :- - append(Stack0, [t(T)], Stack1), - acceptBottomUp(Rules, Root, Stack1, Input0). - -% Reduce prefix on stack to nonterminal -acceptBottomUp(Rules, Root, Stack0, Input0) :- - % Remove a prefix from the stack - append(Stack1, Rhs, Stack0), - % Find the prefix as the RHS of a rule - member((_, N, Rhs), Rules), - % Add LHS nonterminal to the stack - append(Stack1, [n(N)], Stack2), - % Proceed recursively - acceptBottomUp(Rules, Root, Stack2, Input0). diff --git a/languages/bgl/accept-td.pro b/languages/bgl/accept-td.pro deleted file mode 100644 index fd94849..0000000 --- a/languages/bgl/accept-td.pro +++ /dev/null @@ -1,20 +0,0 @@ -% Accept input top-down -acceptTopDown(Rules, Input) :- - Rules = [(_, Root, _)|_], - acceptTopDown(Rules, [n(Root)], Input). - -% Acceptance completed -acceptTopDown(_, [], []). - -% Consume terminal at top of stack from input -acceptTopDown(Rules, [t(T)|Stack], [T|Input]) :- - acceptTopDown(Rules, Stack, Input). - -% Expand nonterminal at the top of stack -acceptTopDown(Rules, [n(N)|Stack0], Input) :- - % Select an alternative with LHS N - member((_, N, Rhs), Rules), - % Add RHS to the stack - append(Rhs, Stack0, Stack1), - % Proceed recursively - acceptTopDown(Rules, Stack1, Input). diff --git a/languages/bgl/api.pro b/languages/bgl/api.pro deleted file mode 100644 index 11ffb65..0000000 --- a/languages/bgl/api.pro +++ /dev/null @@ -1,68 +0,0 @@ -% BGL-based top-down acceptor for token sequences -bglTopDownAcceptor(File, Input) - :- - readTermFile(File, Grammar), - once(acceptTopDown(Grammar, Input)). - -% BGL-based top-down acceptor with scanner -bglTopDownAcceptor(Pred, File, Input1) - :- - apply(Pred, [Input1, Input2]), - bglTopDownAcceptor(File, Input2). - -% BGL-based bottom-up acceptor for token sequences -bglBottomUpAcceptor(File, Input) - :- - readTermFile(File, Grammar), - once(acceptBottomUp(Grammar, Input)). - -% BGL-based bottom-up acceptor with scanner -bglBottomUpAcceptor(Pred, File, Input1) - :- - apply(Pred, [Input1, Input2]), - bglBottomUpAcceptor(File, Input2). - -% BGL-based imploder for parse trees -bglImploder(Input, Output) - :- - implode(Input, Output). - -% BGL-based exploder for parse trees -bglExploder(File, Input, Output) - :- - readTermFile(File, Grammar), - explode(Grammar, Input, Output). - -% BGL-based top-down parser for token sequences -bglTopDownParser(File, Text, Term) - :- - readTermFile(File, Grammar), - once(parseTopDown(Grammar, Text, PTree)), - implode(PTree, Term). - -% BGL-based top-down parser with scanner -bglTopDownParser(Pred, File, Text1, Term) - :- - apply(Pred, [Text1, Text2]), - bglTopDownParser(File, Text2, Term). - -% Parser of BGL grammars relying on EGL -parserOfBgl(Text, Term2) :- - require( - scannerFailed(egl), - tokens(eglToken, Text, Tokens)), - File = 'languages/egl/cs.term', - require( - fileNotReadable(File), - readTermFile(File, Egl)), - require( - parserFailed(egl), - scannerfull(fail, Egl, Tokens, Term1)), - require( - bglSubset, - eglToBgl(Term1, Term2) - ). - -% Membership test for BGL by attempted parsing -elementOfBgl(Text) :- - parserOfBgl(Text, _). diff --git a/languages/bgl/egl-to-bgl.pro b/languages/bgl/egl-to-bgl.pro deleted file mode 100644 index 7b20bd6..0000000 --- a/languages/bgl/egl-to-bgl.pro +++ /dev/null @@ -1,18 +0,0 @@ -/* -Map more complex EGL grammar notation to BGL -*/ - -eglToBgl(Rs1, Rs2) :- - map(eglToBglRule, Rs1, Rs2). - -eglToBglLhs((_, Lhs, _), Lhs). - -eglToBglRule( - ([Label], Lhs, Rhs1), - (Label, Lhs, Rhs2) -) :- - map(eglToBglSymbol, Rhs1, Rhs2). - -eglToBglSymbol(S, S) :- - S = t(_) - ; S = n(_). diff --git a/languages/bgl/egl/.ueber b/languages/bgl/egl/.ueber deleted file mode 100644 index e8c7a4b..0000000 --- a/languages/bgl/egl/.ueber +++ /dev/null @@ -1,4 +0,0 @@ -[ - macro(eglSyntax(bgl)) -]. - diff --git a/languages/bgl/egl/README.md b/languages/bgl/egl/README.md deleted file mode 100644 index 0eb32b0..0000000 --- a/languages/bgl/egl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -A redundant EGL-based syntax of BGL. -It is redundant because the more general EGL parser is actually used. -See egl-to-bgl.pro for the restriction of EGL to BGL. diff --git a/languages/bgl/egl/cs-to-as.pro b/languages/bgl/egl/cs-to-as.pro deleted file mode 100644 index 37d147c..0000000 --- a/languages/bgl/egl/cs-to-as.pro +++ /dev/null @@ -1,5 +0,0 @@ -bglMapping(qstring, (_, String, _), Atom) :- - atom_codes(Atom, String). - -bglMapping(name, String, Atom) :- - name(Atom, String). diff --git a/languages/bgl/egl/cs.egl b/languages/bgl/egl/cs.egl deleted file mode 100644 index a6e3508..0000000 --- a/languages/bgl/egl/cs.egl +++ /dev/null @@ -1,7 +0,0 @@ -grammar : {rule}* ; -rule : '[' label ']' nonterminal ':' {gsymbol}* ';' ; -[t] gsymbol : terminal ; -[n] gsymbol : nonterminal ; -label : name ; -terminal : qstring ; -nonterminal : name ; diff --git a/languages/bgl/egl/cs.term b/languages/bgl/egl/cs.term deleted file mode 100644 index 0bad865..0000000 --- a/languages/bgl/egl/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],grammar,[star([n(rule)])]), ([],rule,[t('['),n(label),t(']'),n(nonterminal),t(:),star([n(gsymbol)]),t(;)]), ([t],gsymbol,[n(terminal)]), ([n],gsymbol,[n(nonterminal)]), ([],label,[n(name)]), ([],terminal,[n(qstring)]), ([],nonterminal,[n(name)])]. \ No newline at end of file diff --git a/languages/bgl/egl/ls.egl b/languages/bgl/egl/ls.egl deleted file mode 100644 index f94662b..0000000 --- a/languages/bgl/egl/ls.egl +++ /dev/null @@ -1,3 +0,0 @@ -qstring : quote { noQuote }+ quote ; -name : { alpha }+ ; -layout : { space }+ ; diff --git a/languages/bgl/egl/ls.term b/languages/bgl/egl/ls.term deleted file mode 100644 index cf4b191..0000000 --- a/languages/bgl/egl/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],qstring,[n(quote),plus([n(noQuote)]),n(quote)]), ([],name,[plus([n(alpha)])]), ([],layout,[plus([n(space)])])]. \ No newline at end of file diff --git a/languages/bgl/esl/.ueber b/languages/bgl/esl/.ueber deleted file mode 100644 index b73f589..0000000 --- a/languages/bgl/esl/.ueber +++ /dev/null @@ -1,4 +0,0 @@ -[ - macro(eslSyntax(bgl)) -]. - diff --git a/languages/bgl/esl/README.md b/languages/bgl/esl/README.md deleted file mode 100644 index 9634ae0..0000000 --- a/languages/bgl/esl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -A redundant ESL-based syntax of BGL. -It is redundant because the more general signature of EGL could be used. -See egl-to-bgl.pro for the restriction of EGL to BGL. diff --git a/languages/bgl/esl/as.esl b/languages/bgl/esl/as.esl deleted file mode 100644 index 3e53241..0000000 --- a/languages/bgl/esl/as.esl +++ /dev/null @@ -1,7 +0,0 @@ -type grammar = rule* ; -type rule = (label, nonterminal, symbol*) ; -symbol t : terminal -> symbol ; -symbol n : nonterminal -> symbol ; -type nonterminal = atom ; -type terminal = atom ; -type label = atom ; diff --git a/languages/bgl/esl/as.term b/languages/bgl/esl/as.term deleted file mode 100644 index 45cf9ec..0000000 --- a/languages/bgl/esl/as.term +++ /dev/null @@ -1 +0,0 @@ -[type(grammar,star(sort(rule))),type(rule,tuple([sort(label),sort(nonterminal),star(sort(symbol))])),symbol(t,[sort(terminal)],symbol),symbol(n,[sort(nonterminal)],symbol),type(nonterminal,atom),type(terminal,atom),type(label,atom)]. \ No newline at end of file diff --git a/languages/bgl/explode.pro b/languages/bgl/explode.pro deleted file mode 100644 index 2ae8a5f..0000000 --- a/languages/bgl/explode.pro +++ /dev/null @@ -1,33 +0,0 @@ -% Explosion -explode( - Rules, % Rules to consult for details - ITree, % Imploded (concise) parse tree - ETree % Exploded (detailed) parse tree - ) :- - Rules = [(_, Root, _)|_], - explode(Rules, [n(Root)], [ITree], [ETree]). - -% Base case; explosion completed -explode(_, [], [], []). - -% Add heading terminal from rule back into exploded form -explode( - Rules, - [t(T)|Symbols], - ITrees, - [leaf(T)|ETrees] - ) :- - explode(Rules, Symbols, ITrees, ETrees). - -% Find a rule for the function symbol at hand -explode( - Rules, - [n(N)|Symbols], - [ITree|ITrees1], - [fork(Rule, ETrees1)|ETrees2] - ) :- - ITree =.. [L|ITrees2], - Rule = (L, N, Rhs), - member(Rule, Rules), - explode(Rules, Rhs, ITrees2, ETrees1), - explode(Rules, Symbols, ITrees1, ETrees2). diff --git a/languages/bgl/implode.pro b/languages/bgl/implode.pro deleted file mode 100644 index 32e2075..0000000 --- a/languages/bgl/implode.pro +++ /dev/null @@ -1,25 +0,0 @@ -% Implosion -implode( - ETree, % Exploded (detailed) parse tree - ITree % Imploded (concise) parse tree - ) :- - implode_([ETree], [ITree]). - -% Base case; implosion completed -implode_([], []). - -% Omit terminal from exploded tree in imploded one -implode_( - [leaf(_)|ETrees], % terminal tree in front - ITrees % recursively imploded trees - ) :- - implode_(ETrees, ITrees). - -% Implode subtree recursively -implode_( - [fork((L, _, _), ETrees1)|ETrees2], % nonterminal tree in front - [ITree|ITrees2] % binarily recursively imploded trees - ) :- - implode_(ETrees1, ITrees1), - ITree =.. [L|ITrees1], % leverage label as function symbol - implode_(ETrees2, ITrees2). diff --git a/languages/bgl/parse-td.pro b/languages/bgl/parse-td.pro deleted file mode 100644 index 6388409..0000000 --- a/languages/bgl/parse-td.pro +++ /dev/null @@ -1,21 +0,0 @@ -% Parse input top-down -parseTopDown(Rules, Input, Tree) :- - Rules = [(_, Root, _)|_], - parseTopDown(Rules, n(Root), Tree, Input, []). - -% Consume terminal at top of stack from input -parseTopDown(_, t(T), leaf(T), [T|Input], Input). - -% Expand nonterminal at the top of stack -parseTopDown(Rules, n(N), fork(Rule, Trees), Input0, Input1) :- - member(Rule, Rules), - Rule = (_, N, Rhs), - parseTopDown(Rules, Rhs, Trees, Input0, Input1). - -% Parsing completed -parseTopDown(_, [], [], Input, Input). - -% Parse symbol by symbol -parseTopDown(Rules, [Symbol|Symbols], [Tree|Trees], Input0, Input2) :- - parseTopDown(Rules, Symbol, Tree, Input0, Input1), - parseTopDown(Rules, Symbols, Trees, Input1, Input2). diff --git a/languages/bgl/unparse.pro b/languages/bgl/unparse.pro deleted file mode 100644 index 24bdee1..0000000 --- a/languages/bgl/unparse.pro +++ /dev/null @@ -1,22 +0,0 @@ -% Unparse parse tree to string -bglTreeToText(Tree, Text) :- - bglTreeToTokens(Tree, Tokens), - atomic_list_concat(Tokens, Atom), - name(Atom, Text). - -% Unparse parse tree to token sequence -bglTreeToTokens(Tree, Tokens) :- - unparse([Tree], Tokens). - -% Base case -unparse([], []). - -% Copy leaf terminal to output string and recurse -unparse([leaf(T)|Trees], [T|Tokens]) :- - unparse(Trees, Tokens). - -% Unparse sub-trees of fork tree and remaining trees -unparse([fork(_, Trees1)|Trees2], Tokens3) :- - unparse(Trees1, Tokens1), - unparse(Trees2, Tokens2), - append(Tokens1, Tokens2, Tokens3). diff --git a/languages/bnl/.ueber b/languages/bnl/.ueber deleted file mode 100644 index b60d598..0000000 --- a/languages/bnl/.ueber +++ /dev/null @@ -1,19 +0,0 @@ -[ - - macro(bglSyntax(bnl)), % Concrete syntax -% macro(bslSyntax(bnl)), % Abstract syntax - macro(bglSample(bnl)), % Sample - - % Results of BNL evaluation - elementOf('sample.formula', term), - elementOf('sample.value', term), - - % DCG-based evaluators - mapsTo(csConvert_, ['sample.tokens'], ['sample.value']), - mapsTo(csConvert__, ['sample.tokens'], ['sample.formula']), - - % AST-based evaluators - mapsTo(asConvert_, ['sample.term'], ['sample.value']), - mapsTo(asConvert__, ['sample.term'], ['sample.formula']) - -]. diff --git a/languages/bnl/README.md b/languages/bnl/README.md deleted file mode 100644 index 0b4ce7d..0000000 --- a/languages/bnl/README.md +++ /dev/null @@ -1,27 +0,0 @@ -## Binary number conversion according to Knuth - -* cs.bgl: Context-free grammar of binary numbers in BGL notation -* cs.dcg: Definite clause grammar of binary numbers -* conversion*.dcg: DCG-encoded attribute grammar for conversion. -* conversion*.pro: AST-based encoding for conversion. -* main.pro: some tests - -## DCG encoding of the attribute grammar - -### Use of CLP(R) - -conversion1.dcg version uses CLP(R) for the semantic rules on number types. -Semantic rules are essentially enclosed in double braces. -The outer level of braces is for semantic rules within a DCG. -The inner level of braces is for constraints according to CLP(R). - -### Use of a (trivial) solver - -conversion1.dcg simply synthesizes an expression. -The expression is ground, in the end. -Thus, a solver is trivial; it computes the expression. - -## Further reading - -* http://en.wikipedia.org/wiki/Attribute_grammar -* https://github.com/slecourse/slecourse/tree/master/sources/attributeGrammars/knuth diff --git a/languages/bnl/as.bsl b/languages/bnl/as.bsl deleted file mode 100644 index 9cafb82..0000000 --- a/languages/bnl/as.bsl +++ /dev/null @@ -1,7 +0,0 @@ -symbol number: bits x rest -> number ; -symbol single: bit -> bits ; -symbol many: bit x bits -> bits ; -symbol zero: -> bit ; -symbol one: -> bit ; -symbol integer : -> rest ; -symbol rational : bits -> rest ; diff --git a/languages/bnl/as.term b/languages/bnl/as.term deleted file mode 100644 index a99e62b..0000000 --- a/languages/bnl/as.term +++ /dev/null @@ -1,9 +0,0 @@ -[ - (number,[bits,rest],number), - (single,[bit],bits), - (many,[bit,bits],bits), - (zero,[],bit), - (one,[],bit), - (integer,[],rest), - (rational,[bits],rest) -]. diff --git a/languages/bnl/conversion1.dcg b/languages/bnl/conversion1.dcg deleted file mode 100644 index 602e634..0000000 --- a/languages/bnl/conversion1.dcg +++ /dev/null @@ -1,37 +0,0 @@ -:- use_module(library(clpr)). - -csConvert_(X, Val) :- - number_(Val, X, []). - -number_(Val0) --> - bits_(Pos1, Len1, Val1), - rest_(Val2), - { { Pos1 =:= Len1 - 1 } }, - { { Val0 =:= Val1 + Val2 } }. - -bits_(Pos, Len, Val) --> - bit_(Pos, Val), - { { Len =:= 1 } }. - -bits_(Pos0, Len0, Val0) --> - bit_(Pos0, Val1), - bits_(Pos1, Len1, Val2), - { { Pos1 =:= Pos0 - 1 } }, - { { Len0 =:= Len1 + 1 } }, - { { Val0 =:= Val1 + Val2 } }. - -bit_(_Pos, Val) --> - ['0'], - { { Val =:= 0 } }. - -bit_(Pos, Val) --> - ['1'], - { { Val =:= 2 ^ Pos } }. - -rest_(Val) --> - { { Val =:= 0 } }. - -rest_(Val) --> - ['.'], - bits_(Pos, _Len, Val), - { { Pos =:= -1 } }. diff --git a/languages/bnl/conversion1.pro b/languages/bnl/conversion1.pro deleted file mode 100644 index 268b80a..0000000 --- a/languages/bnl/conversion1.pro +++ /dev/null @@ -1,31 +0,0 @@ -:- use_module(library(clpr)). - -asConvert_(number(Bits, Rest), Val0) :- - convertBits_(Bits, Pos1, Len1, Val1), - convertRest_(Rest, Val2), - { Pos1 =:= Len1 - 1 }, - { Val0 =:= Val1 + Val2 }. - -convertBits_(single(Bit), Pos, Len, Val) :- - convertBit_(Bit, Pos, Val), - { Len =:= 1 }. - -convertBits_(many(Bit, Bits), Pos0, Len0, Val0) :- - convertBit_(Bit, Pos0, Val1), - convertBits_(Bits, Pos1, Len1, Val2), - { Pos1 =:= Pos0 - 1 }, - { Len0 =:= Len1 + 1 }, - { Val0 =:= Val1 + Val2 }. - -convertBit_(zero, _Pos, Val) :- - { Val =:= 0 }. - -convertBit_(one, Pos, Val) :- - { Val =:= 2 ^ Pos }. - -convertRest_(integer, Val) :- - { Val =:= 0 }. - -convertRest_(rational(Bits), Val) :- - convertBits_(Bits, Pos, _Len, Val), - { Pos =:= -1 }. diff --git a/languages/bnl/conversion2.dcg b/languages/bnl/conversion2.dcg deleted file mode 100644 index 5f7f2c8..0000000 --- a/languages/bnl/conversion2.dcg +++ /dev/null @@ -1,33 +0,0 @@ -csConvert__(X, Term) :- - number__(Term, X, []). - -number__(Val1+Val2) - --> - bits__(Len1-1, Len1, Val1), - rest__(Val2). - -bits__(Pos, 1, Val) - --> - bit__(Pos, Val). - -bits__(Pos0, Len1+1, Val1+Val2) - --> - bit__(Pos0, Val1), - bits__(Pos0-1, Len1, Val2). - -bit__(_Pos, 0) - --> - ['0']. - -bit__(Pos, 2^Pos) - --> - ['1']. - -rest__(0) - --> - []. - -rest__(Val) - --> - ['.'], - bits__(-1, _Len, Val). diff --git a/languages/bnl/conversion2.pro b/languages/bnl/conversion2.pro deleted file mode 100644 index 6186340..0000000 --- a/languages/bnl/conversion2.pro +++ /dev/null @@ -1,19 +0,0 @@ -asConvert__(number(Bits, Rest), Val1+Val2) :- - convertBits__(Bits, Len1-1, Len1, Val1), - convertRest__(Rest, Val2). - -convertBits__(single(Bit), Pos, 1, Val) :- - convertBit__(Bit, Pos, Val). - -convertBits__(many(Bit, Bits), Pos0, Len1+1, Val1+Val2) :- - convertBit__(Bit, Pos0, Val1), - convertBits__(Bits, Pos0-1, Len1, Val2). - -convertBit__(zero, _Pos, 0). - -convertBit__(one, Pos, 2^Pos). - -convertRest__(integer, 0). - -convertRest__(rational(Bits), Val) :- - convertBits__(Bits, -1, _Len, Val). diff --git a/languages/bnl/cs.bgl b/languages/bnl/cs.bgl deleted file mode 100644 index a5de079..0000000 --- a/languages/bnl/cs.bgl +++ /dev/null @@ -1,7 +0,0 @@ -[number] number : bits rest ; -[single] bits : bit ; -[many] bits : bit bits ; -[zero] bit : '0' ; -[one] bit : '1' ; -[integer] rest : ; -[rational] rest : '.' bits ; diff --git a/languages/bnl/cs.dcg b/languages/bnl/cs.dcg deleted file mode 100644 index 3b55c4b..0000000 --- a/languages/bnl/cs.dcg +++ /dev/null @@ -1,7 +0,0 @@ -number --> bits, rest. -bits --> bit. -bits --> bit, bits. -bit --> ['0']. -bit --> ['1']. -rest --> []. -rest --> ['.'], bits. diff --git a/languages/bnl/cs.term b/languages/bnl/cs.term deleted file mode 100644 index 1adf234..0000000 --- a/languages/bnl/cs.term +++ /dev/null @@ -1,9 +0,0 @@ -[ - (number, number, [n(bits), n(rest)]), - (single, bits, [n(bit)]), - (many, bits, [n(bit), n(bits)]), - (zero, bit, [t('0')]), - (one, bit, [t('1')]), - (integer, rest, []), - (rational, rest, [t('.'), n(bits)]) -]. diff --git a/languages/bnl/egl/.ueber b/languages/bnl/egl/.ueber deleted file mode 100644 index 30f6038..0000000 --- a/languages/bnl/egl/.ueber +++ /dev/null @@ -1,5 +0,0 @@ -[ - - macro(eglSyntax(yabnl)) - -]. diff --git a/languages/bnl/egl/cs.egl b/languages/bnl/egl/cs.egl deleted file mode 100644 index 3acb2ec..0000000 --- a/languages/bnl/egl/cs.egl +++ /dev/null @@ -1,3 +0,0 @@ -[number] number : { bit }+ { '.' { bit }+ }? ; -[zero] bit : '0' ; -[one] bit : '1' ; diff --git a/languages/bnl/egl/cs.term b/languages/bnl/egl/cs.term deleted file mode 100644 index e3d0277..0000000 --- a/languages/bnl/egl/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([number],number,[plus([n(bit)]),option([t('.'),plus([n(bit)])])]), ([zero],bit,[t('0')]), ([one],bit,[t('1')])]. \ No newline at end of file diff --git a/languages/bnl/egl/ls.egl b/languages/bnl/egl/ls.egl deleted file mode 100644 index e69de29..0000000 diff --git a/languages/bnl/egl/ls.term b/languages/bnl/egl/ls.term deleted file mode 100644 index 2600237..0000000 --- a/languages/bnl/egl/ls.term +++ /dev/null @@ -1 +0,0 @@ -[]. \ No newline at end of file diff --git a/languages/bnl/esl/.ueber b/languages/bnl/esl/.ueber deleted file mode 100644 index 85845c3..0000000 --- a/languages/bnl/esl/.ueber +++ /dev/null @@ -1,5 +0,0 @@ -[ - - macro(eslSyntax(yabnl)) - -]. diff --git a/languages/bnl/esl/as.esl b/languages/bnl/esl/as.esl deleted file mode 100644 index 1dc78e6..0000000 --- a/languages/bnl/esl/as.esl +++ /dev/null @@ -1,3 +0,0 @@ -type number = (bit+, bit*) ; -symbol zero: -> bit ; -symbol one: -> bit ; diff --git a/languages/bnl/esl/as.term b/languages/bnl/esl/as.term deleted file mode 100644 index e8ca06b..0000000 --- a/languages/bnl/esl/as.term +++ /dev/null @@ -1 +0,0 @@ -[type(number,tuple([plus(sort(bit)),star(sort(bit))])),symbol(zero,[],bit),symbol(one,[],bit)]. \ No newline at end of file diff --git a/languages/bnl/esl/haskell/as.hs b/languages/bnl/esl/haskell/as.hs deleted file mode 100644 index 350e307..0000000 --- a/languages/bnl/esl/haskell/as.hs +++ /dev/null @@ -1,3 +0,0 @@ -data Number = Number Bits Bits -type Bits = [Bit] -data Bit = Zero | One diff --git a/languages/bnl/esl/java/.gitignore b/languages/bnl/esl/java/.gitignore deleted file mode 100644 index ab31b20..0000000 --- a/languages/bnl/esl/java/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.class - diff --git a/languages/bnl/esl/java/Bit.java b/languages/bnl/esl/java/Bit.java deleted file mode 100644 index b573937..0000000 --- a/languages/bnl/esl/java/Bit.java +++ /dev/null @@ -1 +0,0 @@ -public enum Bit { Zero, One } diff --git a/languages/bnl/esl/java/Number.java b/languages/bnl/esl/java/Number.java deleted file mode 100644 index 7cb1452..0000000 --- a/languages/bnl/esl/java/Number.java +++ /dev/null @@ -1,6 +0,0 @@ -import java.util.List; - -public class Number { - public List bits; - public List rest; -} diff --git a/languages/bnl/haskell/as.hs b/languages/bnl/haskell/as.hs deleted file mode 100644 index 871da8a..0000000 --- a/languages/bnl/haskell/as.hs +++ /dev/null @@ -1,4 +0,0 @@ -data Number = Number Bits Rest -data Bits = Single Bit | Many Bit Bits -data Bit = Zero | One -data Rest = Integer | Rational Bits \ No newline at end of file diff --git a/languages/bnl/java/.gitignore b/languages/bnl/java/.gitignore deleted file mode 100644 index ab31b20..0000000 --- a/languages/bnl/java/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.class - diff --git a/languages/bnl/java/Bit.java b/languages/bnl/java/Bit.java deleted file mode 100644 index 64b95d7..0000000 --- a/languages/bnl/java/Bit.java +++ /dev/null @@ -1 +0,0 @@ -public abstract class Bit { } \ No newline at end of file diff --git a/languages/bnl/java/Bits.java b/languages/bnl/java/Bits.java deleted file mode 100644 index d95b864..0000000 --- a/languages/bnl/java/Bits.java +++ /dev/null @@ -1 +0,0 @@ -public abstract class Bits { } \ No newline at end of file diff --git a/languages/bnl/java/Integer.java b/languages/bnl/java/Integer.java deleted file mode 100644 index 28853dd..0000000 --- a/languages/bnl/java/Integer.java +++ /dev/null @@ -1 +0,0 @@ -public class Integer extends Rest { } diff --git a/languages/bnl/java/Many.java b/languages/bnl/java/Many.java deleted file mode 100644 index 01f165e..0000000 --- a/languages/bnl/java/Many.java +++ /dev/null @@ -1,4 +0,0 @@ -public class Many extends Bits { - public Bit bit; - public Bits bits; -} diff --git a/languages/bnl/java/Number.java b/languages/bnl/java/Number.java deleted file mode 100644 index 01b3909..0000000 --- a/languages/bnl/java/Number.java +++ /dev/null @@ -1,4 +0,0 @@ -public class Number { - public Bits bits; - public Rest rest; -} diff --git a/languages/bnl/java/One.java b/languages/bnl/java/One.java deleted file mode 100644 index 874655b..0000000 --- a/languages/bnl/java/One.java +++ /dev/null @@ -1 +0,0 @@ -public class One extends Bit { } diff --git a/languages/bnl/java/Rational.java b/languages/bnl/java/Rational.java deleted file mode 100644 index bbd51e5..0000000 --- a/languages/bnl/java/Rational.java +++ /dev/null @@ -1,3 +0,0 @@ -public class Rational extends Rest { - Bits bits -} diff --git a/languages/bnl/java/Rest.java b/languages/bnl/java/Rest.java deleted file mode 100644 index 35a41fc..0000000 --- a/languages/bnl/java/Rest.java +++ /dev/null @@ -1 +0,0 @@ -public abstract class Rest { } diff --git a/languages/bnl/java/Single.java b/languages/bnl/java/Single.java deleted file mode 100644 index 2a45664..0000000 --- a/languages/bnl/java/Single.java +++ /dev/null @@ -1,3 +0,0 @@ -public class Single extends Bits { - public Bit bit; -} diff --git a/languages/bnl/java/Zero.java b/languages/bnl/java/Zero.java deleted file mode 100644 index 4a64910..0000000 --- a/languages/bnl/java/Zero.java +++ /dev/null @@ -1 +0,0 @@ -public class Zero extends Bit { } diff --git a/languages/bnl/sample.bnl b/languages/bnl/sample.bnl deleted file mode 100644 index db5b7d1..0000000 --- a/languages/bnl/sample.bnl +++ /dev/null @@ -1 +0,0 @@ -101.01 diff --git a/languages/bnl/sample.formula b/languages/bnl/sample.formula deleted file mode 100644 index 7136527..0000000 --- a/languages/bnl/sample.formula +++ /dev/null @@ -1 +0,0 @@ -2^ (1+1+1-1)+ (0+2^ (1+1+1-1-1-1))+ (0+2^ (-1-1)). diff --git a/languages/bnl/sample.ptree b/languages/bnl/sample.ptree deleted file mode 100644 index 25b6e47..0000000 --- a/languages/bnl/sample.ptree +++ /dev/null @@ -1 +0,0 @@ -fork((number,number,[n(bits),n(rest)]),[fork((many,bits,[n(bit),n(bits)]),[fork((one,bit,[t('1')]),[leaf('1')]),fork((many,bits,[n(bit),n(bits)]),[fork((zero,bit,[t('0')]),[leaf('0')]),fork((single,bits,[n(bit)]),[fork((one,bit,[t('1')]),[leaf('1')])])])]),fork((rational,rest,[t('.'),n(bits)]),[leaf('.'),fork((many,bits,[n(bit),n(bits)]),[fork((zero,bit,[t('0')]),[leaf('0')]),fork((single,bits,[n(bit)]),[fork((one,bit,[t('1')]),[leaf('1')])])])])]). \ No newline at end of file diff --git a/languages/bnl/sample.term b/languages/bnl/sample.term deleted file mode 100644 index 59122b2..0000000 --- a/languages/bnl/sample.term +++ /dev/null @@ -1,12 +0,0 @@ -number( - many( - one, - many( - zero, - single( - one))), - rational( - many( - zero, - single( - one)))). \ No newline at end of file diff --git a/languages/bnl/sample.tokens b/languages/bnl/sample.tokens deleted file mode 100644 index eeef2d1..0000000 --- a/languages/bnl/sample.tokens +++ /dev/null @@ -1,2 +0,0 @@ -% 101.01 as a token sequence -['1', '0', '1', '.', '0', '1']. diff --git a/languages/bnl/sample.value b/languages/bnl/sample.value deleted file mode 100644 index 86c9c3a..0000000 --- a/languages/bnl/sample.value +++ /dev/null @@ -1 +0,0 @@ -5.25. diff --git a/languages/bnl/scanner.pro b/languages/bnl/scanner.pro deleted file mode 100644 index 83ff815..0000000 --- a/languages/bnl/scanner.pro +++ /dev/null @@ -1,6 +0,0 @@ -% Turn string into list of singleton character atoms -bnlScanner(String1, L2) :- - ( append(String2, [10], String1) -> true; String2 = String1 ), - map(singleton, String2, L1), - map(flip(atom_codes), L1, L2). - diff --git a/languages/bnl/simpleSample/.ueber b/languages/bnl/simpleSample/.ueber deleted file mode 100644 index ad924ae..0000000 --- a/languages/bnl/simpleSample/.ueber +++ /dev/null @@ -1,5 +0,0 @@ -[ - - macro(bglSample(bnl)) - -]. diff --git a/languages/bnl/simpleSample/sample.bnl b/languages/bnl/simpleSample/sample.bnl deleted file mode 100644 index f599e28..0000000 --- a/languages/bnl/simpleSample/sample.bnl +++ /dev/null @@ -1 +0,0 @@ -10 diff --git a/languages/bnl/simpleSample/sample.ptree b/languages/bnl/simpleSample/sample.ptree deleted file mode 100644 index f7bfff7..0000000 --- a/languages/bnl/simpleSample/sample.ptree +++ /dev/null @@ -1 +0,0 @@ -fork((number,number,[n(bits),n(rest)]),[fork((many,bits,[n(bit),n(bits)]),[fork((one,bit,[t('1')]),[leaf('1')]),fork((single,bits,[n(bit)]),[fork((zero,bit,[t('0')]),[leaf('0')])])]),fork((integer,rest,[]),[])]). \ No newline at end of file diff --git a/languages/bnl/simpleSample/sample.term b/languages/bnl/simpleSample/sample.term deleted file mode 100644 index f88b184..0000000 --- a/languages/bnl/simpleSample/sample.term +++ /dev/null @@ -1,6 +0,0 @@ -number( - many( - one, - single( - zero)), - integer). \ No newline at end of file diff --git a/languages/bnl/simpleSample/sample.tokens b/languages/bnl/simpleSample/sample.tokens deleted file mode 100644 index a518bfe..0000000 --- a/languages/bnl/simpleSample/sample.tokens +++ /dev/null @@ -1 +0,0 @@ -['1','0']. \ No newline at end of file diff --git a/languages/bnl/solver.pro b/languages/bnl/solver.pro deleted file mode 100644 index fe72dd7..0000000 --- a/languages/bnl/solver.pro +++ /dev/null @@ -1,3 +0,0 @@ -% Compute an expression -solve(F, V) :- - V is F. diff --git a/languages/bsl/.ueber b/languages/bsl/.ueber deleted file mode 100644 index 90208ed..0000000 --- a/languages/bsl/.ueber +++ /dev/null @@ -1,15 +0,0 @@ -[ - language(bsl(text)), - language(bsl(term)), - language(tuple(term)), - language(prefix(term)), - membership(bsl(text), elementOfBsl, []), - membership(bsl(term), signature, []), - membership(tuple(term), tupleTerm, []), - membership(prefix(term), prefixTerm, []), - function(parser, [bsl(text)], [bsl(term)], parserOfBsl, []), - elementOf('sample.bsl', bsl(term)), - elementOf('sample.tupleTerm', tuple(term)), - elementOf('sample.prefixTerm', prefix(term)) -]. - diff --git a/languages/bsl/api.pro b/languages/bsl/api.pro deleted file mode 100644 index a4d3b5d..0000000 --- a/languages/bsl/api.pro +++ /dev/null @@ -1,30 +0,0 @@ -% Membership test -bslChecker(File, Term) :- - bslLanguage(File, Term). - -bslLanguage(File, Term) :- - readTermFile(File, Sig), - Sig = [(_, _, Sort)|_], - manySortedTerm(Sig, Term, Sort). - -% Parser of BSL signatures relying on ESL -parserOfBsl(Text, Term2) :- - FileCfSyn = 'languages/esl/cs.term', - require( - fileNotReadable(FileCfSyn), - readTermFile(FileCfSyn, CfSyn)), - FileLexSyn = 'languages/esl/ls.term', - require( - fileNotReadable(FileLexSyn), - readTermFile(FileLexSyn, LexSyn)), - require( - parserFailed(esl), - scannerless(layout, eslMapping, CfSyn, LexSyn, Text, Term1)), - require( - bglSubset, - eslToBsl(Term1, Term2) - ). - -% Membership test for BSL by attempted parsing -elementOfBsl(Text) :- - parserOfBsl(Text, _). diff --git a/languages/bsl/as.pro b/languages/bsl/as.pro deleted file mode 100644 index 490b002..0000000 --- a/languages/bsl/as.pro +++ /dev/null @@ -1,23 +0,0 @@ -% A signature consists of profiles (say, symbol types). -signature(Profiles) :- - profiles(Profiles). - -% Well-formedness of the list (set) of profiles -profiles(Profiles) :- - map(symbolOfProfile, Profiles, Symbols), - is_set(Symbols), - map(resultOfProfile, Profiles, ResultsList), - list_to_set(ResultsList, ResultsSet), - map(profile(ResultsSet), Profiles). - -% The symbol of a profile -symbolOfProfile((Symbol, _, _), Symbol). - -% The result sort of a profile -resultOfProfile((_, _, Result), Result). - -% A profile consists of a symbol, argument sorts, and a result sort. -profile(Sorts, (Symbol, Arguments, _)) :- - atom(Symbol), - % An argument sort is also "defined" by some symbol. - map(flip(member, Sorts), Arguments). diff --git a/languages/bsl/bgl-to-bsl.pro b/languages/bsl/bgl-to-bsl.pro deleted file mode 100644 index 31f8317..0000000 --- a/languages/bsl/bgl-to-bsl.pro +++ /dev/null @@ -1,18 +0,0 @@ -% Convert a grammar to a signature -bglToBsl(Rules, Profiles) :- - map(rule2profile, Rules, Profiles). - -% Convert a rule to a profile -rule2profile((LabelOrFun, LhsOrRes, Rhs), (LabelOrFun, Args, LhsOrRes)) :- - rhs2args(Rhs, Args). - -% Base case -rhs2args([], []). - -% Terminals are not represented by the signature -rhs2args([t(_)|Rhs], Args) :- - rhs2args(Rhs, Args). - -% Nonterminals are mapped to sorts -rhs2args([n(Sort)|Rhs], [Sort|Args]) :- - rhs2args(Rhs, Args). diff --git a/languages/bsl/conformance.pro b/languages/bsl/conformance.pro deleted file mode 100644 index 47222b3..0000000 --- a/languages/bsl/conformance.pro +++ /dev/null @@ -1,4 +0,0 @@ -manySortedTerm(Profiles, Term, Result) :- - Term =.. [Symbol|Terms], - member((Symbol, Arguments, Result), Profiles), - map(manySortedTerm(Profiles), Terms, Arguments). diff --git a/languages/bsl/egl/.ueber b/languages/bsl/egl/.ueber deleted file mode 100644 index 0f33a23..0000000 --- a/languages/bsl/egl/.ueber +++ /dev/null @@ -1,4 +0,0 @@ -[ - macro(eglSyntax(bsl)) -]. - diff --git a/languages/bsl/egl/README.md b/languages/bsl/egl/README.md deleted file mode 100644 index a3200cd..0000000 --- a/languages/bsl/egl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -A redundant EGL-based syntax of BSL. -It is redundant because the more general ESL parser is actually used. -See esl-to-bsl.pro for the restriction of ESL to BSL. diff --git a/languages/bsl/egl/cs-to-as.pro b/languages/bsl/egl/cs-to-as.pro deleted file mode 100644 index 4af5420..0000000 --- a/languages/bsl/egl/cs-to-as.pro +++ /dev/null @@ -1,4 +0,0 @@ -bslMapping(name, String, Atom) :- - name(Atom, String). - -bslMapping(args, [X, Y], [X|Y]). diff --git a/languages/bsl/egl/cs.egl b/languages/bsl/egl/cs.egl deleted file mode 100644 index a7b0250..0000000 --- a/languages/bsl/egl/cs.egl +++ /dev/null @@ -1,3 +0,0 @@ -signature : { symbol ';' }* ; -symbol : 'symbol' name ':' args '->' name ; -args : { name { 'x' name }* }? ; diff --git a/languages/bsl/egl/cs.term b/languages/bsl/egl/cs.term deleted file mode 100644 index 01d3054..0000000 --- a/languages/bsl/egl/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],signature,[star([n(symbol),t(;)])]), ([],symbol,[t(symbol),n(name),t(:),n(args),t(->),n(name)]), ([],args,[option([n(name),star([t(x),n(name)])])])]. \ No newline at end of file diff --git a/languages/bsl/egl/ls.egl b/languages/bsl/egl/ls.egl deleted file mode 100644 index f94662b..0000000 --- a/languages/bsl/egl/ls.egl +++ /dev/null @@ -1,3 +0,0 @@ -qstring : quote { noQuote }+ quote ; -name : { alpha }+ ; -layout : { space }+ ; diff --git a/languages/bsl/egl/ls.term b/languages/bsl/egl/ls.term deleted file mode 100644 index 05ee798..0000000 --- a/languages/bsl/egl/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],qstring,[n(quote),plus([n(noQuote)]),n(quote)]), ([],name,[plus([n(alpha)])]), ([],layout,[plus([n(space)])])]. diff --git a/languages/bsl/esl-to-bsl.pro b/languages/bsl/esl-to-bsl.pro deleted file mode 100644 index 437b2c9..0000000 --- a/languages/bsl/esl-to-bsl.pro +++ /dev/null @@ -1,15 +0,0 @@ -/* -Map more complex ESL signature notation to BSL -*/ - -eslToBsl(Ss1, Ss2) :- - map(eslToBslSymbol, Ss1, Ss2). - -eslToBslSymbol( - symbol(Sym, Args1, Result), - (Sym, Args2, Result) -) :- - map(bslSymbolArg, Args1, Args2). - -bslSymbolArg(sort(Sort), Sort). - diff --git a/languages/bsl/esl/.ueber b/languages/bsl/esl/.ueber deleted file mode 100644 index ddfa68f..0000000 --- a/languages/bsl/esl/.ueber +++ /dev/null @@ -1,4 +0,0 @@ -[ - macro(eslSyntax(bsl)) -]. - diff --git a/languages/bsl/esl/README.md b/languages/bsl/esl/README.md deleted file mode 100644 index 93afb1d..0000000 --- a/languages/bsl/esl/README.md +++ /dev/null @@ -1,3 +0,0 @@ -A redundant ESL-based syntax of BSL. -It is redundant because the more general ESL signature could be used. -See esl-to-bsl.pro for the restriction of ESL to BSL. diff --git a/languages/bsl/esl/as.esl b/languages/bsl/esl/as.esl deleted file mode 100644 index 42a80d5..0000000 --- a/languages/bsl/esl/as.esl +++ /dev/null @@ -1,2 +0,0 @@ -type signature = profile* ; -type profile = (atom, atom*, atom) ; diff --git a/languages/bsl/esl/as.term b/languages/bsl/esl/as.term deleted file mode 100644 index 09bed53..0000000 --- a/languages/bsl/esl/as.term +++ /dev/null @@ -1 +0,0 @@ -[type(signature,star(sort(profile))),type(profile,tuple([atom,star(atom),atom]))]. \ No newline at end of file diff --git a/languages/bsl/prefix-term.pro b/languages/bsl/prefix-term.pro deleted file mode 100644 index b556117..0000000 --- a/languages/bsl/prefix-term.pro +++ /dev/null @@ -1,5 +0,0 @@ -% A term consists of a symbol and a list of subterms. -prefixTerm(Term) :- - Term =.. [Symbol|Terms], - atom(Symbol), - map(prefixTerm, Terms). diff --git a/languages/bsl/sample.bsl b/languages/bsl/sample.bsl deleted file mode 100644 index 7364365..0000000 --- a/languages/bsl/sample.bsl +++ /dev/null @@ -1,4 +0,0 @@ -[ - (zero, [], nat), - (succ, [nat], nat) -]. diff --git a/languages/bsl/sample.prefixTerm b/languages/bsl/sample.prefixTerm deleted file mode 100644 index 67583a4..0000000 --- a/languages/bsl/sample.prefixTerm +++ /dev/null @@ -1,5 +0,0 @@ -% A simple expression term "0 + 1" -add( - const(zero), - const(succ(zero)) -). diff --git a/languages/bsl/sample.tupleTerm b/languages/bsl/sample.tupleTerm deleted file mode 100644 index ddea783..0000000 --- a/languages/bsl/sample.tupleTerm +++ /dev/null @@ -1,7 +0,0 @@ -% A simple expression term "0 + 1" -( add, - [ - (const, [(zero, [])]), - (const, [(succ, [(zero, [])])]) - ] -). diff --git a/languages/bsl/tuple-term.pro b/languages/bsl/tuple-term.pro deleted file mode 100644 index c4495af..0000000 --- a/languages/bsl/tuple-term.pro +++ /dev/null @@ -1,4 +0,0 @@ -% A term is pair of a symbol and a list of subterms. -tupleTerm((Symbol, Terms)) :- - atom(Symbol), - map(tupleTerm, Terms). diff --git a/languages/ddl/.ueber b/languages/ddl/.ueber deleted file mode 100644 index 5c591a5..0000000 --- a/languages/ddl/.ueber +++ /dev/null @@ -1,5 +0,0 @@ -[ - macro(eglSyntax(ddl)), - macro(eslSyntax(ddl)), - macro(parse(ddl)) -]. diff --git a/languages/ddl/as.esl b/languages/ddl/as.esl deleted file mode 100644 index 3050c03..0000000 --- a/languages/ddl/as.esl +++ /dev/null @@ -1,9 +0,0 @@ -type schema = table* ; -type table = (name, column*) ; -type column = (name, type, clause*) ; -symbol integer : -> type ; -symbol varchar : integer -> type ; -symbol notNull : -> clause ; -symbol primaryKey : -> clause ; -symbol foreignKey : name x name -> clause ; -type name = atom ; diff --git a/languages/ddl/as.term b/languages/ddl/as.term deleted file mode 100644 index 8c7234f..0000000 --- a/languages/ddl/as.term +++ /dev/null @@ -1 +0,0 @@ -[type(schema,star(sort(table))),type(table,tuple([sort(name),star(sort(column))])),type(column,tuple([sort(name),sort(type),star(sort(clause))])),symbol(integer,[],type),symbol(varchar,[integer],type),symbol(notNull,[],clause),symbol(primaryKey,[],clause),symbol(foreignKey,[sort(name),sort(name)],clause),type(name,atom)]. \ No newline at end of file diff --git a/languages/ddl/cs-to-as.pro b/languages/ddl/cs-to-as.pro deleted file mode 100644 index 5b968a6..0000000 --- a/languages/ddl/cs-to-as.pro +++ /dev/null @@ -1,11 +0,0 @@ -% Poormen's separator lists -ddlMapping(table, (Name, [Column, Columns]), (Name, [Column|Columns])). - -% Lexical mapping for integers -ddlMapping(integer, Digits, Int) :- - number_codes(Int, Digits). - -% Lexical mapping for names -ddlMapping(name, (Char, String), Atom) :- - name(Atom, [Char|String]). - diff --git a/languages/ddl/cs.egl b/languages/ddl/cs.egl deleted file mode 100644 index e4695eb..0000000 --- a/languages/ddl/cs.egl +++ /dev/null @@ -1,15 +0,0 @@ -schema : { table }+ ; - -table : 'CREATE' 'TABLE' name '(' { column { ',' column }* }? ')' ';' ; - -column : name type { clause }* ; - -[integer] type : 'INTEGER' ; - -[varchar] type : 'VARCHAR' '(' integer ')' ; - -[notNull] clause : 'NOT' 'NULL' ; - -[primaryKey] clause : 'PRIMARY' 'KEY' ; - -[foreignKey] clause : 'FOREIGN' 'KEY' 'REFERENCES' name '(' name ')' ; diff --git a/languages/ddl/cs.term b/languages/ddl/cs.term deleted file mode 100644 index 2216fb8..0000000 --- a/languages/ddl/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],schema,[plus([n(table)])]), ([],table,[t('CREATE'),t('TABLE'),n(name),t('('),option([n(column),star([t(','),n(column)])]),t(')'),t(;)]), ([],column,[n(name),n(type),star([n(clause)])]), ([integer],type,[t('INTEGER')]), ([varchar],type,[t('VARCHAR'),t('('),n(integer),t(')')]), ([notNull],clause,[t('NOT'),t('NULL')]), ([primaryKey],clause,[t('PRIMARY'),t('KEY')]), ([foreignKey],clause,[t('FOREIGN'),t('KEY'),t('REFERENCES'),n(name),t('('),n(name),t(')')])]. diff --git a/languages/ddl/ls.egl b/languages/ddl/ls.egl deleted file mode 100644 index ffa3511..0000000 --- a/languages/ddl/ls.egl +++ /dev/null @@ -1,3 +0,0 @@ -name : lower { csym }* ; -integer : { digit }+ ; -layout : { space }+ ; diff --git a/languages/ddl/ls.term b/languages/ddl/ls.term deleted file mode 100644 index 6c7db5a..0000000 --- a/languages/ddl/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],name,[n(lower),star([n(csym)])]), ([],integer,[plus([n(digit)])]), ([],layout,[plus([n(space)])])]. \ No newline at end of file diff --git a/languages/ddl/sample.ddl b/languages/ddl/sample.ddl deleted file mode 100644 index e213809..0000000 --- a/languages/ddl/sample.ddl +++ /dev/null @@ -1,20 +0,0 @@ -CREATE TABLE family ( - objectId INTEGER NOT NULL PRIMARY KEY, - name VARCHAR(42) NOT NULL -); - -CREATE TABLE person ( - objectId INTEGER NOT NULL PRIMARY KEY, - firstName VARCHAR(42) NOT NULL, - closestFriend INTEGER FOREIGN KEY REFERENCES person (objectId) -); - -CREATE TABLE family_members ( - familyId INTEGER NOT NULL FOREIGN KEY REFERENCES family (objectId), - members INTEGER NOT NULL FOREIGN KEY REFERENCES person (objectId) -); - -CREATE TABLE person_emailAddresses ( - personId INTEGER NOT NULL FOREIGN KEY REFERENCES person (objectId), - emailAddresses VARCHAR(42) NOT NULL -); diff --git a/languages/ddl/sample.term b/languages/ddl/sample.term deleted file mode 100644 index ba302d7..0000000 --- a/languages/ddl/sample.term +++ /dev/null @@ -1 +0,0 @@ -[ (family,[ (objectId,integer,[notNull,primaryKey]), (name,varchar(42),[notNull])]), (person,[ (objectId,integer,[notNull,primaryKey]), (firstName,varchar(42),[notNull]), (closestFriend,integer,[foreignKey(person,objectId)])]), (family_members,[ (familyId,integer,[notNull,foreignKey(family,objectId)]), (members,integer,[notNull,foreignKey(person,objectId)])]), (person_emailAddresses,[ (personId,integer,[notNull,foreignKey(person,objectId)]), (emailAddresses,varchar(42),[notNull])])]. \ No newline at end of file diff --git a/languages/dgl/.ueber b/languages/dgl/.ueber deleted file mode 100644 index 817b6d1..0000000 --- a/languages/dgl/.ueber +++ /dev/null @@ -1,8 +0,0 @@ -[ - - macro(eslSyntax(dgl)), - language(dgl(text)), - membership(dgl(text), succeed, []), - macro(pplSample(dgl)) - -]. diff --git a/languages/dgl/as-to-cs.pro b/languages/dgl/as-to-cs.pro deleted file mode 100644 index 845d410..0000000 --- a/languages/dgl/as-to-cs.pro +++ /dev/null @@ -1,47 +0,0 @@ -% Render DGL-like graphs -dglPp( - (Ns, Es), - vlist( [ - hlist([text(digraph), indent(text('G')), indent(text('{'))]), - indent(indent(vbox(vlist(Bs1), vlist(Bs2)))), - text('}') - ] ) -) :- - map(ppDglNode, Ns, Bs1), - map(ppDglEdge, Es, Bs2). - -ppDglNode( - (Id, Label, Shape, Style), - hlist( [ - text(Id), - text(' [label="'), - text(Label), - text('", shape='), - text(Shape), - hlist(Bs), - text(']') - ] ) -) :- - Style = [S] -> - Bs = [ - text(', style='), - text(S) - ] - ; Bs = []. - -ppDglEdge( - (From, To, Label), - hlist( [ - text(From), - text(' -> '), - text(To), - hlist(Bs) - ] ) -) :- - Label = [L] -> - Bs = [ - text(' [label=" '), - text(L), - text(' "]') - ] - ; Bs = []. diff --git a/languages/dgl/as.esl b/languages/dgl/as.esl deleted file mode 100644 index bca4266..0000000 --- a/languages/dgl/as.esl +++ /dev/null @@ -1,10 +0,0 @@ -type graph = (node*, edge*) ; -type node = (id, label, shape, style?) ; -type edge = (id, id, label?) ; -type id = atom ; -type label = atom ; -symbol box : -> shape ; -symbol ellipse : -> shape ; -symbol bold : -> style ; -symbol dotted : -> style ; -symbol filled : -> style ; diff --git a/languages/dgl/as.term b/languages/dgl/as.term deleted file mode 100644 index 1468d44..0000000 --- a/languages/dgl/as.term +++ /dev/null @@ -1 +0,0 @@ -[type(graph,tuple([star(sort(node)),star(sort(edge))])),type(node,tuple([sort(id),sort(label),sort(shape),option(sort(style))])),type(edge,tuple([sort(id),sort(id),option(sort(label))])),type(id,atom),type(label,atom),symbol(box,[],shape),symbol(ellipse,[],shape),symbol(bold,[],style),symbol(dotted,[],style),symbol(filled,[],style)]. diff --git a/languages/dgl/sample.dgl b/languages/dgl/sample.dgl deleted file mode 100644 index 0b48fc6..0000000 --- a/languages/dgl/sample.dgl +++ /dev/null @@ -1,6 +0,0 @@ -digraph G { - a [label="A", shape=ellipse, style=filled] - b [label="B", shape=box] - a -> b [label=" a2b "] - b -> b -} diff --git a/languages/dgl/sample.ppl b/languages/dgl/sample.ppl deleted file mode 100644 index d3e4445..0000000 --- a/languages/dgl/sample.ppl +++ /dev/null @@ -1 +0,0 @@ -vlist([hlist([text(digraph),indent(text('G')),indent(text('{'))]),indent(indent(vbox(vlist([hlist([text(a),text(' [label="'),text('A'),text('", shape='),text(ellipse),hlist([text(', style='),text(filled)]),text(']')]),hlist([text(b),text(' [label="'),text('B'),text('", shape='),text(box),hlist([]),text(']')])]),vlist([hlist([text(a),text(' -> '),text(b),hlist([text(' [label=" '),text(a2b),text(' "]')])]),hlist([text(b),text(' -> '),text(b),hlist([])])])))),text('}')]). \ No newline at end of file diff --git a/languages/dgl/sample.term b/languages/dgl/sample.term deleted file mode 100644 index 62adb1f..0000000 --- a/languages/dgl/sample.term +++ /dev/null @@ -1,10 +0,0 @@ -( - [ - (a, 'A', ellipse, [filled]), - (b, 'B', box, []) - ], - [ - (a, b, [a2b]), - (b, b, []) - ] -). diff --git a/languages/dict/.ueber b/languages/dict/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/dict/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/dict/abssyn.pro b/languages/dict/abssyn.pro deleted file mode 100644 index 383ee0f..0000000 --- a/languages/dict/abssyn.pro +++ /dev/null @@ -1,23 +0,0 @@ -% Well-formedness of dictionaries -dict(D) :- - dictToList(D, L), - unzip(L, KL, VL), - map(atom, KL), % type of keys - set(KL), % uniqueness of keys - map(dictValue, VL). - -% Single values of key-value pairs -dictValue(V) :- - singleDictValue(V). - -% Lists as values of key-value pairs -dictValue(L) :- - map(singleDictValue, L). - -% Numbers or atoms -singleDictValue(V) - :- atomic(V). - -% Sub-dictionaries -singleDictValue(D) - :- dict(D). diff --git a/languages/dict/conversion.pro b/languages/dict/conversion.pro deleted file mode 100644 index d024812..0000000 --- a/languages/dict/conversion.pro +++ /dev/null @@ -1,9 +0,0 @@ -% Conversion of dictionaries into lists -dictToList({}, []). -dictToList({K:V}, [(K, V)]). -dictToList({K:V, KVPairs}, [(K, V)|L]) :- - dictToList({KVPairs}, L). - -% The conversion is bi-directional -listToDict(L, D) :- - dictToList(D, L). diff --git a/languages/dict/crud.pro b/languages/dict/crud.pro deleted file mode 100644 index 480a6d9..0000000 --- a/languages/dict/crud.pro +++ /dev/null @@ -1,48 +0,0 @@ -% Test a key to be present in a dictionary -key(K, D) :- - dictToList(D, L), - member((K, _), L). - -% Look up a value for a key from a dictionary -lookup(K, D, V1) :- - dictToList(D, L), - require( - keyNotPresent(K), - member((K, V2), L)), - V1 = V2. - -% dictToList/2 with permutation on result list -permute(D, L2) :- - dictToList(D, L1), - unzip(L1, KL1, _), - unzip(L2, KL2, _), - require( - keysNotEqual, - setEq(KL1, KL2)), - map(flip(member, L1), L2). - -% Add a key-value pair to a dictionary -add(K, V, D1, D2) :- - dictToList(D1, L), - require( - keyPresent(K), - \+ member((K, _), L)), - listToDict([(K, V)|L], D2). - -% Update a dictionary with a key-value pair -update(K, V, D1, D2) :- - dictToList(D1, L1), - require( - keyNotPresent(K), - append(L2, [(K, _)|L3], L1)), - append(L2, [(K, V)|L3], L4), - listToDict(L4, D2). - -% Remove a key-value pair from a dictionary -remove(K, D1, D2) :- - dictToList(D1, L1), - require( - keyNotPresent(K), - append(L2, [(K, _)|L3], L1)), - append(L2, L3, L4), - listToDict(L4, D2). diff --git a/languages/efpl/.ueber b/languages/efpl/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/efpl/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/egl/.ueber b/languages/egl/.ueber deleted file mode 100644 index 2eb0b3d..0000000 --- a/languages/egl/.ueber +++ /dev/null @@ -1,5 +0,0 @@ -[ - macro(eglSyntax(egl)), - macro(eslSyntax(egl)) -]. - diff --git a/languages/egl/api.pro b/languages/egl/api.pro deleted file mode 100644 index ed1c445..0000000 --- a/languages/egl/api.pro +++ /dev/null @@ -1,85 +0,0 @@ -eglAcceptor(Mapping, FileCs, FileLs, Text) :- - eglLanguage(Mapping, FileCs, FileLs, Text). -eglLanguage(Mapping, FileCs, FileLs, Text) :- - eglParser(Mapping, FileCs, FileLs, Text, _). -eglParser(Mapping, FileCs, FileLs, Text, Term) :- - eglParser(layout, Mapping, FileCs, FileLs, Text, Term). -eglParser(Layout, Mapping, FileCs, FileLs, Text, Term) :- - readTermFile(FileCs, CfSyn), - readTermFile(FileLs, LexSyn), - scannerless(Layout, Mapping, CfSyn, LexSyn, Text, Term). - -% Scannerfull parsing -scannerfull( - Mapping, % tree mapping - CfSyn, % context-free syntax - Input0, % input string of terminals - Tree % parse tree - ) :- - CfSyn = [(_, Root, _)|_], - Config = ( - CfSyn, - scannerfullTerminal, - scannerfullLexical, - Mapping - ), - xparse(Config, n(Root), [Tree], Input0, []). - -% Handle terminals as tokens previously scanned -scannerfullTerminal(T, [T|Input], Input). - -% Handle external nonterminals as token class -scannerfullLexical(N, V, [T|Input], Input) :- - T =.. [N, V]. - -% Scannerless parsing -scannerless( - Layout, % layout nonterminal - Mapping, % tree mapping - CfSyn, % rules of context-free syntax - LexSyn, % rules of lexical syntax - Input0, % input string of terminals - Tree % parse tree - ) :- - CfSyn = [(_,Root,_)|_], - Config = ( - CfSyn, - scannerlessTerminal(LexSyn, Layout, Mapping), - scannerlessLexical(LexSyn, Layout, Mapping), - Mapping - ), - xparse(Config, n(Root), [Tree], Input0, Input1), - skipLayout(LexSyn, Layout, Mapping, Input1, []). - -% Handle terminals as prefixes of the input (and skip layout) -scannerlessTerminal(LexSyn, Layout, Mapping, T, Input0, Input2) :- - skipLayout(LexSyn, Layout, Mapping, Input0, Input1), - scannerlessTerminal(T, Input1, Input2). - -% Handle terminals as prefixes of the input -scannerlessTerminal(T, Input0, Input1) :- - name(T, String), - append(String, Input1, Input0). - -% Parse nonterminals according to lexical syntax -scannerlessLexical(LexSyn, Layout, Mapping, N, Tree, Input0, Input2) :- - skipLayout(LexSyn, Layout, Mapping, Input0, Input1), - parseLexical(LexSyn, Mapping, n(N), [Tree], Input1, Input2). - -% Skip layout -skipLayout(LexSyn, Layout, Mapping, Input0, Input1) :- - parseLexical(LexSyn, Mapping, star([n(Layout)]), _, Input0, Input1). - -% Parse symbols according to lexical syntax -parseLexical(LexSyn, Mapping, Symbol, Trees, Input0, Input1) :- - Config = ( - LexSyn, - scannerlessTerminal, - scannerlessChar, - Mapping - ), - once(xparse(Config, Symbol, Trees, Input0, Input1)). - -% Parse externals of lexical syntax as char constraints -scannerlessChar(N, Char, Input0, Input1) :- - char(N, Char, Input0, Input1). diff --git a/languages/egl/as.esl b/languages/egl/as.esl deleted file mode 100644 index 9f032ce..0000000 --- a/languages/egl/as.esl +++ /dev/null @@ -1,13 +0,0 @@ -type grammar = rule* ; -type rule = (label?, nonterminal, symbols) ; -type symbols = symbol* ; -symbol t : terminal -> symbol ; -symbol n : nonterminal -> symbol ; -symbol p : nonterminal -> symbol ; -symbol star : symbols -> symbol ; -symbol plus : symbols -> symbol ; -symbol option : symbols -> symbol ; -type nonterminal = atom ; -type parameter = atom ; -type terminal = atom ; -type label = atom ; diff --git a/languages/egl/as.term b/languages/egl/as.term deleted file mode 100644 index 4aa7dd7..0000000 --- a/languages/egl/as.term +++ /dev/null @@ -1,24 +0,0 @@ -% The signature of extended context-free grammars -[ - % Grammars are lists (sets) of rules - type(grammar, star(sort(rule))), - type(rule, tuple([option(sort(label)),sort(nonterminal),sort(symbols)])), - - % Lists of symbols - type(symbols, star(sort(symbol))), - - % Classification of grammar symbols - symbol(t, [sort(terminal)], symbol), % terminals are symbols - symbol(n, [sort(nonterminal)], symbol), % nonterminals as well - symbol(p, [sort(nonterminal)], symbol), % parameters as well - symbol(star, [sort(symbols)], symbol), % "*" - symbol(plus, [sort(symbols)], symbol), % "+" - symbol(option, [sort(symbols)], symbol), % "?" - - % Primitive symbols and names - type(nonterminal, atom), - type(parameter, atom), - type(terminal, atom), - type(label, atom) - -]. diff --git a/languages/egl/cs-to-as.pro b/languages/egl/cs-to-as.pro deleted file mode 100644 index fea58ce..0000000 --- a/languages/egl/cs-to-as.pro +++ /dev/null @@ -1,5 +0,0 @@ -eglMapping(qstring, (_, String, _), Atom) :- - atom_codes(Atom, String). - -eglMapping(name, String, Atom) :- - name(Atom, String). diff --git a/languages/egl/cs.egl b/languages/egl/cs.egl deleted file mode 100644 index cda4dff..0000000 --- a/languages/egl/cs.egl +++ /dev/null @@ -1,11 +0,0 @@ -grammar : {rule}* ; -rule : {'[' label ']'}? nonterminal ':' gsymbols ';' ; -[t] gsymbol : terminal ; -[n] gsymbol : nonterminal ; -[star] gsymbol : '{' gsymbols '}' '*' ; -[plus] gsymbol : '{' gsymbols '}' '+' ; -[option] gsymbol : '{' gsymbols '}' '?' ; -gsymbols : {gsymbol}* ; -label : name ; -terminal : qstring ; -nonterminal : name ; diff --git a/languages/egl/cs.term b/languages/egl/cs.term deleted file mode 100644 index 6d78c73..0000000 --- a/languages/egl/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],grammar,[star([n(rule)])]), ([],rule,[option([t('['),n(label),t(']')]),n(nonterminal),t(:),n(gsymbols),t(;)]), ([t],gsymbol,[n(terminal)]), ([n],gsymbol,[n(nonterminal)]), ([star],gsymbol,[t('{'),n(gsymbols),t('}'),t(*)]), ([plus],gsymbol,[t('{'),n(gsymbols),t('}'),t(+)]), ([option],gsymbol,[t('{'),n(gsymbols),t('}'),t(?)]), ([],gsymbols,[star([n(gsymbol)])]), ([],label,[n(name)]), ([],terminal,[n(qstring)]), ([],nonterminal,[n(name)])]. diff --git a/languages/egl/ls.egl b/languages/egl/ls.egl deleted file mode 100644 index f94662b..0000000 --- a/languages/egl/ls.egl +++ /dev/null @@ -1,3 +0,0 @@ -qstring : quote { noQuote }+ quote ; -name : { alpha }+ ; -layout : { space }+ ; diff --git a/languages/egl/ls.term b/languages/egl/ls.term deleted file mode 100644 index 05ee798..0000000 --- a/languages/egl/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],qstring,[n(quote),plus([n(noQuote)]),n(quote)]), ([],name,[plus([n(alpha)])]), ([],layout,[plus([n(space)])])]. diff --git a/languages/egl/parse-debug.pro b/languages/egl/parse-debug.pro deleted file mode 100644 index ba6ce33..0000000 --- a/languages/egl/parse-debug.pro +++ /dev/null @@ -1,8 +0,0 @@ -/* -xparse( - _, - Stack, - _, _, _ -) :- - write(Stack), nl, fail. -*/ diff --git a/languages/egl/parse.pro b/languages/egl/parse.pro deleted file mode 100644 index dc4a764..0000000 --- a/languages/egl/parse.pro +++ /dev/null @@ -1,63 +0,0 @@ -:- multifile xparse/5. - -% The case for terminals -xparse(Config, t(T), [], Input0, Input1) :- - Config = (_, ParseTerminal, _, _), - apply(ParseTerminal, [T, Input0, Input1]). - -% The case for nonterminals -xparse( - Config, - n(N), - [Tree2], - Input0, Input1 - ) :- - Config = (Rules, _, _, Mapping), - member(Rule1, Rules), - Rule1 = (LOpt, N, Rhs), - xparseSeq(Config, Rhs, Trees1, Input0, Input1), - ( - % Use label when available - LOpt = [L], - Tree1 =.. [L|Trees1] - ; - % Use trees as is for nonterminal with one rule - LOpt = [], - \+ ( member(Rule2, Rules), - Rule2 = (_, N, _), - Rule1 \= Rule2 ), - list2tuple([], Trees1, Tree1) - ), - ( apply(Mapping, [N, Tree1, Tree2]) -> - true - ; Tree1 = Tree2 ). - -% The case for external nonterminals -xparse(Config, n(N), [Tree], Input0, Input1) :- - Config = (Rules, _, ParseExternal, _), - \+ member((_, N, _), Rules), - apply(ParseExternal, [N, Tree, Input0, Input1]). - -% "*" / "+" / "?" -xparse( - Config, - EbnfSymbol, - [Trees2], - Input0, Input1 - ) :- - EbnfSymbol =.. [Func,Symbols], - member(Func, [star, plus, option]), - Pred = xparseSeq(Config, Symbols), - Goal =.. [Func, Pred, Trees1, Input0, Input1], - Goal, - concat(Trees1, Trees2). - -% Parse groups (sequences) of symbols -xparseSeq( - Config, - Symbols, - Trees2, - Input0, Input1 - ) :- - seq(xparse(Config), Symbols, Trees1, Input0, Input1), - concat(Trees1, Trees2). diff --git a/languages/egl/scanner.pro b/languages/egl/scanner.pro deleted file mode 100644 index f7ffbf5..0000000 --- a/languages/egl/scanner.pro +++ /dev/null @@ -1,22 +0,0 @@ -% Quoted string literals -eglToken(qstring(Atom)) --> - char(quote), - star(char(noQuote), String), - char(quote), - { atom_codes(Atom, String) }. - -% Names consisting of alphabetic characters -eglToken(name(Atom)) --> - plus(char(alpha), String), - { name(Atom, String) }. - -% Keywords and special characters -eglToken(Atom) --> - { - member( - String, - ["#", "*", "+", "?", "{", "}", "[", "]", ":", ";"] - ), - name(Atom, String) - }, - String. diff --git a/languages/esl/.ueber b/languages/esl/.ueber deleted file mode 100644 index 9175aa4..0000000 --- a/languages/esl/.ueber +++ /dev/null @@ -1,8 +0,0 @@ -[ - - language(term), - membership(term, appliedTerm, []), - macro(eglSyntax(esl)), - macro(eslSyntax(esl)) - -]. diff --git a/languages/esl/api.pro b/languages/esl/api.pro deleted file mode 100644 index bb031fb..0000000 --- a/languages/esl/api.pro +++ /dev/null @@ -1,10 +0,0 @@ -% Membership test -eslChecker(File, Term) :- - eslLanguage(File, Term). - -eslLanguage(File, Term) :- - readTermFile(File, Decls), - [Decl|_] = Decls, - ( Decl = symbol(_, _, Sort) - ; Decl = type(Sort, _) ), - wellTypedTerm(Decls, sort(Sort), Term). diff --git a/languages/esl/applied-term.pro b/languages/esl/applied-term.pro deleted file mode 100644 index c4add65..0000000 --- a/languages/esl/applied-term.pro +++ /dev/null @@ -1,9 +0,0 @@ -% Applied terms also covering lists and pairs -appliedTerm(Term) :- - Term =.. [Symbol|Terms], - atom(Symbol), - map(appliedTerm, Terms). - -% Numbers as applied terms -appliedTerm(Term) :- - number(Term). diff --git a/languages/esl/as.esl b/languages/esl/as.esl deleted file mode 100644 index d68c0bf..0000000 --- a/languages/esl/as.esl +++ /dev/null @@ -1,14 +0,0 @@ -type signature = decl*; -symbol type : atom x typeexpr -> decl; -symbol symbol : atom x typeexpr* x atom -> decl; -symbol term : -> typeexpr; -symbol atom : -> typeexpr; -symbol integer : -> typeexpr; -symbol float : -> typeexpr; -symbol number : -> typeexpr; -symbol boolean : -> typeexpr; -symbol sort : atom -> typeexpr; -symbol star : typeexpr -> typeexpr; -symbol plus : typeexpr -> typeexpr; -symbol option : typeexpr -> typeexpr; -symbol tuple : typeexpr* -> typeexpr; diff --git a/languages/esl/as.pro b/languages/esl/as.pro deleted file mode 100644 index 0a44952..0000000 --- a/languages/esl/as.pro +++ /dev/null @@ -1,73 +0,0 @@ -% An applied signature -appliedSignature(Decls) :- - - require( - appliedTermExpected, - appliedTerm(Decls)), - - % No confusion of symbols and types - \+ ( - member(symbol(_, _, Sort), Decls), - member(type(Sort, _), Decls) - ), - - % No double declarations of symbols - \+ ( - member(symbol(Symbol, Arguments1, Result1), Decls), - member(symbol(Symbol, Arguments2, Result2), Decls), - \+ ( - Arguments1 == Arguments2, - Result1 == Result2 - ) - ), - - % No double declarations of types - \+ ( - member(type(Sort, Type1), Decls), - member(type(Sort, Type2), Decls), - \+ Type1 == Type2 - ), - - % Per-declaration well-formedness - map(appliedDecl, Decls). - -% A declaration of a symbol -appliedDecl(symbol(_, Arguments, Result)) :- - map(appliedType, Arguments), - appliedSort(Result). - -% A declaration of a type -appliedDecl(type(Sort, Type)) :- - appliedSort(Sort), - appliedType(Type). - -% Some sorts are reserved as "primitive types" -appliedSort(Sort) :- - \+ member(Sort, [ - atom, - integer, - float, - number, - boolean, - term - ]). - -% An applied term type -appliedType(atom). -appliedType(integer). -appliedType(float). -appliedType(number). -appliedType(boolean). -appliedType(term). -appliedType(sort(Sort)) :- - appliedSort(Sort). -appliedType(star(Type)) :- - appliedType(Type). -appliedType(plus(Type)) :- - appliedType(Type). -appliedType(option(Type)) :- - appliedType(Type). -appliedType(tuple(Types)) :- - map(appliedType, Types). -appliedType(option(Type)) :- - appliedType(Type). diff --git a/languages/esl/as.term b/languages/esl/as.term deleted file mode 100644 index 3226683..0000000 --- a/languages/esl/as.term +++ /dev/null @@ -1,36 +0,0 @@ -% The applied signature of applied signatures -[ - % Signatures as a list of declarations - type(signature, star(sort(decl))), - - % Type definitions - symbol(type, - [ - atom, % the sort/type being defined - sort(typeexpr) % the definition of the type - ], - decl), - - % Symbols associated with argument and result types - symbol(symbol, - [ - atom, % the actual symbol - star(sort(typeexpr)), % the argument types - atom % the result type (sort) - ], - decl), - - % Different kind of term types - symbol(term, [], typeexpr), % untyped terms - symbol(atom, [], typeexpr), % primitive type "atom" - symbol(integer, [], typeexpr), % ... "integer" - symbol(float, [], typeexpr), % ... "float" - symbol(number, [], typeexpr), % ... "number" - symbol(boolean, [], typeexpr), % ... "boolean" - symbol(sort, [atom], typeexpr), % sort reference - symbol(star, [sort(typeexpr)], typeexpr), % list types - symbol(plus, [sort(typeexpr)], typeexpr), % list types - symbol(option, [sort(typeexpr)], typeexpr), % option types - symbol(tuple, [star(sort(typeexpr))], typeexpr) % tuple types - -]. diff --git a/languages/esl/conformance.pro b/languages/esl/conformance.pro deleted file mode 100644 index 87829a4..0000000 --- a/languages/esl/conformance.pro +++ /dev/null @@ -1,41 +0,0 @@ -% Apply symbol declaration -wellTypedTerm(Decls, sort(Result), Term) :- - \+ (list(Term); tuple(Term)), - Term =.. [FSym|Terms], - member(symbol(FSym, Args, Result), Decls), - map(wellTypedTerm(Decls), Args, Terms). - -% Apply type declaration -wellTypedTerm(Decls, sort(Sort), Term) :- - member(type(Sort, Type), Decls), - wellTypedTerm(Decls, Type, Term). - -% Tesst for primitive data types -wellTypedTerm(_, term, _). -wellTypedTerm(_, atom, Term) :- atom(Term). -wellTypedTerm(_, integer, Term) :- integer(Term). -wellTypedTerm(_, float, Term) :- float(Term). -wellTypedTerm(_, number, Term) :- number(Term). -wellTypedTerm(_, boolean, Term) :- boolean(Term). - -% Test for lists -wellTypedTerm(Decls, star(Type), Terms) :- - map(wellTypedTerm(Decls, Type), Terms). -wellTypedTerm(Decls, plus(Type), Terms) :- - Terms \= [], - map(wellTypedTerm(Decls, Type), Terms). - -% Test for options -wellTypedTerm(Decls, option(Type), Terms) :- - ( Terms = []; Terms = [_] ), - map(wellTypedTerm(Decls, Type), Terms). - -% Base case for tuples -wellTypedTerm(Decls, tuple([Type]), Term) :- - wellTypedTerm(Decls, Type, Term). - -% Step case for tuples -wellTypedTerm(Decls, tuple([Type|Types]), (Term, Terms)) :- - Types \= [], - wellTypedTerm(Decls, Type, Term), - wellTypedTerm(Decls, tuple(Types), Terms). diff --git a/languages/esl/cs-to-as.pro b/languages/esl/cs-to-as.pro deleted file mode 100644 index 787facf..0000000 --- a/languages/esl/cs-to-as.pro +++ /dev/null @@ -1,17 +0,0 @@ -eslMapping(typeexpr, (T1, C), T2) :- - eslCardinality(T1, C, T2). - -eslMapping(factor, tuple(T, Ts), tuple([T|Ts])). - -eslMapping(name, String, Atom) :- - name(Atom, String). - -eslMapping(args, [X, Y], [X|Y]). - -eslCardinality(T, none, T). -eslCardinality(T1, star(C), T2) :- - eslCardinality(star(T1), C, T2). -eslCardinality(T1, plus(C), T2) :- - eslCardinality(plus(T1), C, T2). -eslCardinality(T1, option(C), T2) :- - eslCardinality(option(T1), C, T2). diff --git a/languages/esl/cs.egl b/languages/esl/cs.egl deleted file mode 100644 index 854a2c7..0000000 --- a/languages/esl/cs.egl +++ /dev/null @@ -1,17 +0,0 @@ -signature : { decl ';' }* ; -[type] decl : 'type' name '=' typeexpr ; -[symbol] decl : 'symbol' name ':' args '->' name ; -args : { typeexpr { 'x' typeexpr }* }? ; -typeexpr : factor cardinality ; -[term] factor : 'term' ; -[atom] factor : 'atom' ; -[integer] factor : 'integer' ; -[float] factor : 'float' ; -[number] factor : 'number' ; -[boolean] factor : 'boolean' ; -[tuple] factor : '(' typeexpr {',' typeexpr}+ ')' ; -[sort] factor : name ; -[star] cardinality : '*' cardinality ; -[plus] cardinality : '+' cardinality ; -[option] cardinality : '?' cardinality ; -[none] cardinality : ; diff --git a/languages/esl/cs.term b/languages/esl/cs.term deleted file mode 100644 index b8f8a78..0000000 --- a/languages/esl/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],signature,[star([n(decl),t(;)])]), ([type],decl,[t(type),n(name),t(=),n(typeexpr)]), ([symbol],decl,[t(symbol),n(name),t(:),n(args),t(->),n(name)]), ([],args,[option([n(typeexpr),star([t(x),n(typeexpr)])])]), ([],typeexpr,[n(factor),n(cardinality)]), ([term],factor,[t(term)]), ([atom],factor,[t(atom)]), ([integer],factor,[t(integer)]), ([float],factor,[t(float)]), ([number],factor,[t(number)]), ([boolean],factor,[t(boolean)]), ([tuple],factor,[t('('),n(typeexpr),plus([t(','),n(typeexpr)]),t(')')]), ([sort],factor,[n(name)]), ([star],cardinality,[t(*),n(cardinality)]), ([plus],cardinality,[t(+),n(cardinality)]), ([option],cardinality,[t(?),n(cardinality)]), ([none],cardinality,[])]. diff --git a/languages/esl/ls.egl b/languages/esl/ls.egl deleted file mode 100644 index f94662b..0000000 --- a/languages/esl/ls.egl +++ /dev/null @@ -1,3 +0,0 @@ -qstring : quote { noQuote }+ quote ; -name : { alpha }+ ; -layout : { space }+ ; diff --git a/languages/esl/ls.term b/languages/esl/ls.term deleted file mode 100644 index 05ee798..0000000 --- a/languages/esl/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],qstring,[n(quote),plus([n(noQuote)]),n(quote)]), ([],name,[plus([n(alpha)])]), ([],layout,[plus([n(space)])])]. diff --git a/languages/expr/.ueber b/languages/expr/.ueber deleted file mode 100644 index 511169b..0000000 --- a/languages/expr/.ueber +++ /dev/null @@ -1,11 +0,0 @@ -[ - - % Different syntaxes - macro(bglSyntax(expr)), - macro(mmlSyntax(expr)), - - % A simple example - macro(bglSample(expr)), - macro(mmlSample(expr)) - -]. diff --git a/languages/expr/as.bsl b/languages/expr/as.bsl deleted file mode 100644 index 78157a8..0000000 --- a/languages/expr/as.bsl +++ /dev/null @@ -1,4 +0,0 @@ -symbol const: nat -> expr ; -symbol add: expr x expr -> expr ; -symbol zero: -> nat ; -symbol succ: nat -> nat ; diff --git a/languages/expr/as.term b/languages/expr/as.term deleted file mode 100644 index a2893d3..0000000 --- a/languages/expr/as.term +++ /dev/null @@ -1,6 +0,0 @@ -[ - (const,[nat],expr), - (add,[expr,expr],expr), - (zero,[],nat), - (succ,[nat],nat) -]. diff --git a/languages/expr/cs.bgl b/languages/expr/cs.bgl deleted file mode 100644 index 8032956..0000000 --- a/languages/expr/cs.bgl +++ /dev/null @@ -1,4 +0,0 @@ -[const] expr : nat ; -[add] expr : expr '+' expr ; -[zero] nat : 'zero' ; -[succ] nat : 'succ' '(' nat ')' ; diff --git a/languages/expr/cs.term b/languages/expr/cs.term deleted file mode 100644 index 7bf8832..0000000 --- a/languages/expr/cs.term +++ /dev/null @@ -1,6 +0,0 @@ -[ - (const, expr, [n(nat)]), - (add, expr, [n(expr), t(+), n(expr)]), - (zero, nat, [t(zero)]), - (succ, nat, [t(succ), t('('), n(nat), t(')')]) -]. diff --git a/languages/expr/editing/.ueber b/languages/expr/editing/.ueber deleted file mode 100644 index a895075..0000000 --- a/languages/expr/editing/.ueber +++ /dev/null @@ -1,10 +0,0 @@ -[ - % Exercise "new object" - elementOf('new-expr.graph', exprRelaxed(graph(term))), - mapsTo(newObject(add), ['../exprRelaxed/mm.graph'], ['new-expr.graph']), - - % Exercise "list concrete classes for a member" - elementOf('classes.term', term), - mapsTo(concreteClassesForMember(add, left), ['../exprRelaxed/mm.graph'], ['classes.term']) - -]. diff --git a/languages/expr/editing/classes.term b/languages/expr/editing/classes.term deleted file mode 100644 index b279389..0000000 --- a/languages/expr/editing/classes.term +++ /dev/null @@ -1 +0,0 @@ -[const, add]. diff --git a/languages/expr/editing/new-expr.graph b/languages/expr/editing/new-expr.graph deleted file mode 100644 index da50627..0000000 --- a/languages/expr/editing/new-expr.graph +++ /dev/null @@ -1 +0,0 @@ -{class:add,left:[],right:[]}. diff --git a/languages/expr/exprRelaxed/.ueber b/languages/expr/exprRelaxed/.ueber deleted file mode 100644 index bdfc2c2..0000000 --- a/languages/expr/exprRelaxed/.ueber +++ /dev/null @@ -1,9 +0,0 @@ -[ - - macro(mmlSyntax(exprRelaxed)), - macro(mmlSample(exprRelaxed)), - mapsTo(relaxer, ['../mm.graph'], ['mm.graph']), - mapsTo(recardinalizer, ['mm.graph', '../mm.graph', 'sample.graph'], ['../sample.graph']), - mapsTo(recardinalizer, ['../mm.graph', 'mm.graph', '../sample.graph'], ['sample.graph']) - -]. diff --git a/languages/expr/exprRelaxed/mm.graph b/languages/expr/exprRelaxed/mm.graph deleted file mode 100644 index 88070eb..0000000 --- a/languages/expr/exprRelaxed/mm.graph +++ /dev/null @@ -1 +0,0 @@ -{class:metamodel,name:expr,classifiers:[ (nat&{class:class,name:nat,abstract:true,super:[],members:[]}), (zero&{class:class,name:zero,abstract:false,super:[#nat],members:[]}), (succ&{class:class,name:succ,abstract:false,super:[#nat],members:[{class:part,name:pred,type: #nat,cardinality:{class:option}}]}), (expr&{class:class,name:expr,abstract:true,super:[],members:[]}), (const&{class:class,name:const,abstract:false,super:[#expr],members:[{class:part,name:value,type: #nat,cardinality:{class:option}}]}), (add&{class:class,name:add,abstract:false,super:[#expr],members:[{class:part,name:left,type: #expr,cardinality:{class:option}},{class:part,name:right,type: #expr,cardinality:{class:option}}]})]}. diff --git a/languages/expr/exprRelaxed/mm.mml b/languages/expr/exprRelaxed/mm.mml deleted file mode 100644 index f74b41b..0000000 --- a/languages/expr/exprRelaxed/mm.mml +++ /dev/null @@ -1,15 +0,0 @@ -metamodel expr { - abstract class nat { } - class zero extends nat { } - class succ extends nat { - part pred : nat?; - } - abstract class expr { } - class const extends expr { - part value : nat?; - } - class add extends expr { - part left : expr?; - part right : expr?; - } -} diff --git a/languages/expr/exprRelaxed/mm.term b/languages/expr/exprRelaxed/mm.term deleted file mode 100644 index 401b963..0000000 --- a/languages/expr/exprRelaxed/mm.term +++ /dev/null @@ -1 +0,0 @@ -expr,[class(true,nat,[],[]),class(false,zero,[nat],[]),class(false,succ,[nat],[ (part,pred,nat,option)]),class(true,expr,[],[]),class(false,const,[expr],[ (part,value,nat,option)]),class(false,add,[expr],[ (part,left,expr,option), (part,right,expr,option)])]. diff --git a/languages/expr/exprRelaxed/sample.graph b/languages/expr/exprRelaxed/sample.graph deleted file mode 100644 index 3bb9e62..0000000 --- a/languages/expr/exprRelaxed/sample.graph +++ /dev/null @@ -1,19 +0,0 @@ -% A simple expression term "0 + 1" -{ - class : add, - left : [ { - class : const, - value : [ { - class : zero - } ] - } ], - right : [ { - class : const, - value : [ { - class : succ, - pred : [ { - class : zero - } ] - } ] - } ] -}. diff --git a/languages/expr/mm.graph b/languages/expr/mm.graph deleted file mode 100644 index ec4f63a..0000000 --- a/languages/expr/mm.graph +++ /dev/null @@ -1,77 +0,0 @@ -{ - class : metamodel, - name : expr, - classifiers : [ - nat & - { - class : class, - name : nat, - abstract : true, - super : [], - members : [] - }, - zero & - { - class : class, - name : zero, - abstract : false, - super : [ # nat ], - members : [] - }, - succ & - { - class : class, - name : succ, - abstract : false, - super : [ # nat ], - members : [ { - class : part, - name : pred, - type : # nat, - cardinality : { class : one } - } ] - }, - expr & - { - class : class, - name : expr, - abstract : true, - super : [], - members : [] - }, - const & - { - class : class, - name : const, - abstract : false, - super : [ # expr ], - members : [ { - class : part, - name : value, - type : # nat, - cardinality : { class : one } - } ] - }, - add & - { - class : class, - name : add, - abstract : false, - super : [ # expr ], - members : [ - { - class : part, - name : left, - type : # expr, - cardinality : { class : one } - }, - { - class : part, - name : right, - type : # expr, - cardinality : { class : one } - } - ] - } - ] -}. diff --git a/languages/expr/mm.mml b/languages/expr/mm.mml deleted file mode 100644 index 82d3b6c..0000000 --- a/languages/expr/mm.mml +++ /dev/null @@ -1,15 +0,0 @@ -metamodel expr { - abstract class nat { } - class zero extends nat { } - class succ extends nat { - part pred : nat; - } - abstract class expr { } - class const extends expr { - part value : nat; - } - class add extends expr { - part left : expr; - part right : expr; - } -} diff --git a/languages/expr/mm.term b/languages/expr/mm.term deleted file mode 100644 index ff409aa..0000000 --- a/languages/expr/mm.term +++ /dev/null @@ -1 +0,0 @@ -expr,[class(true,nat,[],[]),class(false,zero,[nat],[]),class(false,succ,[nat],[ (part,pred,nat,one)]),class(true,expr,[],[]),class(false,const,[expr],[ (part,value,nat,one)]),class(false,add,[expr],[ (part,left,expr,one), (part,right,expr,one)])]. diff --git a/languages/expr/parsing/.ueber b/languages/expr/parsing/.ueber deleted file mode 100644 index 583f9c6..0000000 --- a/languages/expr/parsing/.ueber +++ /dev/null @@ -1,9 +0,0 @@ -[ - - % Demonstration of accept/parse options - mapsTo(acceptBottomUp, ['../cs.term', '../sample.tokens'], []), - mapsTo(acceptTopDown, ['../cs.term', '../sample.tokens'], []), - mapsTo(parseTopDown, ['../cs.term', '../sample.tokens'], ['../sample.ptree']) - -]. - diff --git a/languages/expr/sample.expr b/languages/expr/sample.expr deleted file mode 100644 index ca48c79..0000000 --- a/languages/expr/sample.expr +++ /dev/null @@ -1 +0,0 @@ -zero+succ(zero) diff --git a/languages/expr/sample.graph b/languages/expr/sample.graph deleted file mode 100644 index af21a12..0000000 --- a/languages/expr/sample.graph +++ /dev/null @@ -1,18 +0,0 @@ -{ - class : add, - left : { - class : const, - value : { - class : zero - } - }, - right : { - class : const, - value : { - class : succ, - pred : { - class : zero - } - } - } -}. diff --git a/languages/expr/sample.ptree b/languages/expr/sample.ptree deleted file mode 100644 index 5f1de23..0000000 --- a/languages/expr/sample.ptree +++ /dev/null @@ -1 +0,0 @@ -fork((add,expr,[n(expr),t(+),n(expr)]),[fork((const,expr,[n(nat)]),[fork((zero,nat,[t(zero)]),[leaf(zero)])]),leaf(+),fork((const,expr,[n(nat)]),[fork((succ,nat,[t(succ),t('('),n(nat),t(')')]),[leaf(succ),leaf('('),fork((zero,nat,[t(zero)]),[leaf(zero)]),leaf(')')])])]). \ No newline at end of file diff --git a/languages/expr/sample.term b/languages/expr/sample.term deleted file mode 100644 index 6c243a9..0000000 --- a/languages/expr/sample.term +++ /dev/null @@ -1,4 +0,0 @@ -add( - const(zero), - const(succ(zero)) -). diff --git a/languages/expr/sample.tokens b/languages/expr/sample.tokens deleted file mode 100644 index bf6c268..0000000 --- a/languages/expr/sample.tokens +++ /dev/null @@ -1 +0,0 @@ -[zero, '+', succ, '(', zero, ')']. diff --git a/languages/expr/sample.tuple b/languages/expr/sample.tuple deleted file mode 100644 index 1b57879..0000000 --- a/languages/expr/sample.tuple +++ /dev/null @@ -1,8 +0,0 @@ -% A simple expression term "0 + 1" -( add, - [ - (const, [(zero, [])]), - (const, [(succ, [(zero, [])])]) - ] -). - diff --git a/languages/expr/scanner.pro b/languages/expr/scanner.pro deleted file mode 100644 index ae812b8..0000000 --- a/languages/expr/scanner.pro +++ /dev/null @@ -1,7 +0,0 @@ -% A scanner for the expr language -exprScanner(Input, Ts) :- - tokens( - token(['zero', 'succ', '(', ')', '+']), - Input, - Ts). - diff --git a/languages/family/.ueber b/languages/family/.ueber deleted file mode 100644 index 274293e..0000000 --- a/languages/family/.ueber +++ /dev/null @@ -1,24 +0,0 @@ -[ - - % Apply the MML to DDL mapping - elementOf('familyByRef/mm.term', mml(mappable(term))), - mapsTo(mmlToDll, ['familyByRef/mm.term'], ['../ddl/sample.term']), - - % Apply the atomToRef transformation - mapsTo( - atomToRef( - person, - person, - closestFriend, - firstName), - [ - 'familyByName/small-family.graph', - 'familyByName/mm.graph' - ], - [ - 'familyByRef/small-family.graph', - 'familyByRef/mm.graph' - ]) - -]. - diff --git a/languages/family/familyByName/.ueber b/languages/family/familyByName/.ueber deleted file mode 100644 index 438ff2d..0000000 --- a/languages/family/familyByName/.ueber +++ /dev/null @@ -1,6 +0,0 @@ -[ - - macro(mmlSyntax(familyByName)), - macro(mmlSample(familyByName, 'small-family')) - -]. diff --git a/languages/family/familyByName/mm.graph b/languages/family/familyByName/mm.graph deleted file mode 100644 index 4fb2272..0000000 --- a/languages/family/familyByName/mm.graph +++ /dev/null @@ -1 +0,0 @@ -{class:metamodel,name:family,classifiers:[ (family&{class:class,name:family,abstract:false,super:[],members:[{class:value,name:name,type: #atom,cardinality:{class:one}},{class:part,name:members,type: #person,cardinality:{class:star}}]}), (person&{class:class,name:person,abstract:false,super:[],members:[{class:value,name:firstName,type: #atom,cardinality:{class:one}},{class:value,name:emailAddresses,type: #atom,cardinality:{class:star}},{class:value,name:closestFriend,type: #atom,cardinality:{class:option}}]}), (atom&{class:datatype,name:atom})]}. \ No newline at end of file diff --git a/languages/family/familyByName/mm.mml b/languages/family/familyByName/mm.mml deleted file mode 100644 index dcbdc25..0000000 --- a/languages/family/familyByName/mm.mml +++ /dev/null @@ -1,16 +0,0 @@ -metamodel family { - - class family { - value name : atom; - part members : person*; - } - - class person { - value firstName : atom; - value emailAddresses : atom*; - value closestFriend : atom?; - } - - datatype atom; - -} diff --git a/languages/family/familyByName/mm.term b/languages/family/familyByName/mm.term deleted file mode 100644 index fbded37..0000000 --- a/languages/family/familyByName/mm.term +++ /dev/null @@ -1 +0,0 @@ -family,[class(false,family,[],[ (value,name,atom,one), (part,members,person,star)]),class(false,person,[],[ (value,firstName,atom,one), (value,emailAddresses,atom,star), (value,closestFriend,atom,option)]),datatype(atom)]. \ No newline at end of file diff --git a/languages/family/familyByName/small-family.graph b/languages/family/familyByName/small-family.graph deleted file mode 100644 index 0282461..0000000 --- a/languages/family/familyByName/small-family.graph +++ /dev/null @@ -1,18 +0,0 @@ -{ - class : family, - name : smallFamily, - members : [ - { - class : person, - firstName : x, - emailAddresses : [ 'x@small.family.com', 'x42@earth.com' ], - closestFriend : [ y ] - }, - { - class : person, - firstName : y, - emailAddresses : [ ], - closestFriend : [ ] - } - ] -}. diff --git a/languages/family/familyByRef/.ueber b/languages/family/familyByRef/.ueber deleted file mode 100644 index 276937a..0000000 --- a/languages/family/familyByRef/.ueber +++ /dev/null @@ -1,8 +0,0 @@ -[ - - macro(mmlSyntax(familyByRef)), - macro(mmlSample(familyByRef, 'empty-family')), - macro(mmlSample(familyByRef, 'singleton-family')), - macro(mmlSample(familyByRef, 'small-family')) - -]. diff --git a/languages/family/familyByRef/empty-family.graph b/languages/family/familyByRef/empty-family.graph deleted file mode 100644 index 30b355c..0000000 --- a/languages/family/familyByRef/empty-family.graph +++ /dev/null @@ -1,6 +0,0 @@ -{ - class : family, - name : emptyFamily, - members : [ - ] -}. diff --git a/languages/family/familyByRef/mm.graph b/languages/family/familyByRef/mm.graph deleted file mode 100644 index 1723364..0000000 --- a/languages/family/familyByRef/mm.graph +++ /dev/null @@ -1 +0,0 @@ -{class:metamodel,name:family,classifiers:[ (family&{class:class,name:family,abstract:false,super:[],members:[{class:value,name:name,type: #atom,cardinality:{class:one}},{class:part,name:members,type: #person,cardinality:{class:star}}]}), (person&{class:class,name:person,abstract:false,super:[],members:[{class:value,name:firstName,type: #atom,cardinality:{class:one}},{class:value,name:emailAddresses,type: #atom,cardinality:{class:star}},{class:reference,name:closestFriend,type: #person,cardinality:{class:option}}]}), (atom&{class:datatype,name:atom})]}. \ No newline at end of file diff --git a/languages/family/familyByRef/mm.mml b/languages/family/familyByRef/mm.mml deleted file mode 100644 index 5b407d9..0000000 --- a/languages/family/familyByRef/mm.mml +++ /dev/null @@ -1,16 +0,0 @@ -metamodel family { - - class family { - value name : atom; - part members : person*; - } - - class person { - value firstName : atom; - value emailAddresses : atom*; - reference closestFriend : person?; - } - - datatype atom; - -} diff --git a/languages/family/familyByRef/mm.term b/languages/family/familyByRef/mm.term deleted file mode 100644 index e800720..0000000 --- a/languages/family/familyByRef/mm.term +++ /dev/null @@ -1 +0,0 @@ -family,[class(false,family,[],[ (value,name,atom,one), (part,members,person,star)]),class(false,person,[],[ (value,firstName,atom,one), (value,emailAddresses,atom,star), (reference,closestFriend,person,option)]),datatype(atom)]. \ No newline at end of file diff --git a/languages/family/familyByRef/singleton-family.graph b/languages/family/familyByRef/singleton-family.graph deleted file mode 100644 index 7504fec..0000000 --- a/languages/family/familyByRef/singleton-family.graph +++ /dev/null @@ -1,12 +0,0 @@ -{ - class : family, - name : singletonFamily, - members : [ - { - class : person, - firstName : joe, - emailAddresses : [], - closestFriend : [] - } - ] -}. diff --git a/languages/family/familyByRef/small-family.graph b/languages/family/familyByRef/small-family.graph deleted file mode 100644 index ad69be2..0000000 --- a/languages/family/familyByRef/small-family.graph +++ /dev/null @@ -1,20 +0,0 @@ -{ - class : family, - name : smallFamily, - members : [ - 42 & - { - class : person, - firstName : x, - emailAddresses : [ 'x@small.family.com', 'x42@earth.com' ], - closestFriend : [ #88 ] - }, - 88 & - { - class : person, - firstName : y, - emailAddresses : [ ], - closestFriend : [ ] - } - ] -}. diff --git a/languages/figure/.ueber b/languages/figure/.ueber deleted file mode 100644 index 32f9a01..0000000 --- a/languages/figure/.ueber +++ /dev/null @@ -1,9 +0,0 @@ -[ - - % Basics - macro(eglSyntax(figure)), - macro(eslSyntax(figure)), - macro(parse(figure)), - macro(pplSample(figure)) - -]. diff --git a/languages/figure/as-to-cs.pro b/languages/figure/as-to-cs.pro deleted file mode 100644 index 15ba187..0000000 --- a/languages/figure/as-to-cs.pro +++ /dev/null @@ -1,47 +0,0 @@ -% Pretty print figures with one line per element -figurePp(F, vlist(Bs)) :- - map(ppElement, F, Bs). - -% End each element by a semicolon -ppElement(E, hbox(B, text(';'))) :- - ppElement_(E, B). - -% Pretty print a line -ppElement_( - line(P1, P2), - hlist([ - text('line'), - text(' from: '), - B1, - text(', to: '), - B2 - ]) -) :- - ppPoint(P1, B1), - ppPoint(P2, B2). - -% Pretty print a circle -ppElement_( - circle(P, I), - hlist([ - text('circle'), - text(' origin: '), - B1, - text(', radius: '), - B2 - ]) -) :- - ppPoint(P, B1), - ppInteger(I, B2). - -% Pretty print a point -ppPoint( - (X, Y), - hlist([text('('), B1, text(', '), B2, text(')')]) -) :- - ppInteger(X, B1), - ppInteger(Y, B2). - -% Pretty print an integer -ppInteger(I, number(I)). - diff --git a/languages/figure/as.esl b/languages/figure/as.esl deleted file mode 100644 index 62576ef..0000000 --- a/languages/figure/as.esl +++ /dev/null @@ -1,4 +0,0 @@ -type figure = element* ; -symbol line: point x point -> element ; -symbol circle: point x integer -> element ; -type point = (integer, integer) ; diff --git a/languages/figure/as.term b/languages/figure/as.term deleted file mode 100644 index c33cc9d..0000000 --- a/languages/figure/as.term +++ /dev/null @@ -1,6 +0,0 @@ -[ - type(figure, star(sort(element))), - symbol(line, [sort(point), sort(point)], element), - symbol(circle, [sort(point), integer], element), - type(point, tuple([integer, integer])) -]. diff --git a/languages/figure/cs-to-as.pro b/languages/figure/cs-to-as.pro deleted file mode 100644 index da1bd80..0000000 --- a/languages/figure/cs-to-as.pro +++ /dev/null @@ -1,2 +0,0 @@ -figureMapping(integer, Digits, Int) :- - number_codes(Int, Digits). diff --git a/languages/figure/cs.egl b/languages/figure/cs.egl deleted file mode 100644 index 2cbd35a..0000000 --- a/languages/figure/cs.egl +++ /dev/null @@ -1,4 +0,0 @@ -figure : {element ';'}* ; -[line] element : 'line' 'from' ':' point ',' 'to' ':' point ; -[circle ] element : 'circle' 'origin' ':' point ',' 'radius' ':' integer ; -point : '(' integer ',' integer ')' ; diff --git a/languages/figure/cs.term b/languages/figure/cs.term deleted file mode 100644 index 655ef0a..0000000 --- a/languages/figure/cs.term +++ /dev/null @@ -1,22 +0,0 @@ -[ - ([], figure, [star([n(element), t(';')])]), - ([line], element, [ - t('line'), - t('from'), t(':'), n(point), - t(','), - t('to'), t(':'), n(point) - ]), - ([circle], element, [ - t('circle'), - t('origin'), t(':'), n(point), - t(','), - t('radius'), t(':'), n(integer) - ]), - ([], point, [ - t('('), - n(integer), - t(','), - n(integer), - t(')') - ]) -]. diff --git a/languages/figure/ls.egl b/languages/figure/ls.egl deleted file mode 100644 index b2eb345..0000000 --- a/languages/figure/ls.egl +++ /dev/null @@ -1,2 +0,0 @@ -integer : { digit }+ ; -layout : { space }+ ; diff --git a/languages/figure/ls.term b/languages/figure/ls.term deleted file mode 100644 index 20edb02..0000000 --- a/languages/figure/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],integer,[plus([n(digit)])]), ([],layout,[plus([n(space)])])]. diff --git a/languages/figure/parsing/.ueber b/languages/figure/parsing/.ueber deleted file mode 100644 index 3ab071e..0000000 --- a/languages/figure/parsing/.ueber +++ /dev/null @@ -1,21 +0,0 @@ -[ - - % An extra language of token sequences - language(figure(tokens(term))), - membership(figure(tokens(term)), succeed, []), - elementOf('sample.tokens', figure(tokens(term))), - - % Scannerless parsing with EGL for both context-free and lexical syntax - mapsTo( - scannerless(layout, figureMapping), - ['../cs.term', '../ls.term', '../sample.figure'], - ['../sample.term']), - - % Scannerfull parsing with EGL for context-free syntax and separate scanner - mapsTo( - scannerfull(figureMapping), - ['../cs.term', 'sample.tokens'], - ['../sample.term']) - -]. - diff --git a/languages/figure/parsing/README.md b/languages/figure/parsing/README.md deleted file mode 100644 index d6b2c36..0000000 --- a/languages/figure/parsing/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Illusration of parsing options - -See the .ueber file. diff --git a/languages/figure/parsing/sample.tokens b/languages/figure/parsing/sample.tokens deleted file mode 100644 index 75de282..0000000 --- a/languages/figure/parsing/sample.tokens +++ /dev/null @@ -1 +0,0 @@ -[line,from,:,'(',integer(0),',',integer(0),')',',',to,:,'(',integer(0),',',integer(4),')',;,line,from,:,'(',integer(0),',',integer(4),')',',',to,:,'(',integer(3),',',integer(5),')',;,line,from,:,'(',integer(3),',',integer(5),')',',',to,:,'(',integer(0),',',integer(0),')',;]. diff --git a/languages/figure/parsing/scanner.pro b/languages/figure/parsing/scanner.pro deleted file mode 100644 index 8661692..0000000 --- a/languages/figure/parsing/scanner.pro +++ /dev/null @@ -1,18 +0,0 @@ -% (Non-negative) integer literals -figureToken(integer(Int)) --> - plus(char(digit), Digits), - { number_codes(Int, Digits) }. - -% Keywords and special characters -figureToken(Atom) --> - { - member(String, - [ - "line", "from", "to", - "circle", "origin", "radius", - ",", ";", ":", "(", ")" - ] - ), - name(Atom, String) - }, - String. diff --git a/languages/figure/sample.figure b/languages/figure/sample.figure deleted file mode 100644 index 127bdc2..0000000 --- a/languages/figure/sample.figure +++ /dev/null @@ -1,3 +0,0 @@ -line from: (0, 0), to: (0, 4); -line from: (0, 4), to: (3, 5); -line from: (3, 5), to: (0, 0); diff --git a/languages/figure/sample.ppl b/languages/figure/sample.ppl deleted file mode 100644 index 0963920..0000000 --- a/languages/figure/sample.ppl +++ /dev/null @@ -1 +0,0 @@ -vlist([hbox(hlist([text(line),text(' from: '),hlist([text('('),number(0),text(', '),number(0),text(')')]),text(', to: '),hlist([text('('),number(0),text(', '),number(4),text(')')])]),text(;)),hbox(hlist([text(line),text(' from: '),hlist([text('('),number(0),text(', '),number(4),text(')')]),text(', to: '),hlist([text('('),number(3),text(', '),number(5),text(')')])]),text(;)),hbox(hlist([text(line),text(' from: '),hlist([text('('),number(3),text(', '),number(5),text(')')]),text(', to: '),hlist([text('('),number(0),text(', '),number(0),text(')')])]),text(;))]). \ No newline at end of file diff --git a/languages/figure/sample.term b/languages/figure/sample.term deleted file mode 100644 index 6ba84fb..0000000 --- a/languages/figure/sample.term +++ /dev/null @@ -1,5 +0,0 @@ -[ - line((0, 0), (0, 4)), - line((0, 4), (3, 5)), - line((3, 5), (0, 0)) -]. diff --git a/languages/fsml/.ueber b/languages/fsml/.ueber deleted file mode 100644 index ebdbe95..0000000 --- a/languages/fsml/.ueber +++ /dev/null @@ -1,18 +0,0 @@ -[ - - macro(eglSyntax(fsml)), - macro(eslSyntax(fsml)), - macro(parse('sample.fsml')), - language(fsml(ok(term))), - membership(fsml(ok(term)), okFsm, []), - elementOf('sample.term', fsml(ok(term))), - elementOf('sample.input', term), - elementOf('sample.output', term), - mapsTo(simulateFsm, ['sample.term', 'sample.input'], ['sample.output']), - mapsTo(acceptFsm, ['sample.term', 'sample.input'], []), - mapsTo(statesOfFsm, ['sample.term'], ['java/State.java']), - mapsTo(inputsOfFsm, ['sample.term'], ['java/Input.java']), - mapsTo(actionsOfFsm, ['sample.term'], ['java/Action.java']), - mapsTo(stepperOfFsm, ['sample.term'], ['java/Stepper.java']) - -]. diff --git a/languages/fsml/accept.pro b/languages/fsml/accept.pro deleted file mode 100644 index 174b694..0000000 --- a/languages/fsml/accept.pro +++ /dev/null @@ -1,3 +0,0 @@ -% Simulation while ignoring output -acceptFsm(Fsm, Input) :- - simulateFsm(Fsm, Input, _). diff --git a/languages/fsml/as.esl b/languages/fsml/as.esl deleted file mode 100644 index 5e46107..0000000 --- a/languages/fsml/as.esl +++ /dev/null @@ -1,7 +0,0 @@ -type fsm = state* ; -type state = (initial, id, transition*) ; -type initial = boolean ; -type transition = (input, action?, id) ; -type id = atom ; -type input = atom ; -type action = atom ; \ No newline at end of file diff --git a/languages/fsml/as.term b/languages/fsml/as.term deleted file mode 100644 index 5bc84e0..0000000 --- a/languages/fsml/as.term +++ /dev/null @@ -1 +0,0 @@ -[type(fsm,star(sort(state))),type(state,tuple([sort(initial),sort(id),star(sort(transition))])),type(initial,boolean),type(transition,tuple([sort(input),option(sort(action)),sort(id)])),type(id,atom),type(input,atom),type(action,atom)]. diff --git a/languages/fsml/cs-to-as.pro b/languages/fsml/cs-to-as.pro deleted file mode 100644 index 5f3b342..0000000 --- a/languages/fsml/cs-to-as.pro +++ /dev/null @@ -1,14 +0,0 @@ -% Lexical mapping for name -fsmlMapping(name, String, Atom) :- - name(Atom, String). - -% Mapping for states -fsmlMapping(state, (I1, N, Ts1), (I2, N, Ts2)) :- - toBoolean((I1==initial), I2), - map(normalizeTargetState(N), Ts1, Ts2). - -% Make target state mandatory -normalizeTargetState(_, (I, A, [S]), (I, A, S)). - -% Fill in missing target state as the source state -normalizeTargetState(N, (I, A, []), (I, A, N)). diff --git a/languages/fsml/cs.egl b/languages/fsml/cs.egl deleted file mode 100644 index c89bd50..0000000 --- a/languages/fsml/cs.egl +++ /dev/null @@ -1,8 +0,0 @@ -fsm : { state }* ; -state : initial 'state' id '{' { transition }* '}' ; -[initial] initial : 'initial' ; -[noninitial] initial : ; -transition : input { '/' action }? { '->' id }? ';' ; -id : name ; -input : name ; -action : name ; diff --git a/languages/fsml/cs.term b/languages/fsml/cs.term deleted file mode 100644 index 8b02f33..0000000 --- a/languages/fsml/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],fsm,[star([n(state)])]), ([],state,[n(initial),t(state),n(id),t('{'),star([n(transition)]),t('}')]), ([initial],initial,[t(initial)]), ([noninitial],initial,[]), ([],transition,[n(input),option([t(/),n(action)]),option([t(->),n(id)]),t(;)]), ([],id,[n(name)]), ([],input,[n(name)]), ([],action,[n(name)])]. diff --git a/languages/fsml/dot/.ueber b/languages/fsml/dot/.ueber deleted file mode 100644 index f2566b0..0000000 --- a/languages/fsml/dot/.ueber +++ /dev/null @@ -1,5 +0,0 @@ -[ - mapsTo(fsmToDgl, ['../sample.term'], ['sample.term']), - macro(pplSample(dgl)) -]. - diff --git a/languages/fsml/dot/Makefile b/languages/fsml/dot/Makefile deleted file mode 100644 index c9e80cd..0000000 --- a/languages/fsml/dot/Makefile +++ /dev/null @@ -1,5 +0,0 @@ -sample = sample - -build: - dot -Tpdf ${sample}.dgl -o ${sample}.pdf - diff --git a/languages/fsml/dot/sample.dgl b/languages/fsml/dot/sample.dgl deleted file mode 100644 index 9fe5639..0000000 --- a/languages/fsml/dot/sample.dgl +++ /dev/null @@ -1,13 +0,0 @@ -digraph G { - locked [label="locked", shape=ellipse, style=filled] - unlocked [label="unlocked", shape=ellipse] - exception [label="exception", shape=ellipse] - locked -> unlocked [label=" ticket/collect "] - locked -> exception [label=" pass/alarm "] - unlocked -> unlocked [label=" ticket/eject "] - unlocked -> locked [label=" pass "] - exception -> exception [label=" ticket/eject "] - exception -> exception [label=" pass "] - exception -> exception [label=" mute "] - exception -> locked [label=" release "] -} diff --git a/languages/fsml/dot/sample.pdf b/languages/fsml/dot/sample.pdf deleted file mode 100644 index d88b4ac..0000000 Binary files a/languages/fsml/dot/sample.pdf and /dev/null differ diff --git a/languages/fsml/dot/sample.ppl b/languages/fsml/dot/sample.ppl deleted file mode 100644 index 98fe0b3..0000000 --- a/languages/fsml/dot/sample.ppl +++ /dev/null @@ -1 +0,0 @@ -vlist([hlist([text(digraph),indent(text('G')),indent(text('{'))]),indent(indent(vbox(vlist([hlist([text(locked),text(' [label="'),text(locked),text('", shape='),text(ellipse),hlist([text(', style='),text(filled)]),text(']')]),hlist([text(unlocked),text(' [label="'),text(unlocked),text('", shape='),text(ellipse),hlist([]),text(']')]),hlist([text(exception),text(' [label="'),text(exception),text('", shape='),text(ellipse),hlist([]),text(']')])]),vlist([hlist([text(locked),text(' -> '),text(unlocked),hlist([text(' [label=" '),text('ticket/collect'),text(' "]')])]),hlist([text(locked),text(' -> '),text(exception),hlist([text(' [label=" '),text('pass/alarm'),text(' "]')])]),hlist([text(unlocked),text(' -> '),text(unlocked),hlist([text(' [label=" '),text('ticket/eject'),text(' "]')])]),hlist([text(unlocked),text(' -> '),text(locked),hlist([text(' [label=" '),text(pass),text(' "]')])]),hlist([text(exception),text(' -> '),text(exception),hlist([text(' [label=" '),text('ticket/eject'),text(' "]')])]),hlist([text(exception),text(' -> '),text(exception),hlist([text(' [label=" '),text(pass),text(' "]')])]),hlist([text(exception),text(' -> '),text(exception),hlist([text(' [label=" '),text(mute),text(' "]')])]),hlist([text(exception),text(' -> '),text(locked),hlist([text(' [label=" '),text(release),text(' "]')])])])))),text('}')]). \ No newline at end of file diff --git a/languages/fsml/dot/sample.term b/languages/fsml/dot/sample.term deleted file mode 100644 index 795ecc8..0000000 --- a/languages/fsml/dot/sample.term +++ /dev/null @@ -1,19 +0,0 @@ -( - % States - [ - (locked,locked,ellipse,[filled]), - (unlocked,unlocked,ellipse,[]), - (exception,exception,ellipse,[]) - ], - % Edges - [ - (locked,unlocked,['ticket/collect']), - (locked,exception,['pass/alarm']), - (unlocked,unlocked,['ticket/eject']), - (unlocked,locked,[pass]), - (exception,exception,['ticket/eject']), - (exception,exception,[pass]), - (exception,exception,[mute]), - (exception,locked,[release]) - ] -). diff --git a/languages/fsml/java/.gitignore b/languages/fsml/java/.gitignore deleted file mode 100644 index e7f6ca5..0000000 --- a/languages/fsml/java/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -*.class -output.txt - diff --git a/languages/fsml/java/.ueber b/languages/fsml/java/.ueber deleted file mode 100644 index 1fa3cda..0000000 --- a/languages/fsml/java/.ueber +++ /dev/null @@ -1,11 +0,0 @@ -[ - elementOf('State.java', java(text)), - elementOf('Input.java', java(text)), - elementOf('Action.java', java(text)), - elementOf('Handler.java', java(text)), - elementOf('Stepper.java', java(text)), - elementOf('Demo.java', java(text)), - elementOf('HandlerBase.java', java(text)), - elementOf('StepperBase.java', java(text)), - elementOf('Pair.java', java(text)) -]. diff --git a/languages/fsml/java/Action.java b/languages/fsml/java/Action.java deleted file mode 100644 index 48f2eaa..0000000 --- a/languages/fsml/java/Action.java +++ /dev/null @@ -1,2 +0,0 @@ -// Generated code -public enum Action {collect, alarm, eject} diff --git a/languages/fsml/java/Demo.java b/languages/fsml/java/Demo.java deleted file mode 100644 index 63a009f..0000000 --- a/languages/fsml/java/Demo.java +++ /dev/null @@ -1,23 +0,0 @@ -// Turnstile-specific, handwritten code -public class Demo { - public static void main(String [] args) { - Handler handler = - new Handler(); - Stepper stepper = - new Stepper(handler); - stepper.step(Input.ticket); - stepper.step(Input.pass); - stepper.step(Input.ticket); - stepper.step(Input.pass); - stepper.step(Input.ticket); - stepper.step(Input.ticket); - stepper.step(Input.pass); - stepper.step(Input.pass); - stepper.step(Input.ticket); - stepper.step(Input.pass); - stepper.step(Input.mute); - stepper.step(Input.release); - stepper.step(Input.ticket); - stepper.step(Input.pass); - } -} diff --git a/languages/fsml/java/Handler.java b/languages/fsml/java/Handler.java deleted file mode 100644 index 22458b9..0000000 --- a/languages/fsml/java/Handler.java +++ /dev/null @@ -1,16 +0,0 @@ -// Turnstile-specific, handwritten code -public class Handler implements HandlerBase { - public void handle(Action a) { - switch (a) { - case collect : - System.out.println("collect"); - break; - case alarm : - System.out.println("alarm"); - break; - case eject : - System.out.println("eject"); - break; - } - } -} diff --git a/languages/fsml/java/HandlerBase.java b/languages/fsml/java/HandlerBase.java deleted file mode 100644 index f675cd0..0000000 --- a/languages/fsml/java/HandlerBase.java +++ /dev/null @@ -1,4 +0,0 @@ -// Reusable code -public interface HandlerBase { - public void handle(A a); -} diff --git a/languages/fsml/java/Input.java b/languages/fsml/java/Input.java deleted file mode 100644 index 50b1a38..0000000 --- a/languages/fsml/java/Input.java +++ /dev/null @@ -1,2 +0,0 @@ -// Generated code -public enum Input {ticket, pass, mute, release} diff --git a/languages/fsml/java/Makefile b/languages/fsml/java/Makefile deleted file mode 100644 index 90a9078..0000000 --- a/languages/fsml/java/Makefile +++ /dev/null @@ -1,11 +0,0 @@ -build: - javac *.java - -test: - java TurnstileDemo > output.txt - diff baseline.txt output.txt - -clean: - rm -f *.class - rm -f output.txt - diff --git a/languages/fsml/java/Pair.java b/languages/fsml/java/Pair.java deleted file mode 100644 index 0cdfc5a..0000000 --- a/languages/fsml/java/Pair.java +++ /dev/null @@ -1,9 +0,0 @@ -// Reusable code -public class Pair { - public X x; - public Y y; - public Pair(X x, Y y) { - this.x = x; - this.y = y; - } -} diff --git a/languages/fsml/java/State.java b/languages/fsml/java/State.java deleted file mode 100644 index de7ced4..0000000 --- a/languages/fsml/java/State.java +++ /dev/null @@ -1,2 +0,0 @@ -// Generated code -public enum State {locked, unlocked, exception} diff --git a/languages/fsml/java/Stepper.java b/languages/fsml/java/Stepper.java deleted file mode 100644 index 787b906..0000000 --- a/languages/fsml/java/Stepper.java +++ /dev/null @@ -1,15 +0,0 @@ -// Generated code -public class Stepper extends StepperBase { - public Stepper(HandlerBase handler) { - this.handler = handler; - state = State.locked; - add(State.locked, Input.ticket, Action.collect, State.unlocked); - add(State.locked, Input.pass, Action.alarm, State.exception); - add(State.unlocked, Input.ticket, Action.eject, State.unlocked); - add(State.unlocked, Input.pass, null, State.locked); - add(State.exception, Input.ticket, Action.eject, State.exception); - add(State.exception, Input.pass, null, State.exception); - add(State.exception, Input.mute, null, State.exception); - add(State.exception, Input.release, null, State.locked); - } -} diff --git a/languages/fsml/java/StepperBase.java b/languages/fsml/java/StepperBase.java deleted file mode 100644 index 5fef898..0000000 --- a/languages/fsml/java/StepperBase.java +++ /dev/null @@ -1,25 +0,0 @@ -import java.util.HashMap; - -// Reusable code -public abstract class StepperBase { - protected S state; - protected HandlerBase handler; - private HashMap>> table = - new HashMap>>(); - public final void add(S from, I i, A a, S to) { - if (!table.containsKey(from)) - table.put(from, new HashMap>()); - HashMap> subtable = table.get(from); - Pair pair = new Pair(a, to); - subtable.put(i, pair); - } - public final void step(I i) { - HashMap> subtable = table.get(state); - Pair pair = subtable.get(i); - S from = state; - S to = pair.y; - System.out.println("from: "+from+", input: "+i+", to: "+to); - if (pair.x!=null) handler.handle(pair.x); - state = to; - } -} diff --git a/languages/fsml/java/baseline.txt b/languages/fsml/java/baseline.txt deleted file mode 100644 index bd40aa8..0000000 --- a/languages/fsml/java/baseline.txt +++ /dev/null @@ -1,21 +0,0 @@ -from: locked, input: ticket, to: unlocked -collect -from: unlocked, input: pass, to: locked -from: locked, input: ticket, to: unlocked -collect -from: unlocked, input: pass, to: locked -from: locked, input: ticket, to: unlocked -collect -from: unlocked, input: ticket, to: unlocked -eject -from: unlocked, input: pass, to: locked -from: locked, input: pass, to: exception -alarm -from: exception, input: ticket, to: exception -eject -from: exception, input: pass, to: exception -from: exception, input: mute, to: exception -from: exception, input: release, to: locked -from: locked, input: ticket, to: unlocked -collect -from: unlocked, input: pass, to: locked diff --git a/languages/fsml/ls.egl b/languages/fsml/ls.egl deleted file mode 100644 index 2fe9073..0000000 --- a/languages/fsml/ls.egl +++ /dev/null @@ -1,2 +0,0 @@ -name : { alpha }+ ; -layout : { space }+ ; diff --git a/languages/fsml/ls.term b/languages/fsml/ls.term deleted file mode 100644 index 0be41eb..0000000 --- a/languages/fsml/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],name,[plus([n(alpha)])]), ([],layout,[plus([n(space)])])]. diff --git a/languages/fsml/ok.pro b/languages/fsml/ok.pro deleted file mode 100644 index 5e75146..0000000 --- a/languages/fsml/ok.pro +++ /dev/null @@ -1,7 +0,0 @@ -% Wellness of FSMs -okFsm(Fsm) :- - require(fsmSingleInitial(Fsm)), - require(fsmDistinctIds(Fsm)), - require(fsmResolvable(Fsm)), - require(fsmDeterministic(Fsm)), - require(fsmReachable(Fsm)). diff --git a/languages/fsml/ok/.ueber b/languages/fsml/ok/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/fsml/ok/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/fsml/ok/closure.pro b/languages/fsml/ok/closure.pro deleted file mode 100644 index acd3d24..0000000 --- a/languages/fsml/ok/closure.pro +++ /dev/null @@ -1,15 +0,0 @@ -% Compute closure of state reachable -fixedPointIds(Fsm, Ids1, Ids4) :- - findall( - Id2, - ( - member(Id1, Ids1), - member((_, Id1, Ts), Fsm), - member((_, _, Id2), Ts) - ), - Ids2), - union(Ids1, Ids2, Ids3), - ( \+ setEq(Ids1, Ids3) -> - fixedPointIds(Fsm, Ids3, Ids4) - ; Ids4 = Ids1 - ). diff --git a/languages/fsml/ok/deterministic.pro b/languages/fsml/ok/deterministic.pro deleted file mode 100644 index 5baefa5..0000000 --- a/languages/fsml/ok/deterministic.pro +++ /dev/null @@ -1,11 +0,0 @@ -% Input is handled deterministically -fsmDeterministic(Fsm) :- - map(stateDeterministic, Fsm). - -% Input is handled deterministically in a state -stateDeterministic((_, _, Ts)) :- - findall( - I, - member((I, _, _), Ts), - Is), - set(Is). diff --git a/languages/fsml/ok/distinct.pro b/languages/fsml/ok/distinct.pro deleted file mode 100644 index ebcc838..0000000 --- a/languages/fsml/ok/distinct.pro +++ /dev/null @@ -1,7 +0,0 @@ -% All state ids are distinct -fsmDistinctIds(Fsm) :- - findall( - Id, - member((_, Id, _), Fsm), - Ids), - set(Ids). diff --git a/languages/fsml/ok/initial.pro b/languages/fsml/ok/initial.pro deleted file mode 100644 index 4d19d87..0000000 --- a/languages/fsml/ok/initial.pro +++ /dev/null @@ -1,7 +0,0 @@ -% There is a single initial state -fsmSingleInitial(Fsm) :- - findall( - Initial, - member((true, Initial, _), Fsm), - Initials), - length(Initials, 1). diff --git a/languages/fsml/ok/reachable.pro b/languages/fsml/ok/reachable.pro deleted file mode 100644 index f2ccd3e..0000000 --- a/languages/fsml/ok/reachable.pro +++ /dev/null @@ -1,12 +0,0 @@ -% All states are reachable from the initial state -fsmReachable(Fsm) :- - findall( - Id, - member((_, Id, _), Fsm), - Ids), - findall( - Initial, - member((true, Initial, _), Fsm), - Initials), - fixedPointIds(Fsm, Initials, Reachables), - setEq(Ids, Reachables). diff --git a/languages/fsml/ok/resolvable.pro b/languages/fsml/ok/resolvable.pro deleted file mode 100644 index 118eec8..0000000 --- a/languages/fsml/ok/resolvable.pro +++ /dev/null @@ -1,14 +0,0 @@ -% All state ids are resolvable to states -fsmResolvable(Fsm) :- - findall( - DefId, - member((_, DefId, _), Fsm), - DefIds), - findall( - RefId, - ( - member((_, _, Ts), Fsm), - member((_, _, RefId), Ts) - ), - RefIds), - subset(RefIds, DefIds). diff --git a/languages/fsml/sample.fsml b/languages/fsml/sample.fsml deleted file mode 100644 index 31e61a0..0000000 --- a/languages/fsml/sample.fsml +++ /dev/null @@ -1,14 +0,0 @@ -initial state locked { - ticket/collect -> unlocked; - pass/alarm -> exception; -} -state unlocked { - ticket/eject; - pass -> locked; -} -state exception { - ticket/eject; - pass; - mute; - release -> locked; -} diff --git a/languages/fsml/sample.input b/languages/fsml/sample.input deleted file mode 100644 index f079a76..0000000 --- a/languages/fsml/sample.input +++ /dev/null @@ -1,16 +0,0 @@ -[ - ticket, % Regular insertion of a ticket - pass, % Regular passage of turnstile - ticket, % Regular insertion of a ticket - pass, % Regular passage of turnstile - ticket, % Regular insertion of a ticket - ticket, % Tickets are ejected in unlocked state - pass, % Regular passage of turnstile - pass, % Attempt leads to exceptional state - ticket, % Tickets are ejected in exceptional state - pass, % Passage attempt keeps us in exceptional state - mute, % Mute indeed - release, % Return to normal - ticket, % Regular insertion of a ticket - pass % Regular passage of turnstile -]. diff --git a/languages/fsml/sample.output b/languages/fsml/sample.output deleted file mode 100644 index 8a3cce1..0000000 --- a/languages/fsml/sample.output +++ /dev/null @@ -1,16 +0,0 @@ -[ - ([collect], unlocked), - ([], locked), - ([collect], unlocked), - ([], locked), - ([collect], unlocked), - ([eject], unlocked), - ([], locked), - ([alarm], exception), - ([eject], exception), - ([], exception), - ([], exception), - ([], locked), - ([collect], unlocked), - ([], locked) -]. diff --git a/languages/fsml/sample.term b/languages/fsml/sample.term deleted file mode 100644 index 37b5715..0000000 --- a/languages/fsml/sample.term +++ /dev/null @@ -1,15 +0,0 @@ -[ - (true,locked,[ - (ticket,[collect],unlocked), - (pass,[alarm],exception)]), - - (false,unlocked,[ - (ticket,[eject],unlocked), - (pass,[],locked)]), - - (false,exception,[ - (ticket,[eject],exception), - (pass,[],exception), - (mute,[],exception), - (release,[],locked)]) -]. diff --git a/languages/fsml/simulation.pro b/languages/fsml/simulation.pro deleted file mode 100644 index b30bf30..0000000 --- a/languages/fsml/simulation.pro +++ /dev/null @@ -1,17 +0,0 @@ -% Simulate FSM for given input to compute output -simulateFsm( - Fsm, - Input, - Output -) :- - member((true, Id, _), Fsm), % Select initial state - simulateFsm_(Fsm, Id, Input, Output). - -% All input was processed -simulateFsm_(_, _, [], []). - -% Apply transition for input at hand -simulateFsm_(Fsm, Id1, [Input|Inputs], [(Action, Id2)|Outputs]) :- - member((_, Id1, Ts), Fsm), - member((Input, Action, Id2), Ts), - simulateFsm_(Fsm, Id2, Inputs, Outputs). diff --git a/languages/fsml/tests/.ueber b/languages/fsml/tests/.ueber deleted file mode 100644 index 6917951..0000000 --- a/languages/fsml/tests/.ueber +++ /dev/null @@ -1,17 +0,0 @@ -[ - not(elementOf('parserError.fsml', fsml(text))), - macro(parse('initialNotOk.fsml')), - not(elementOf('initialNotOk.term', fsml(ok(term)))), - macro(parse('idsNotOk.fsml')), - not(elementOf('idsNotOk.term', fsml(ok(term)))), - macro(parse('resolutionNotOk.fsml')), - not(elementOf('resolutionNotOk.term', fsml(ok(term)))), - macro(parse('determinismNotOk.fsml')), - not(elementOf('determinismNotOk.term', fsml(ok(term)))), - macro(parse('reachabilityNotOk.fsml')), - not(elementOf('reachabilityNotOk.term', fsml(ok(term)))), - elementOf('illegalSymbol.input', term), - elementOf('infeasibleSymbol.input', term), - not(mapsTo(acceptFsm, ['../sample.term', 'illegalSymbol.input'], [])), - not(mapsTo(acceptFsm, ['../sample.term', 'infeasibleSymbol.input'], [])) -]. diff --git a/languages/fsml/tests/determinismNotOk.fsml b/languages/fsml/tests/determinismNotOk.fsml deleted file mode 100644 index e42c147..0000000 --- a/languages/fsml/tests/determinismNotOk.fsml +++ /dev/null @@ -1,14 +0,0 @@ -initial state locked { - ticket/collect -> unlocked; - ticket/alarm -> exception; -} -state unlocked { - ticket/eject; - pass -> locked; -} -state exception { - ticket/eject; - pass; - mute; - release -> locked; -} diff --git a/languages/fsml/tests/determinismNotOk.term b/languages/fsml/tests/determinismNotOk.term deleted file mode 100644 index 64c7451..0000000 --- a/languages/fsml/tests/determinismNotOk.term +++ /dev/null @@ -1 +0,0 @@ -[ (true,locked,[ (ticket,[collect],unlocked), (ticket,[alarm],exception)]), (false,unlocked,[ (ticket,[eject],unlocked), (pass,[],locked)]), (false,exception,[ (ticket,[eject],exception), (pass,[],exception), (mute,[],exception), (release,[],locked)])]. \ No newline at end of file diff --git a/languages/fsml/tests/idsNotOk.fsml b/languages/fsml/tests/idsNotOk.fsml deleted file mode 100644 index 80be19b..0000000 --- a/languages/fsml/tests/idsNotOk.fsml +++ /dev/null @@ -1,14 +0,0 @@ -initial state locked { - ticket/collect -> unlocked; - pass/alarm -> exception; -} -state locked { - ticket/eject; - pass -> locked; -} -state exception { - ticket/eject; - pass; - mute; - release -> locked; -} diff --git a/languages/fsml/tests/idsNotOk.term b/languages/fsml/tests/idsNotOk.term deleted file mode 100644 index 0029839..0000000 --- a/languages/fsml/tests/idsNotOk.term +++ /dev/null @@ -1 +0,0 @@ -[ (true,locked,[ (ticket,[collect],unlocked), (pass,[alarm],exception)]), (false,locked,[ (ticket,[eject],locked), (pass,[],locked)]), (false,exception,[ (ticket,[eject],exception), (pass,[],exception), (mute,[],exception), (release,[],locked)])]. \ No newline at end of file diff --git a/languages/fsml/tests/illegalSymbol.input b/languages/fsml/tests/illegalSymbol.input deleted file mode 100644 index 5c01d8b..0000000 --- a/languages/fsml/tests/illegalSymbol.input +++ /dev/null @@ -1,3 +0,0 @@ -[ - foo % This is a not a valid input symbol -]. diff --git a/languages/fsml/tests/infeasibleSymbol.input b/languages/fsml/tests/infeasibleSymbol.input deleted file mode 100644 index 058ca6d..0000000 --- a/languages/fsml/tests/infeasibleSymbol.input +++ /dev/null @@ -1,3 +0,0 @@ -[ - mute % This symbol is only feasible in the exceptional state -]. diff --git a/languages/fsml/tests/initialNotOk.fsml b/languages/fsml/tests/initialNotOk.fsml deleted file mode 100644 index a6ea3e6..0000000 --- a/languages/fsml/tests/initialNotOk.fsml +++ /dev/null @@ -1,14 +0,0 @@ -initial state locked { - ticket/collect -> unlocked; - pass/alarm -> exception; -} -initial state unlocked { - ticket/eject; - pass -> locked; -} -state exception { - ticket/eject; - pass; - mute; - release -> locked; -} diff --git a/languages/fsml/tests/initialNotOk.term b/languages/fsml/tests/initialNotOk.term deleted file mode 100644 index 2bb4973..0000000 --- a/languages/fsml/tests/initialNotOk.term +++ /dev/null @@ -1 +0,0 @@ -[ (true,locked,[ (ticket,[collect],unlocked), (pass,[alarm],exception)]), (true,unlocked,[ (ticket,[eject],unlocked), (pass,[],locked)]), (false,exception,[ (ticket,[eject],exception), (pass,[],exception), (mute,[],exception), (release,[],locked)])]. \ No newline at end of file diff --git a/languages/fsml/tests/parserError.fsml b/languages/fsml/tests/parserError.fsml deleted file mode 100644 index 3f826ae..0000000 --- a/languages/fsml/tests/parserError.fsml +++ /dev/null @@ -1,14 +0,0 @@ -innnitial state locked { - ticket/collect -> unlocked; - pass/alarm -> exception; -} -state unlocked { - ticket/eject; - pass -> locked; -} -state exception { - ticket/eject; - pass; - mute; - release -> locked; -} diff --git a/languages/fsml/tests/reachabilityNotOk.fsml b/languages/fsml/tests/reachabilityNotOk.fsml deleted file mode 100644 index 72e77f4..0000000 --- a/languages/fsml/tests/reachabilityNotOk.fsml +++ /dev/null @@ -1,14 +0,0 @@ -initial state locked { - ticket/collect -> locked; - pass/alarm -> exception; -} -state unlocked { - ticket/eject; - pass -> locked; -} -state exception { - ticket/eject; - pass; - mute; - release -> locked; -} diff --git a/languages/fsml/tests/reachabilityNotOk.term b/languages/fsml/tests/reachabilityNotOk.term deleted file mode 100644 index 0eeee03..0000000 --- a/languages/fsml/tests/reachabilityNotOk.term +++ /dev/null @@ -1 +0,0 @@ -[ (true,locked,[ (ticket,[collect],locked), (pass,[alarm],exception)]), (false,unlocked,[ (ticket,[eject],unlocked), (pass,[],locked)]), (false,exception,[ (ticket,[eject],exception), (pass,[],exception), (mute,[],exception), (release,[],locked)])]. \ No newline at end of file diff --git a/languages/fsml/tests/resolutionNotOk.fsml b/languages/fsml/tests/resolutionNotOk.fsml deleted file mode 100644 index 748f2d4..0000000 --- a/languages/fsml/tests/resolutionNotOk.fsml +++ /dev/null @@ -1,14 +0,0 @@ -initial state locked { - ticket/collect -> unlockkked; - pass/alarm -> exception; -} -state unlocked { - ticket/eject; - pass -> locked; -} -state exception { - ticket/eject; - pass; - mute; - release -> locked; -} diff --git a/languages/fsml/tests/resolutionNotOk.term b/languages/fsml/tests/resolutionNotOk.term deleted file mode 100644 index b056f0e..0000000 --- a/languages/fsml/tests/resolutionNotOk.term +++ /dev/null @@ -1 +0,0 @@ -[ (true,locked,[ (ticket,[collect],unlockkked), (pass,[alarm],exception)]), (false,unlocked,[ (ticket,[eject],unlocked), (pass,[],locked)]), (false,exception,[ (ticket,[eject],exception), (pass,[],exception), (mute,[],exception), (release,[],locked)])]. \ No newline at end of file diff --git a/languages/fsml/to-dgl.pro b/languages/fsml/to-dgl.pro deleted file mode 100644 index 0c3cbbe..0000000 --- a/languages/fsml/to-dgl.pro +++ /dev/null @@ -1,29 +0,0 @@ -% Map FSM to DGL-like graph -fsmToDgl(Ss, (Ns, Es)) :- - map(fsmStateToDgl, Ss, NEs), - unzip(NEs, Ns, Ess), - concat(Ess, Es). - -% Map state of FSM -fsmStateToDgl( - (Initial, Id, Ts), - ( - (Id, Id, ellipse, Style), - Es - ) -) :- - ( Initial -> - Style = [filled] - ; Style = [] - ), - map(fsmTransToDgl(Id), Ts, Es). - -% Map transition of FSM -fsmTransToDgl( - From, - (Input, Action, To), - (From, To, [Label]) -) :- - Action = [A] -> - format(atom(Label), '~w/~w', [Input, A]) - ; Label = Input. diff --git a/languages/fsml/to-java/.ueber b/languages/fsml/to-java/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/fsml/to-java/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/fsml/to-java/action.pro b/languages/fsml/to-java/action.pro deleted file mode 100644 index 1f961c4..0000000 --- a/languages/fsml/to-java/action.pro +++ /dev/null @@ -1,17 +0,0 @@ -actionsOfFsm(Fsm, Text) :- - - % Find all action names - findall( - A, - ( - member((_, _, Ts), Fsm), - member((_, [A], _), Ts) - ), - As1), - - % Establish uniqueness of names - list_to_set(As1, As2), - - % Render enum type - ppJavaDecl(enum(public, 'Action', As2), Text). - diff --git a/languages/fsml/to-java/input.pro b/languages/fsml/to-java/input.pro deleted file mode 100644 index 61dde7a..0000000 --- a/languages/fsml/to-java/input.pro +++ /dev/null @@ -1,16 +0,0 @@ -inputsOfFsm(Fsm, Text) :- - - % Collect input values - findall( - I, - ( - member((_, _, Ts), Fsm), - member((I, _, _), Ts) - ), - Is1), - - % Establish uniquness of values - list_to_set(Is1, Is2), - - % Render enum type - ppJavaDecl(enum(public, 'Input', Is2), Text). diff --git a/languages/fsml/to-java/state.pro b/languages/fsml/to-java/state.pro deleted file mode 100644 index 7badc81..0000000 --- a/languages/fsml/to-java/state.pro +++ /dev/null @@ -1,10 +0,0 @@ -statesOfFsm(Fsm, Text) :- - - % Collect declared states - findall( - Id, - member((_, Id, _), Fsm), - Ids), - - % Render enum type - ppJavaDecl(enum(public, 'State', Ids), Text). diff --git a/languages/fsml/to-java/stepper.pro b/languages/fsml/to-java/stepper.pro deleted file mode 100644 index 9bbe303..0000000 --- a/languages/fsml/to-java/stepper.pro +++ /dev/null @@ -1,35 +0,0 @@ -stepperOfFsm(Fsm, Text) :- - - % Map transitions to calls to the stepper's "add" method - findall(S, - ( - % Iterate over states and transitions - member((_, From, Ts), Fsm), - member((I, A, To), Ts), - - EFrom = select(name('State'), From), % Expression for source state - ETo = select(name('State'), To), % Expression for target state - EI = select(name('Input'), I), % Expression for input - - % Expression for (optional) action - (A = [A1] -> AE = select(name('Action'), A1); AE = null), - - % Expression statement for "add" - S = expression(call(add, [EFrom, EI, AE, ETo])) - ), - Ss), - - HA = assign(select(this, handler), name(handler)), % Handler assignment - SI = assign(name(state), select(name('State'),locked)), % State initialization - - % Stepper subclass - Class = class(public, false, 'Stepper', [], - [typeapp('StepperBase', - [typename('State'), typename('Input'), typename('Action')])], - [constr( - public, - [(typeapp('HandlerBase', [typename('Action')]), handler)], - [HA,SI|Ss])]), - - % Render the class - ppJavaDecl(Class, Text). diff --git a/languages/graph/.ueber b/languages/graph/.ueber deleted file mode 100644 index 033b3ce..0000000 --- a/languages/graph/.ueber +++ /dev/null @@ -1,5 +0,0 @@ -[ - language(graph(term)), - membership(graph(term), graph, []) -]. - diff --git a/languages/graph/abssyn.pro b/languages/graph/abssyn.pro deleted file mode 100644 index 3b72609..0000000 --- a/languages/graph/abssyn.pro +++ /dev/null @@ -1,46 +0,0 @@ -:- op(1200, xfx, (&)). -:- op(500, fx, (#)). - -% Well-formedness of graphs -graph(O) :- - graph(O, Defs, Uses1), - set(Defs), - list_to_set(Uses1, Uses2), - subset(Uses2, Defs). - -% A graph with an ID -graph(Id&D, [Id|Defs], Uses) :- - atomic(Id), - graph(D, Defs, Uses). - -% A dictionary -graph(D, Defs, Uses) :- - dictToList(D, L), - unzip(L, KL, VL), - map(atom, KL), % type of keys - set(KL), % uniqueness of keys - map(divalue, VL, Defss, Usess), - concat(Defss, Defs), - concat(Usess, Uses). - -% Single values -divalue(Value, Defs, Uses) :- - single(Value, Defs, Uses). - -% Lists -divalue(Value, Defs, Uses) :- - map(single, Value, Defss, Usess), - concat(Defss, Defs), - concat(Usess, Uses). - -% References -single(#Id, [], [Id]) :- - atomic(Id). - -% Numbers or atoms -single(Value, [], []) :- - atomic(Value). - -% Graphs -single(Value, Defs, Uses) :- - graph(Value, Defs, Uses). diff --git a/languages/graph/as-to-cs.pro b/languages/graph/as-to-cs.pro deleted file mode 100644 index b832447..0000000 --- a/languages/graph/as-to-cs.pro +++ /dev/null @@ -1,91 +0,0 @@ -% Render graphs -ppGraph(G, S) :- - once(ppGraph_(text('.'), G, B)), - pp(B, S). - -% Render graphs with IDs -ppGraph_(Post, (Id & Dict), B) :- - ppDict( - hbox( - text(Id), - text(' & ') - ), - Post, - Dict, - B). - -% Render graphs without IDs -ppGraph_(Post, Dict, B) :- - Dict \= (_ & _), - ppDict(empty, Post, Dict, B). - -% Render dictionaries -ppDict( - Pre, - Post, - Dict, - vlist([ - hbox(Pre, text('{')), - indent(vlist(Bs)), - hbox(text('}'), Post) - ]) -) :- - dictToList(Dict, L), - ppKvPairs(L, Bs). - -% Render key-value pairs of dictionaries -ppKvPairs([], []). -ppKvPairs([(K,V)], [B]) :- - ppKvPair(empty, K, V, B). -ppKvPairs([(K,V)|L], [B|Bs]) :- - L \= [], - ppKvPair(text(','), K, V, B), - ppKvPairs(L, Bs). - -% Render one key-value pair -ppKvPair( - Post, - K, - V, - hlist([text(K), text(' : '), B]) -) :- - ppValue(Post, V, B). - -% Render atomic values -ppValue( - Post, - V, - hbox(text(V), Post) -) :- - atomic(V). - -% Render lists -ppValue( - Post, - L, - vlist([ - text('['), - indent(vlist(Bs)), - hbox(text(']'), Post) - ]) -) :- - list(L), - ppList(L, Bs). - -% Render (sub-) graphs -ppValue( - Post, - G, - B -) :- - graph(G), - ppGraph_(Post, G, B). - -% Render lists -ppList([], []). -ppList([V], [B]) :- - ppValue(empty, V, B). -ppList([V|Vs], [B|Bs]) :- - Vs \= [], - ppValue(text(','), V, B), - ppList(Vs, Bs). diff --git a/languages/graph/conversion.pro b/languages/graph/conversion.pro deleted file mode 100644 index a0e2450..0000000 --- a/languages/graph/conversion.pro +++ /dev/null @@ -1,19 +0,0 @@ -% Conversion of dictionaries into lists -graphToList(_&D, L) :- - dictToList(D, L). -graphToList(D, L) :- - dictToList(D, L). - -% Conversion returning inverse direction -graphToList(Id&D, L, listToGraph_(Id)) :- - dictToList(D, L). -graphToList(D, L, listToDict) :- - dictToList(D, L). - -% Construct object from dictionary and ID -listToGraph_(Id, L, Id&D) :- - listToDict(L, D). - -% The conversion is (nearly) bi-directional -listToGraph(L, D) :- - dictToList(D, L). diff --git a/languages/graph/crud.pro b/languages/graph/crud.pro deleted file mode 100644 index 4cab113..0000000 --- a/languages/graph/crud.pro +++ /dev/null @@ -1,23 +0,0 @@ -% Test a key to be present in an object -key(K, _&D) :- - key(K, D). - -% Look up a value for a key from an object -lookup(K, _&D, V) :- - lookup(K, D, V). - -% graphToList/2 with permutation on result list -permute(_&D, L) :- - permute(D, L). - -% Add a key-value pair to an object -add(K, V, Id&D1, Id&D2) :- - add(K, V, D1, D2). - -% Update an object with a key-value pair -update(K, V, Id&D1, Id&D2) :- - update(K, V, D1, D2). - -% Remove a key-value pair from a dictionary -remove(K, Id&D1, Id&D2) :- - remove(K, D1, D2). diff --git a/languages/graph/deref.pro b/languages/graph/deref.pro deleted file mode 100644 index 947a96a..0000000 --- a/languages/graph/deref.pro +++ /dev/null @@ -1,19 +0,0 @@ -% Return object with the intended ID -getObject(Id & O, Id, O). - -% Skip deviating ID -getObject(Id1 & O1, Id2, O2) :- - Id1 \= Id2, - getObject(O1, Id2, O2). - -% Search among values of key-value pairs -getObject(D, Id, O) :- - dictToList(D, L), - unzip(L, _, LV), - member(V, LV), - getObject(V, Id, O). - -% Search among elements of a list -getObject(L, Id, O) :- - member(E, L), - getObject(E, Id, O). diff --git a/languages/graph/iterate.pro b/languages/graph/iterate.pro deleted file mode 100644 index b58c267..0000000 --- a/languages/graph/iterate.pro +++ /dev/null @@ -1,27 +0,0 @@ -topdownGraph(P, O1, O3) :- - try(P, O1, O2), - graphToList(O2, L1, Back), - unzip(L1, KL, VL1), - map(topdownValue(P), VL1, VL2), - zip(KL, VL2, L2), - apply(Back, [L2, O3]). - -% A single value -topdownValue(P, V1, V2) :- - topdownSingle(P, V1, V2). - -% A list of values -topdownValue(P, V1, V2) :- - map(topdownSingle(P), V1, V2). - -% Atomic values -topdownSingle(_, V, V) :- - atomic(V). - -% References -topdownSingle(_, #Id, #Id) :- - atomic(Id). - -% An object as a value -topdownSingle(P, O1, O2) :- - topdownGraph(P, O1, O2). diff --git a/languages/graph/normal.pro b/languages/graph/normal.pro deleted file mode 100644 index 58537be..0000000 --- a/languages/graph/normal.pro +++ /dev/null @@ -1,58 +0,0 @@ -% Graphs are equal if they have the same normal form -graphEq(D1, D2) :- - graphNf(D1, D), - graphNf(D2, D). - -% Start normalization with empty mapping -graphNf(D1, D2) :- - graphNf(D1, D2, (0, []), _). - -% Re-assign ID to object and normalize it -graphNf((Id1&D1), (Id2&D2), M1, M3) :- - idNf(Id1, Id2, M1, M2), - dictNf(D1, D2, M2, M3). - -% Assign ID to object and normalize it -graphNf(D1, (Id1&D2), M1, M3) :- - nextIdNf(Id1, M1, M2), - dictNf(D1, D2, M2, M3). - -% Normalize dictionaries -dictNf(D1, D2, M1, M2) :- - dictToList(D1, L1), - sort(L1, L2), - unzip(L2, KL, VL1), - seq(valueNf, VL1, VL2, M1, M2), - zip(KL, VL2, L3), - listToDict(L3, D2). - -% Normalize a single value -valueNf(V1, V2, M1, M2) :- - singleNf(V1, V2, M1, M2). - -% Normalize a list -valueNf(L1, L2, M1, M2) :- - seq(singleNf, L1, L2, M1, M2). - -% Normalize a single value -singleNf(V, V, M, M) :- atomic(V). -singleNf(#Id1, #Id2, M1, M2) :- idNf(Id1, Id2, M1, M2). -singleNf(D1, D2, M1, M2) :- graphNf(D1, D2, M1, M2). - -% Lookup NF for ID -idNf(Id1, Id2, M, M) :- - M = (_, X), - member((Id1,Id2), X). - -% Add a NF for ID -idNf(Id1, Id2, M1, M2) :- - M1 = (Id2, X), - \+ member((Id1,_), X), - Id3 is Id2 + 1, - M2 = (Id3, [(Id1,Id2)|X]). - -% Generate next ID -nextIdNf(Id1, M1, M2) :- - M1 = (Id1, X), - Id2 is Id1 + 1, - M2 = (Id2, X). diff --git a/languages/graph/search.pro b/languages/graph/search.pro deleted file mode 100644 index 16f09c0..0000000 --- a/languages/graph/search.pro +++ /dev/null @@ -1,28 +0,0 @@ -% Search graph for object of interest -searchGraph(S, O1, O2) :- - searchObject(S, O1, O2). - -searchObject(S, O1, O2) :- - apply(S, [O1]) -> - O2 = O1 - ; searchValues(S, O1, O2). - -% Skip ID -searchValues(S, _&D, O) :- - searchValues(S, D, O). - -% Search among values -searchValues(S, D, O) :- - dictToList(D, L), - unzip(L, _, VL), - member(V, VL), - searchValue(S, V, O). - -% Search objects -searchValue(S, O1, O2) :- - searchObject(S, O1, O2). - -% Search in lists of objects -searchValue(S, Os, O2) :- - member(O1, Os), - searchObject(S, O1, O2). diff --git a/languages/java/.ueber b/languages/java/.ueber deleted file mode 100644 index d481587..0000000 --- a/languages/java/.ueber +++ /dev/null @@ -1,8 +0,0 @@ -[ - macro(eslSyntax(java)), - language(java(text)), - membership(java(text), succeed, []), - elementOf('sample.term', java(term)), - elementOf('sample.java', java(text)), - mapsTo(ppJavaDecl, ['sample.term'], ['sample.java']) -]. diff --git a/languages/java/as-to-cs.pro b/languages/java/as-to-cs.pro deleted file mode 100644 index fa4d7f1..0000000 --- a/languages/java/as-to-cs.pro +++ /dev/null @@ -1,139 +0,0 @@ -% Render Java declaration -ppJavaDecl(J, S) :- - once(ppJavaDecl_(J, B)), - pp(vbox(text('// Generated code'), B), S). - -% Render class declaration -ppJavaDecl_( - class(V, A, N, Ns, X, Ms), - vlist( [ - hlist( [ - text(V), - AB, - indent(text('class')), - indent(text(N)), - NsB, - XB, - indent(text('{')) - ] ), - indent(indent(vlist(MBs))), - text('}') - ] ) -) :- - ( A -> - AB = indent(text('abstract')) - ; AB = empty), - map(ppJavaName, Ns, NBs), - ( Ns == [] -> - NsB = empty - ; NsB = hlist([text('<'), hseplist(text(', '), NBs), text('>')])), - ( X = [T] -> - ppJavaType(T, TB), - XB = hbox(indent(text(extends)), indent(TB)) - ; XB = empty), - map(ppJavaMember(N), Ms, MBs). - -% Render enum declaration -ppJavaDecl_( - enum(V, N, Ns), - hlist( [ - text(V), - indent(text('enum')), - indent(text(N)), - indent(text('{')), - hseplist(text(', '), Bs), - text('}') - ] ) -) :- - map(ppJavaName, Ns, Bs). - -% Render unqualified name -ppJavaName(N, text(N)). - -% Render constructor member -ppJavaMember( - N, - constr(V, Ps, Ss), - vlist( [ - hlist( [ - text(V), - indent(text(N)), - text('('), - hseplist(text(', '), PBs), - text(')'), - indent(text('{')) - ] ), - indent(indent(vlist(SBs))), - text('}') - ] ) -) :- - map(ppJavaMpara, Ps, PBs), - map(ppJavaStm, Ss, SBs). - -% Render method parameter -ppJavaMpara( - (T, N), - hbox(B, indent(text(N))) -) :- - ppJavaType(T, B). - -% Render typename -ppJavaType( - typename(N), - text(N) -). - -% Render (generic) type application -ppJavaType( - typeapp(N, Ts), - hlist( [ - text(N), - text('<'), - hseplist(text(', '), Bs), - text('>') - ] ) -) :- - map(ppJavaType, Ts, Bs). - -% Render statement expression -ppJavaStm( - expression(E), - hbox(B, text(';')) -) :- - ppJavaExpr(E, B). - -% Render assignment -ppJavaStm( - assign(E1, E2), - hlist([B1, indent(text('=')), indent(B2), text(';')]) -) :- - ppJavaExpr(E1, B1), - ppJavaExpr(E2, B2). - -% Render method call -ppJavaExpr( - call(N, Es), - hlist( [ - text(N), - text('('), - hseplist(text(', '), Bs), - text(')') - ] ) -) :- - map(ppJavaExpr, Es, Bs). - -% Render null -ppJavaExpr(null, text(null)). - -% Render this -ppJavaExpr(this, text(this)). - -% Render name expressions -ppJavaExpr(name(N), text(N)). - -% Render selection (".") -ppJavaExpr( - select(E, N), - hlist([B, text('.'), text(N)]) -) :- - ppJavaExpr(E, B). diff --git a/languages/java/as.esl b/languages/java/as.esl deleted file mode 100644 index 11823f3..0000000 --- a/languages/java/as.esl +++ /dev/null @@ -1,21 +0,0 @@ -symbol class : visible x abstract x name x tpara* x extends x member* -> decl ; -symbol enum : visible x name x name+ -> decl ; -symbol public : -> visible ; -symbol protected : -> visible ; -symbol private : -> visible ; -type abstract = boolean ; -type name = atom ; -type tpara = name ; -type extends = type? ; -symbol constr : visible x mpara* x statement* -> member ; -symbol method : visible x time x type x name x mpara* x statement* -> member ; -symbol assignment : expression x expression -> statement ; -symbol expression : expression -> statement ; -symbol this : -> expression ; -symbol null : -> expression ; -symbol name : name -> expression ; -symbol select : expression x name -> expression ; -symbol call : name x expression* -> expression ; -type mpara = (type, name) ; -symbol typename : name -> type ; -symbol typeapp : name x type* -> type ; diff --git a/languages/java/as.term b/languages/java/as.term deleted file mode 100644 index ef9b9e9..0000000 --- a/languages/java/as.term +++ /dev/null @@ -1 +0,0 @@ -[symbol(class,[sort(visible),sort(abstract),sort(name),star(sort(tpara)),sort(extends),star(sort(member))],decl),symbol(enum,[sort(visible),sort(name),plus(sort(name))],decl),symbol(public,[],visible),symbol(protected,[],visible),symbol(private,[],visible),type(abstract,boolean),type(name,atom),type(tpara,sort(name)),type(extends,option(sort(type))),symbol(constr,[sort(visible),star(sort(mpara)),star(sort(statement))],member),symbol(method,[sort(visible),sort(time),sort(type),sort(name),star(sort(mpara)),star(sort(statement))],member),symbol(assignment,[sort(expression),sort(expression)],statement),symbol(expression,[sort(expression)],statement),symbol(this,[],expression),symbol(null,[],expression),symbol(name,[sort(name)],expression),symbol(select,[sort(expression),sort(name)],expression),symbol(call,[sort(name),star(sort(expression))],expression),type(mpara,tuple([sort(type),sort(name)])),symbol(typename,[sort(name)],type),symbol(typeapp,[sort(name),star(sort(type))],type)]. \ No newline at end of file diff --git a/languages/java/sample.java b/languages/java/sample.java deleted file mode 100644 index e35ec8a..0000000 --- a/languages/java/sample.java +++ /dev/null @@ -1,2 +0,0 @@ -// Generated code -public enum foo {v1, v2, v3} diff --git a/languages/java/sample.term b/languages/java/sample.term deleted file mode 100644 index 07e131a..0000000 --- a/languages/java/sample.term +++ /dev/null @@ -1,2 +0,0 @@ -enum(public, foo, [v1, v2, v3]). - diff --git a/languages/mml/.ueber b/languages/mml/.ueber deleted file mode 100644 index bf005cc..0000000 --- a/languages/mml/.ueber +++ /dev/null @@ -1,22 +0,0 @@ -[ - - % Syntax of MML - macro(eglSyntax(mml)), - macro(eslSyntax(mml)), - - % The metametamodel - macro(mmlSyntax(mml)), - membership(mml(graph(term)), metamodel, []), % Alternative characterization - membership(mml(term), metamodelOk, []), % Extra constraints - function(resolver, [mml(term)], [mml(graph(term))], metamodelToGraph, []), - - % MT support for Relaxed metamodels - function(relaxer, [mml(graph(term))], [mml(graph(term))], relaxMm, []), - function(recardinalizer, [mml(graph(term)), mml(graph(term)), graph(term)], [graph(term)], recardinalize, []), - - % MML to DDL mapping - language(mml(mappable(term))), - membership(mml(mappable(term)), simpleMetamodel, []), - function(mmlToDll, [mml(mappable(term))], [ddl(term)], classesToTables, []) - -]. diff --git a/languages/mml/api.pro b/languages/mml/api.pro deleted file mode 100644 index db44620..0000000 --- a/languages/mml/api.pro +++ /dev/null @@ -1,3 +0,0 @@ -mmlChecker(MmFile, Model) :- - readTermFile(MmFile, Mm), - conforms(Model, Mm). diff --git a/languages/mml/as.esl b/languages/mml/as.esl deleted file mode 100644 index 01781b7..0000000 --- a/languages/mml/as.esl +++ /dev/null @@ -1,13 +0,0 @@ -type metamodel = (name, classifier*); -symbol class : abstract x name x extends? x member* -> classifier; -symbol datatype : name -> classifier; -type member = (kind, name, name, cardinality); -symbol value : -> kind; -symbol part : -> kind; -symbol reference : -> kind; -symbol one : -> cardinality; -symbol option : -> cardinality; -symbol star : -> cardinality; -type abstract = boolean; -type extends = name; -type name = atom; diff --git a/languages/mml/as.pro b/languages/mml/as.pro deleted file mode 100644 index 3013d6c..0000000 --- a/languages/mml/as.pro +++ /dev/null @@ -1,77 +0,0 @@ -% Characterization of metamodel terms with lookup (resolution) -metamodel(MM) :- - require( - graphMissing, - graph(MM)), - permute(MM, [ - (class, metamodel), - (name, Name), - (classifiers, Cs) - ]), - atom(Name), - map(classifier(MM), Cs). - -% Datatypes as classifiers -classifier(_, C) :- - lookup(class, C, datatype), - permute(C, [ - (class, datatype), - (name, Name) - ]), - atom(Name). - -% Classes as classifiers -classifier(MM, C) :- - lookup(class, C, class), - permute(C, [ - (class, class), - (name, Name), - (abstract, Abstract), - (super, Super), - (members, Members1) - ]), - atom(Name), - boolean(Abstract), - super(MM, Super), - map(classMember(MM), Members1), - chaseSuper(MM, Super, Members2), - append(Members1, Members2, Members3), - map(lookup(name), Members3, Names), - set(Names). - -% Optional superclass -super(_, []). -super(MM, [#Id]) :- - atomic(Id), - getObject(MM, Id, O), - lookup(class, O, class). - -% Class members -classMember(MM, M) :- - permute(M, [ - (class, Kind), - (name, Name), - (type, #Id), - (cardinality, Ca) - ]), - member(Kind, [value, part, reference]), - atom(Name), - atomic(Id), - cardinality(Ca), - memberType(MM, Kind, Id). - -% Value members use datatypes -memberType(MM, value, Id) :- - getObject(MM, Id, O), - lookup(class, O, datatype). - -% Parts and references use classes -memberType(MM, Kind, Id) :- - member(Kind, [part, reference]), - getObject(MM, Id, O), - lookup(class, O, class). - -% Extension of cardinality type -cardinality(O) :- - permute(O, [(class, Class)]), - member(Class, [one, star, option]). diff --git a/languages/mml/as.term b/languages/mml/as.term deleted file mode 100644 index f720028..0000000 --- a/languages/mml/as.term +++ /dev/null @@ -1,39 +0,0 @@ -% The signature of metamodels -[ - - type(metamodel, tuple([ - sort(name), - star(sort(classifier)) - ])), - - symbol(class, [ - sort(abstract), - sort(name), - option(sort(extends)), - star(sort(member)) - ], classifier), - - symbol(datatype, [ - sort(name) - ], classifier), - - type(member, tuple([ - sort(kind), - sort(name), % name of member - sort(name), % name of type - sort(cardinality) - ])), - - symbol(value, [], kind), - symbol(part, [], kind), - symbol(reference, [], kind), - - symbol(one, [], cardinality), - symbol(option, [], cardinality), - symbol(star, [], cardinality), - - type(abstract, boolean), - type(extends, sort(name)), - type(name, atom) - -]. diff --git a/languages/mml/atom-to-ref/.ueber b/languages/mml/atom-to-ref/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/mml/atom-to-ref/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/mml/atom-to-ref/coupling.pro b/languages/mml/atom-to-ref/coupling.pro deleted file mode 100644 index 9f5d90a..0000000 --- a/languages/mml/atom-to-ref/coupling.pro +++ /dev/null @@ -1,27 +0,0 @@ -% Replace an atom by a reference -atomToRef( - CFrom, % Referring class - CTo, % Referred class - KFrom, % Key on referring class - KTo, % Key on referred class - M1, % Input model - MM1, % Input metamodel - M2, % Output model - MM2 % Output metamodel - ) - - :- - - % Precondition(s) - conforms(M1, MM1), - - % Metamodel level - atomToRefMM(CFrom, CTo, KFrom, MM1, MM2), - - % Model level - ZFrom = instanceOf(MM1, CFrom), - ZTo = instanceOf(MM1, CTo), - atomToRefM(ZFrom, ZTo, KFrom, KTo, M1, M2), - - % Postcondition(s) - conforms(M2, MM2). diff --git a/languages/mml/atom-to-ref/mmt.pro b/languages/mml/atom-to-ref/mmt.pro deleted file mode 100644 index aa41dbe..0000000 --- a/languages/mml/atom-to-ref/mmt.pro +++ /dev/null @@ -1,20 +0,0 @@ -% atomToRef at metamodel level -atomToRefMM( - From, % Class that is referring - To, % Class that is being referred to - Key, % Key to be updated - MM1, % Input metamodel - MM2 % Output metamodel - ) :- - require( - memberMissing(From, Key), - lookupMember(From, Key, MM1, X1)), - require( - valueMissing, - lookup(class, X1, value)), - require( - atomMissing, - lookup(type, X1, #atom)), - update(class, reference, X1, X2), - update(type, #To, X2, X3), - updateMember(From, X3, MM1, MM2). diff --git a/languages/mml/atom-to-ref/mt.pro b/languages/mml/atom-to-ref/mt.pro deleted file mode 100644 index b5e80d3..0000000 --- a/languages/mml/atom-to-ref/mt.pro +++ /dev/null @@ -1,39 +0,0 @@ -% Replace atom-typed reference by actual reference -atomToRefM( - From, % Referring objects - To, % Referred objects - KRef, % Key for reference on "From" objects - KId, % Corresponding key on "To" objects - M1, % Input model - M3 % Output model - ) :- - graphNf(M1, M2), % All objects have IDs - topdownGraph( % Iterate over the object - atomToRefM_(From, To, KRef, KId, M2), - M2, M3). - -% Per-object logic -atomToRefM_( - From, To, KRef, KId, % As before - R, % Root of the graph - O1, O2) - :- - apply(From, [O1]), - lookup(KRef, O1, V1), - applyOrMap( - derefAtom_(To, KId, R), - V1, V2), - update(KRef, V2, O1, O2). - -% Dereference atom -derefAtom_(To, KId, R, A, Ref) :- - searchGraph( - derefAtom_(To, KId, A), - R, Id&_), - Ref = (#Id). - -% Per-object logic -derefAtom_(To, KId, A1, O) :- - apply(To, [O]), - lookup(KId, O, A2), - A1 == A2. diff --git a/languages/mml/conformance/.ueber b/languages/mml/conformance/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/mml/conformance/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/mml/conformance/cardinality.pro b/languages/mml/conformance/cardinality.pro deleted file mode 100644 index 5ce02a9..0000000 --- a/languages/mml/conformance/cardinality.pro +++ /dev/null @@ -1,15 +0,0 @@ -% Conformance for "[1-1]" -cardinalityConforms(One, P, V) :- - permute(One, [ (class, one) ]), - apply(P, [V]). - -% Conformance for "[*]" -cardinalityConforms(Star, P, V) :- - permute(Star, [ (class, star) ]), - apply(map(P), [V]). - -% Conformance for "[0-1]" -cardinalityConforms(Option, P, V) :- - permute(Option, [ (class, option) ]), - option(V), - apply(map(P), [V]). diff --git a/languages/mml/conformance/main.pro b/languages/mml/conformance/main.pro deleted file mode 100644 index 4799949..0000000 --- a/languages/mml/conformance/main.pro +++ /dev/null @@ -1,44 +0,0 @@ -% Conformance of model to a metamodel -conforms(M, MM) :- - require( - graphMissing, - graph(M)), - require( - metamodelMissing, - metamodel(MM)), - lookup(class, M, N), - objectConforms(M, MM, M, N). - -% Object conforms to class -objectConforms(M, MM, O, N1) :- - lookup(class, O, N2), - subclassOf(MM, N2, N1), - lookupClass(N2, MM, Class), - lookup(members, Class, Lmm1), - lookup(super, Class, Super), - chaseSuper(MM, Super, Lmm2), - append(Lmm1, Lmm2, Lmm3), - graphToList(O, Lm), - kvPairsConforms(M, MM, Lm, Lmm3). - -% Object and class matched -kvPairsConforms(_, _, [], []). - -% Skip "class" member of object -kvPairsConforms(M, MM, [(class, _)|Lm], Lmm) :- - kvPairsConforms(M, MM, Lm, Lmm). - -% Handle relevant member, finally -kvPairsConforms(M, MM, [(K, V)|Lm], Lmm1) :- - K \= class, - append(Lmm2, [X|Lmm3], Lmm1), - permute(X, [ - (name, K), - (class, Kind), - (type, #Id), - (cardinality, Times) - ]), - getObject(MM, Id, Type), - memberConforms(M, MM, V, Kind, Type, Times), - append(Lmm2, Lmm3, Lmm4), - kvPairsConforms(M, MM, Lm, Lmm4). diff --git a/languages/mml/conformance/member.pro b/languages/mml/conformance/member.pro deleted file mode 100644 index 696b334..0000000 --- a/languages/mml/conformance/member.pro +++ /dev/null @@ -1,27 +0,0 @@ -% Conformance for values -memberConforms(_, _, V, value, Type, Times) :- - lookup(class, Type, datatype), - lookup(name, Type, Name), - cardinalityConforms(Times, Name, V). - -% Conformance for parts -memberConforms(M, MM, V, part, Type, Times) :- - lookup(class, Type, class), - lookup(name, Type, Name), - cardinalityConforms( - Times, - flip(objectConforms(M, MM), Name), V). - -% Conformance for references -memberConforms(M, MM, V, reference, Type, Times) :- - lookup(class, Type, class), - lookup(name, Type, Name), - cardinalityConforms( - Times, - flip(refConforms(M, MM), Name), V). - -% Deref and check class but not members -refConforms(M, MM, #Id, N1) :- - getObject(M, Id, O), - lookup(class, O, N2), - subclassOf(MM, N2, N1). diff --git a/languages/mml/crud.pro b/languages/mml/crud.pro deleted file mode 100644 index 81689de..0000000 --- a/languages/mml/crud.pro +++ /dev/null @@ -1,50 +0,0 @@ -% Look up class by name -lookupClass(ClassN, MM, Class) :- - lookupClassifier(ClassN, MM, Class), - lookup(class, Class, class). - -% Look up concrete class by name -lookupConcreteClass(ClassN, MM, Class) :- - lookupClass(ClassN, MM, Class), - require( - concreteClassRequired, - lookup(abstract, Class, false) - ). - -% Look up datatype by name -lookupDatatype(DatatypeN, MM) :- - lookupClassifier(DatatypeN, MM, Datatype), - lookup(class, Datatype, datatype). - -% Look up classifier by name -lookupClassifier(ClassifierN, MM, Classifier) :- - lookup(classifiers, MM, Classifiers), - member(Classifier, Classifiers), - lookup(name, Classifier, ClassifierN). - -% Update classifier -updateClassifier(Classifier1, MM1, MM2) :- - lookup(name, Classifier1, ClassifierN), - lookup(classifiers, MM1, Classifiers1), - append(Classifiers2, [Classifier2|Classifiers3], Classifiers1), - lookup(name, Classifier2, ClassifierN), - append(Classifiers2, [Classifier1|Classifiers3], Classifiers4), - update(classifiers, Classifiers4, MM1, MM2). - -% Look up class member -lookupMember(ClassN, MemberN, MM, Member) :- - lookupClass(ClassN, MM, Class), - lookup(members, Class, L1), - member(Member, L1), - lookup(name, Member, MemberN). - -% Update class member -updateMember(ClassN, X, MM1, MM2) :- - lookup(name, X, MemberN), - lookupClass(ClassN, MM1, Class1), - lookup(members, Class1, L1), - append(L2, [Y|L3], L1), - lookup(name, Y, MemberN), - append(L2, [X|L3], L4), - update(members, L4, Class1, Class2), - updateClassifier(Class2, MM1, MM2). diff --git a/languages/mml/cs-to-as.pro b/languages/mml/cs-to-as.pro deleted file mode 100644 index ae17ff7..0000000 --- a/languages/mml/cs-to-as.pro +++ /dev/null @@ -1,5 +0,0 @@ -mmlMapping(name, String, Atom) :- - name(Atom, String). - -mmlMapping(abstract, abstract, true). -mmlMapping(abstract, concrete, false). diff --git a/languages/mml/cs.egl b/languages/mml/cs.egl deleted file mode 100644 index 09607ce..0000000 --- a/languages/mml/cs.egl +++ /dev/null @@ -1,23 +0,0 @@ -metamodel : 'metamodel' name '{' { classifier }* '}' ; - -[datatype] classifier : 'datatype' name ';' ; - -[class] classifier : abstract 'class' name super members ; - -super : { 'extends' name }? ; - -[abstract] abstract : 'abstract' ; -[concrete] abstract : ; - -members : '{' { member }* '}' ; -member : kind name ':' type ';' ; - -[value] kind : 'value' ; -[part] kind : 'part' ; -[reference] kind : 'reference' ; - -type : name cardinality ; - -[star] cardinality : '*' ; -[option] cardinality : '?' ; -[one] cardinality : ; diff --git a/languages/mml/cs.term b/languages/mml/cs.term deleted file mode 100644 index 6f43c25..0000000 --- a/languages/mml/cs.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],metamodel,[t(metamodel),n(name),t('{'),star([n(classifier)]),t('}')]), ([datatype],classifier,[t(datatype),n(name),t(;)]), ([class],classifier,[n(abstract),t(class),n(name),n(super),n(members)]), ([],super,[option([t(extends),n(name)])]), ([abstract],abstract,[t(abstract)]), ([concrete],abstract,[]), ([],members,[t('{'),star([n(member)]),t('}')]), ([],member,[n(kind),n(name),t(:),n(type),t(;)]), ([value],kind,[t(value)]), ([part],kind,[t(part)]), ([reference],kind,[t(reference)]), ([],type,[n(name),n(cardinality)]), ([star],cardinality,[t(*)]), ([option],cardinality,[t(?)]), ([one],cardinality,[])]. diff --git a/languages/mml/editing/.ueber b/languages/mml/editing/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/mml/editing/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/mml/editing/add-object.pro b/languages/mml/editing/add-object.pro deleted file mode 100644 index b76aabd..0000000 --- a/languages/mml/editing/add-object.pro +++ /dev/null @@ -1,24 +0,0 @@ -% Add a new subobject -addObject(MM1, Id, Key, ClassN, Obj1, Obj3) :- - newObject_(MM1, ClassN, Obj0), - topdownGraph( - addObject_(Id, Key, Obj0), - Obj1, Obj2), - graphNf(Obj2, Obj3), - relaxMetamodel(MM1, MM2), - require( - inconsistentAddObject(ClassN), - conforms(Obj3, MM2) - ). - -% Per-object logic -addObject_(Id, Key, Obj0, Obj1, Obj2) :- - Obj1 = (Id&_), - require( - missingListValueForKey(Key), - ( - lookup(Key, Obj1, L1), - list(L1) - )), - append(L1, [Obj0], L2), - update(Key, L2, Obj1, Obj2). diff --git a/languages/mml/editing/lists.pro b/languages/mml/editing/lists.pro deleted file mode 100644 index 8a18eaa..0000000 --- a/languages/mml/editing/lists.pro +++ /dev/null @@ -1,43 +0,0 @@ -% Classes of a metamodel -classesOfMetamodel(MM, CNames) :- - lookup(classifiers, MM, Classes), - findall(CName, - ( - member(Class, Classes), - lookup(class, Class, class), - lookup(name, Class, CName) - ), - CNames). - -% Concrete classes of metamodel -concreteClassesOfMetamodel(MM, CNames) :- - lookup(classifiers, MM, Classes), - findall(CName, - ( - member(Class, Classes), - lookup(class, Class, class), - lookup(name, Class, CName), - lookup(abstract, Class, false) - ), - CNames). - -% Concrete classes with a certain base class -concreteClassesOfMetamodel(Bound, MM, CNames) :- - lookup(classifiers, MM, Classes), - findall(CName, - ( - member(Class, Classes), - lookup(class, Class, class), - lookup(name, Class, CName), - lookup(abstract, Class, false), - subclassOf(MM, CName, Bound) - ), - CNames). - -% Concrete classes for a member -concreteClassesForMember(CName, MName, MM, CNames) :- - lookupMember(CName, MName, MM, M), - lookup(type, M, #Ref), - getObject(MM, Ref, Class), - lookup(name, Class, Bound), - concreteClassesOfMetamodel(Bound, MM, CNames). diff --git a/languages/mml/editing/new-object.pro b/languages/mml/editing/new-object.pro deleted file mode 100644 index 42203c2..0000000 --- a/languages/mml/editing/new-object.pro +++ /dev/null @@ -1,20 +0,0 @@ -% Instantiate a class -newObject(ClassN, MM1, Obj2) :- - newObject_(ClassN, MM1, Obj1), - graphNf(Obj1, Obj2), - relaxMm(MM1, MM2), - require( - inconsistentNewObject(ClassN), - conforms(Obj2, MM2) - ). - -% Instantiation helper -newObject_(ClassN, MM, Obj) :- - lookupConcreteClass(ClassN, MM, Class), - lookup(members, Class, Ms), - map(newMember, Ms, Fs), - listToGraph([(class, ClassN)|Fs], Obj). - -% Per-member logic -newMember(Member, (MemberN, [])) :- - lookup(name, Member, MemberN). diff --git a/languages/mml/editing/obj-add-key.pro b/languages/mml/editing/obj-add-key.pro deleted file mode 100644 index 0fc27ed..0000000 --- a/languages/mml/editing/obj-add-key.pro +++ /dev/null @@ -1,19 +0,0 @@ -% Add a key with value "[]" to certain objects -addKey( - P, % Predicate for object selection - Key, % Key to be inserted - O1, O2) - :- - topdownGraph( - addKey_(P, Key, O1), - O1, O2). - -% Per-object logic -addKey_( - P, % Predicate for selection of objects - Key, % Key to be inserted - R, % Root of graph - O1, O2) - :- - apply(P, [R, O1]), - add(Key, [], O1, O2). diff --git a/languages/mml/editing/obj-remove-key.pro b/languages/mml/editing/obj-remove-key.pro deleted file mode 100644 index 11880d3..0000000 --- a/languages/mml/editing/obj-remove-key.pro +++ /dev/null @@ -1,14 +0,0 @@ -% Remove a key from certain objects -removeKey( - P, % Predicate for object selection - Key, % Key to be removed - O1, O2) - :- - topdownGraph( - removeKey_(P, Key, O1), - O1, O2). - -% Per-object logic -removeKey_(P, Key, R, O1, O2) :- - apply(P, [R, O1]), - remove(Key, O1, O2). diff --git a/languages/mml/editing/remove-object.pro b/languages/mml/editing/remove-object.pro deleted file mode 100644 index 4ab320e..0000000 --- a/languages/mml/editing/remove-object.pro +++ /dev/null @@ -1,23 +0,0 @@ -% Remove a subobject -removeObject(MM1, Id, Obj1, Obj3) :- - topdownGraph( - removeObject_(Id), - Obj1, Obj2), - require( - missingId(Id), - Obj1 \= Obj2), - graphNf(Obj2, Obj3), - relaxMetamodel(MM1, MM2), - require( - inconsistentRemoveObject(Id), - conforms(Obj3, MM2) - ). - -% Per-object logic -removeObject_(Id, Obj1, Obj2) :- - graphToList(Obj1, L1, Q), - append(L2, [(K, V1)|L3], L1), - append(V2, [(Id&_)|V3], V1), - append(V2, V3, V4), - append(L2, [(K, V4)|L3], L4), - apply(Q, [L4, Obj2]). diff --git a/languages/mml/graph-chase.pro b/languages/mml/graph-chase.pro deleted file mode 100644 index 6dcee3f..0000000 --- a/languages/mml/graph-chase.pro +++ /dev/null @@ -1,16 +0,0 @@ -% Chase members along super chain -chaseSuper(MM, Super, L) :- - chaseSuper_(MM, [], Super, L). - -% Chase finished when super is missing -chaseSuper_(_, _, [], []). - -% Continue chase for members -chaseSuper_(MM, Supers, [#Super1], L3) :- - % Terminate in case of cycle - \+ member(Super1, Supers), - getObject(MM, Super1, O), - lookup(members, O, L1), - lookup(super, O, Super2), - chaseSuper_(MM, [Super1|Supers], Super2, L2), - append(L1, L2, L3). diff --git a/languages/mml/ls.egl b/languages/mml/ls.egl deleted file mode 100644 index 2fe9073..0000000 --- a/languages/mml/ls.egl +++ /dev/null @@ -1,2 +0,0 @@ -name : { alpha }+ ; -layout : { space }+ ; diff --git a/languages/mml/ls.term b/languages/mml/ls.term deleted file mode 100644 index 0be41eb..0000000 --- a/languages/mml/ls.term +++ /dev/null @@ -1 +0,0 @@ -[ ([],name,[plus([n(alpha)])]), ([],layout,[plus([n(space)])])]. diff --git a/languages/mml/mm.graph b/languages/mml/mm.graph deleted file mode 100644 index ebff6b8..0000000 --- a/languages/mml/mm.graph +++ /dev/null @@ -1,194 +0,0 @@ -{ - class : metamodel, - name : metametamodel, - classifiers : [ - - base & - { - class : class, - name : base, - abstract : true, - super : [], - members : [ - { - class : value, - name : name, - type : # atom, - cardinality : { class : one } - } - ] - }, - - metamodel & - { - class : class, - name : metamodel, - abstract : false, - super : [ # base ], - members : [ - { - class : part, - name : classifiers, - type : # classifier, - cardinality : { class : star } - } - ] - }, - - classifier & - { - class : class, - name : classifier, - abstract : true, - super : [ # base ], - members : [] - }, - - datatype & - { - class : class, - name : datatype, - abstract : false, - super : [ # classifier ], - members : [] - }, - - class & - { - class : class, - name : class, - abstract : false, - super : [ # classifier ], - members : [ - { - class : value, - name : abstract, - type : # boolean, - cardinality : { class : one } - }, - { - class : reference, - name : super, - type : # class, - cardinality : { class : option } - }, - { - class : part, - name : members, - type : # member, - cardinality : { class : star } - } - ] - }, - - member & - { - class : class, - name : member, - abstract : true, - super : [ # base ], - members : [ - { - class : part, - name : cardinality, - type : # cardinality, - cardinality : { class : one } - } - ] - }, - - value & - { - class : class, - name : value, - abstract : false, - super : [ # member ], - members : [ - { - class : reference, - name : type, - type : # datatype, - cardinality : { class : one } - } - ] - }, - - part & - { - class : class, - name : part, - abstract : false, - super : [ # member ], - members : [ - { - class : reference, - name : type, - type : # class, - cardinality : { class : one } - } - ] - }, - - reference & - { - class : class, - name : reference, - abstract : false, - super : [ # member ], - members : [ - { - class : reference, - name : type, - type : # class, - cardinality : { class : one } - } - ] - }, - - cardinality & - { - class : class, - name : cardinality, - abstract : true, - super : [ ], - members : [ ] - }, - - { - class : class, - name : one, - abstract : false, - super : [ # cardinality ], - members : [ ] - }, - - { - class : class, - name : star, - abstract : false, - super : [ # cardinality ], - members : [ ] - }, - - { - class : class, - name : option, - abstract : false, - super : [ # cardinality ], - members : [ ] - }, - - atom & - { - class : datatype, - name : atom - }, - - boolean & - { - class : datatype, - name : boolean - } - - ] -}. diff --git a/languages/mml/mm.mml b/languages/mml/mm.mml deleted file mode 100644 index 333806c..0000000 --- a/languages/mml/mm.mml +++ /dev/null @@ -1,45 +0,0 @@ -metamodel metametamodel { - - abstract class base { - value name : atom; - } - - class metamodel extends base { - part classifiers : classifier*; - } - - abstract class classifier extends base { } - - class datatype extends classifier { } - - class class extends classifier { - value abstract : boolean; - reference super : class?; - part members : member*; - } - - abstract class member extends base { - part cardinality : cardinality; - } - - class value extends member { - reference type : datatype; - } - - class part extends member { - reference type : class; - } - - class reference extends member { - reference type : class; - } - - abstract class cardinality { } - class one extends cardinality { } - class star extends cardinality { } - class option extends cardinality { } - - datatype atom; - datatype boolean; - -} diff --git a/languages/mml/mm.term b/languages/mml/mm.term deleted file mode 100644 index 1e8c9c4..0000000 --- a/languages/mml/mm.term +++ /dev/null @@ -1 +0,0 @@ -metametamodel,[class(true,base,[],[ (value,name,atom,one)]),class(false,metamodel,[base],[ (part,classifiers,classifier,star)]),class(true,classifier,[base],[]),class(false,datatype,[classifier],[]),class(false,class,[classifier],[ (value,abstract,boolean,one), (reference,super,class,option), (part,members,member,star)]),class(true,member,[base],[ (part,cardinality,cardinality,one)]),class(false,value,[member],[ (reference,type,datatype,one)]),class(false,part,[member],[ (reference,type,class,one)]),class(false,reference,[member],[ (reference,type,class,one)]),class(true,cardinality,[],[]),class(false,one,[cardinality],[]),class(false,star,[cardinality],[]),class(false,option,[cardinality],[]),datatype(atom),datatype(boolean)]. diff --git a/languages/mml/ok.pro b/languages/mml/ok.pro deleted file mode 100644 index 335df7b..0000000 --- a/languages/mml/ok.pro +++ /dev/null @@ -1,48 +0,0 @@ -% Wellness of metamodels -metamodelOk((_, Classifiers)) :- - - % Uniqueness of classifier names - map(nameOfClassifier, Classifiers, Names), - set(Names), - - % Wellness per classifier - map(classifierOk(Classifiers), Classifiers). - -% Projection of classifier to name -nameOfClassifier(class(_, Name, _, _), Name). -nameOfClassifier(datatype(Name), Name). - -% Wellness of datatypes (trivial) -classifierOk(_, datatype(_)). - -% Wellness of classes -classifierOk( - Classifiers, % Context - class(_, _, Extends, Members1)) - - :- - % Resolvability of "super" - chaseMembers(Classifiers, Extends, Members2), - - % Uniqueness of member names - append(Members1, Members2, Members3), - map(nameOfMember, Members3, Names), - set(Names), - - % Wellness per member - map(memberOk(Classifiers), Members1). - -% Projection of member to name -nameOfMember((_, Name, _, _), Name). - -% Wellness of values -memberOk(Classifiers, (value, _, Name, _)) :- - member(datatype(Name), Classifiers). - -% Wellness of parts -memberOk(Classifiers, (part, _, Name, _)) :- - member(class(_,Name,_,_), Classifiers). - -% Wellness of references -memberOk(Classifiers, (reference, _, Name, _)) :- - member(class(_,Name,_,_), Classifiers). diff --git a/languages/mml/recardinalize.pro b/languages/mml/recardinalize.pro deleted file mode 100644 index 0c0c5ec..0000000 --- a/languages/mml/recardinalize.pro +++ /dev/null @@ -1,70 +0,0 @@ -% Account for differences in cardinality -recardinalize( - MM1, % Metamodel of source model - MM2, % Metamodel of target model - M1, % Source model - M2 % Target model -) :- - conforms(M1, MM1), - recardObject(MM1, MM2, M1, M2), - conforms(M2, MM2). - -% Per-object logic -recardObject(MM1, MM2, M1, M2) :- - lookup(class, M1, ClassN), - graphToList(M1, L1, Q), - map(recardMember(MM1, MM2, ClassN), L1, L2), - apply(Q, [L2, M2]). - -% Per-member logic -recardMember(_, _, ClassN, (class, ClassN), (class, ClassN)). -recardMember(MM1, MM2, ClassN, KV1, KV2) :- - KV1 \= (class,ClassN), - KV1 = (MemberN, V1), - lookupMember(ClassN, MemberN, MM1, Member1), - lookupMember(ClassN, MemberN, MM2, Member2), - lookup(class, Member1, Kind), - lookup(class, Member2, Kind), - lookup(cardinality, Member1, Card1), - lookup(cardinality, Member2, Card2), - recardValue(MM1, MM2, Kind, Card1, Card2, V1, V2), - KV2 = (MemberN, V2). - -% required to required -recardValue(MM1, MM2, Kind, Card, Card, V1, V2) :- - lookup(class, Card, one), - recardValue(MM1, MM2, Kind, V1, V2). - -% option to option -recardValue(MM1, MM2, Kind, Card, Card, V1, V2) :- - lookup(class, Card, option), - map(recardValue(MM1, MM2, Kind), V1, V2). - -% star to star -recardValue(MM1, MM2, Kind, Card, Card, V1, V2) :- - lookup(class, Card, star), - map(recardValue(MM1, MM2, Kind), V1, V2). - -% required to optional or many -recardValue(MM1, MM2, Kind, Card1, Card2, V1, [V2]) :- - lookup(class, Card1, one), - lookup(class, Card2, ClassN), - member(ClassN, [option, star]), - recardValue(MM1, MM2, Kind, V1, V2). - -% optional or many to required -recardValue(MM1, MM2, Kind, Card1, Card2, V1, V2) :- - lookup(class, Card1, ClassN), - member(ClassN, [option, star]), - lookup(class, Card2, one), - map(recardValue(MM1, MM2, Kind), V1, [V2]). - -% Recurse into parts -recardValue(MM1, MM2, part, M1, M2) :- - recardObject(MM1, MM2, M1, M2). - -% Preserve references, as is -recardValue(_, _, reference, R, R). - -% Preserve values, as is -recardValue(_, _, value, V, V). diff --git a/languages/mml/relax-cardinality.pro b/languages/mml/relax-cardinality.pro deleted file mode 100644 index 8eef65d..0000000 --- a/languages/mml/relax-cardinality.pro +++ /dev/null @@ -1,8 +0,0 @@ -% Turn all required members into optional members -relaxMm(MM1, MM2) :- - topdownGraph(relaxOne, MM1, MM2). - -% Cardinality-level helper -relaxOne(X, Y) :- - lookup(class, X, one), - update(class, option, X, Y). diff --git a/languages/mml/subclass.pro b/languages/mml/subclass.pro deleted file mode 100644 index b9e3dbf..0000000 --- a/languages/mml/subclass.pro +++ /dev/null @@ -1,20 +0,0 @@ -% Subclassing is reflective -subclassOf(_, N, N). - -% Subclassing considers super -subclassOf(MM, N1, N2) :- - N1 \= N2, - lookupClass(N1, MM, C), - lookup(super, C, [#Super]), - getObject(MM, Super, O), - lookup(name, O, N3), - subclassOf(MM, N3, N2). - -% Test for specific class -instanceOf(Class, O) :- - lookup(class, O, Class). - -% Test for specific class or subclasses thereof -instanceOf(MM, Class1, O) :- - lookup(class, O, Class2), - subclassOf(MM, Class2, Class1). diff --git a/languages/mml/term-chase.pro b/languages/mml/term-chase.pro deleted file mode 100644 index 4384907..0000000 --- a/languages/mml/term-chase.pro +++ /dev/null @@ -1,8 +0,0 @@ -% End of chasing -chaseMembers(_, [], []). - -% Chase along "super" -chaseMembers(Classifiers, [Name], Members3) :- - member(class(_, Name, Super, Members1), Classifiers), - chaseMembers(Classifiers, Super, Members2), - append(Members1, Members2, Members3). diff --git a/languages/mml/term-to-graph.pro b/languages/mml/term-to-graph.pro deleted file mode 100644 index e636f44..0000000 --- a/languages/mml/term-to-graph.pro +++ /dev/null @@ -1,47 +0,0 @@ -metamodelToGraph( - (Name, Ts), - G -) :- - map(classifierToGraph, Ts, Gs), - G = { - class : metamodel, - name : Name, - classifiers : Gs - }, - require( - illFormedGraph, - graph(G)). - -classifierToGraph( - datatype(Name), - Name & { - class : datatype, - name : Name - } -). - -classifierToGraph( - class(Abstr, Name, SuperT, Ts), - Name & { - class : class, - name : Name, - abstract : Abstr, - super : SuperG, - members : Gs - } -) :- - superToGraph(SuperT, SuperG), - map(memberToGraph, Ts, Gs). - -superToGraph([], []). -superToGraph([Name], [#Name]). - -memberToGraph( - (Kind, Name, Type, Card), - { - class : Kind, - name : Name, - type : # Type, - cardinality : { class : Card } - } -). diff --git a/languages/mml/tests/.ueber b/languages/mml/tests/.ueber deleted file mode 100644 index 6521e9c..0000000 --- a/languages/mml/tests/.ueber +++ /dev/null @@ -1,8 +0,0 @@ -[ - - elementOf('mm1.graph', mml(graph(term))), - elementOf('mm2.graph', mml(graph(term))), - elementOf('mm3.graph', mml(graph(term))), - elementOf('mm4.graph', mml(graph(term))) - -]. diff --git a/languages/mml/tests/mm1.graph b/languages/mml/tests/mm1.graph deleted file mode 100644 index 335bbd4..0000000 --- a/languages/mml/tests/mm1.graph +++ /dev/null @@ -1,6 +0,0 @@ -{ - class : metamodel, - name : emptyMetamodel, - classifiers : [ - ] -}. diff --git a/languages/mml/tests/mm2.graph b/languages/mml/tests/mm2.graph deleted file mode 100644 index 0d48620..0000000 --- a/languages/mml/tests/mm2.graph +++ /dev/null @@ -1,13 +0,0 @@ -{ - class : metamodel, - name : singleClass, - classifiers : [ - { - class : class, - name : aClass, - abstract : false, - super : [], - members : [] - } - ] -}. diff --git a/languages/mml/tests/mm3.graph b/languages/mml/tests/mm3.graph deleted file mode 100644 index a14f0eb..0000000 --- a/languages/mml/tests/mm3.graph +++ /dev/null @@ -1,10 +0,0 @@ -{ - class : metamodel, - name : singleDatatype, - classifiers : [ - { - class : datatype, - name : atom - } - ] -}. diff --git a/languages/mml/tests/mm4.graph b/languages/mml/tests/mm4.graph deleted file mode 100644 index 1f029cd..0000000 --- a/languages/mml/tests/mm4.graph +++ /dev/null @@ -1,25 +0,0 @@ -{ - class : metamodel, - name : aValue, - classifiers : [ - { - class : class, - name : aClass, - abstract : false, - super : [], - members : [ - { - class : value, - name : aValue, - type : #atom, - cardinality : { class : one } - } - ] - }, - atom & - { - class : datatype, - name : atom - } - ] -}. diff --git a/languages/mml/to-ddl/.ueber b/languages/mml/to-ddl/.ueber deleted file mode 100644 index 694889a..0000000 --- a/languages/mml/to-ddl/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ -]. - diff --git a/languages/mml/to-ddl/class-to-table.pro b/languages/mml/to-ddl/class-to-table.pro deleted file mode 100644 index 988d422..0000000 --- a/languages/mml/to-ddl/class-to-table.pro +++ /dev/null @@ -1,25 +0,0 @@ -% Map each class to a table -classToTable( - - class( - false, % Map concrete classes, only - Name, - [], % Map non-extended classes, only - Members), - - [ (Name, - [ PrimaryKey % Standard column for primary key - | Columns % Columns for single-valued members - ] ) ] ) - - :- - PrimaryKey = ( - objectId, % Standardized name of column - integer, % Standardized primary key type - [notNull, primaryKey] % SQL DDL modifiers - ), - map(singleToColumn, Members, Columnss), - concat(Columnss, Columns). - -% Skip datatypes -classToTable(datatype(_), []). diff --git a/languages/mml/to-ddl/classes-to-tables.pro b/languages/mml/to-ddl/classes-to-tables.pro deleted file mode 100644 index 40660d6..0000000 --- a/languages/mml/to-ddl/classes-to-tables.pro +++ /dev/null @@ -1,8 +0,0 @@ -% Map classes to tables -classesToTables((_, Classifiers), Tables3) :- - map(classToTable, Classifiers, Tabless1), - concat(Tabless1, Tables1), - map(multisToTables, Classifiers, Tabless2), - concat(Tabless2, Tables2), - append(Tables1, Tables2, Tables3). - diff --git a/languages/mml/to-ddl/mappable.pro b/languages/mml/to-ddl/mappable.pro deleted file mode 100644 index 8623d42..0000000 --- a/languages/mml/to-ddl/mappable.pro +++ /dev/null @@ -1,22 +0,0 @@ -% Simplicity of metamodels -simpleMetamodel((_, Classifiers)) :- - map(simpleClassifier, Classifiers). - -% Simplicity of classes -simpleClassifier( - class( - false, % Concrete classes, only - Name, - [], % Classes without super, only - _ % No constraints on members - )) - :- - \+ datatype(Name). - -% Simplicity of datatypes -simpleClassifier(datatype(X)) :- - datatype(X). - -% All known datatypes -datatype(atom). -datatype(integer). diff --git a/languages/mml/to-ddl/multi-to-table.pro b/languages/mml/to-ddl/multi-to-table.pro deleted file mode 100644 index 222954f..0000000 --- a/languages/mml/to-ddl/multi-to-table.pro +++ /dev/null @@ -1,30 +0,0 @@ -% Map multi-valued members to tables -multisToTables( - class(false, Name, [], Members), - Tables) - :- - map(multiToTable(Name), Members, Tabless), - concat(Tabless, Tables). - -% Skip datatypes -multisToTables(datatype(_), []). - -% Map multi-valued member to a designated table -multiToTable( - Class, % Class containing the multi-valued member - (Kind, Member, Type, star), % The multi-valued member - [(Table, [From, To])]) % The relationship table - :- - atom_concat([Class, '_', Member], Table), - downcase_atom(Class, LowerCase), - atom_concat([LowerCase, 'Id'], Column), - From = ( - Column, % Synthesized column name - integer, % Type for SQL keys - [notNull, foreignKey(Class, objectId)] - ), - singleToColumn((Kind, Member, Type, one), [To]). - -% Skip single-valued attribute here -multiToTable(_, (_, _, _, Cardinality), []) :- - member(Cardinality, [one, option]). diff --git a/languages/mml/to-ddl/single-to-column.pro b/languages/mml/to-ddl/single-to-column.pro deleted file mode 100644 index 2a0336d..0000000 --- a/languages/mml/to-ddl/single-to-column.pro +++ /dev/null @@ -1,31 +0,0 @@ -% Map value members -singleToColumn( - (value, Name, Type, Cardinality), - [(Name, SqlType, Clauses)]) - :- - singleCardinality(Cardinality, Clauses), - datatypeToSql(Type, SqlType). - -% Map non-value members -singleToColumn( - (Kind, Name, Type, Cardinality), - [(Name, integer, Clauses2)]) - :- - member(Kind, [part, reference]), - singleCardinality(Cardinality, Clauses1), - append(Clauses1, [foreignKey(Type, objectId)], Clauses2). - -% Skip star cardinality here -singleToColumn((_, _, _, star), []). - -% NOT NULL for cardinality "one" -singleCardinality(one, [notNull]). - -% no NOT NULL for cardinality "option" -singleCardinality(option, []). - -% Map String (atom) to VARCHAR(42) -datatypeToSql(atom, varchar(42)). - -% Map integer to INTEGER -datatypeToSql(integer, integer). diff --git a/languages/ppl/.ueber b/languages/ppl/.ueber deleted file mode 100644 index 5716851..0000000 --- a/languages/ppl/.ueber +++ /dev/null @@ -1,3 +0,0 @@ -[ - macro(eslSyntax(ppl)) -]. diff --git a/languages/ppl/as.esl b/languages/ppl/as.esl deleted file mode 100644 index bf956e1..0000000 --- a/languages/ppl/as.esl +++ /dev/null @@ -1,9 +0,0 @@ -symbol empty : -> box ; -symbol text : atom -> box ; -symbol number : number -> box ; -symbol hbox : box x box -> box ; -symbol hlist : box* -> box ; -symbol hseplist : box x box* -> box ; -symbol vbox : box x box -> box ; -symbol vlist : box* -> box ; -symbol indent : box -> box ; diff --git a/languages/ppl/as.term b/languages/ppl/as.term deleted file mode 100644 index 7840d30..0000000 --- a/languages/ppl/as.term +++ /dev/null @@ -1 +0,0 @@ -[symbol(empty,[],box),symbol(text,[atom],box),symbol(number,[number],box),symbol(hbox,[sort(box),sort(box)],box),symbol(hlist,[star(sort(box))],box),symbol(hseplist,[sort(box),star(sort(box))],box),symbol(vbox,[sort(box),sort(box)],box),symbol(vlist,[star(sort(box))],box),symbol(indent,[sort(box)],box)]. \ No newline at end of file diff --git a/languages/ppl/eval.pro b/languages/ppl/eval.pro deleted file mode 100644 index 008f30f..0000000 --- a/languages/ppl/eval.pro +++ /dev/null @@ -1 +0,0 @@ -:- multifile ppEval/2. diff --git a/languages/ppl/eval/.ueber b/languages/ppl/eval/.ueber deleted file mode 100644 index 57afcca..0000000 --- a/languages/ppl/eval/.ueber +++ /dev/null @@ -1 +0,0 @@ -[]. diff --git a/languages/ppl/eval/empty.pro b/languages/ppl/eval/empty.pro deleted file mode 100644 index 3c2def7..0000000 --- a/languages/ppl/eval/empty.pro +++ /dev/null @@ -1,2 +0,0 @@ -% Evaluate an empty box -ppEval(empty, []). diff --git a/languages/ppl/eval/hbox.pro b/languages/ppl/eval/hbox.pro deleted file mode 100644 index f94083b..0000000 --- a/languages/ppl/eval/hbox.pro +++ /dev/null @@ -1,22 +0,0 @@ -% Evaluate a horizontal composition -ppEval(hbox(B1, B2), L3) :- - ppEval(B1, L1), - ppEval(B2, L2), - happend(L1, L2, L3). - -% Horizontal composition of boxes (consisting of many lines) -happend(L1, L2, L3) :- - map(length, L1, Lens), - foldr(max, 0, Lens, Len), - repeat(0' , Len, Spaces), - happend(Spaces, L1, L2, L3). - -% Helper for happend/3 -happend(_, [], [], []). -happend(Spaces, [H1|T1], [H2|T2], [H3|T3]) :- - append(H1, H2, H3), - happend(Spaces, T1, T2, T3). -happend(_, [H1|T1], [], [H1|T1]). -happend(Spaces, [], [H2|T2], [H3|T3]) :- - append(Spaces, H2, H3), - happend(Spaces, [], T2, T3). diff --git a/languages/ppl/eval/hlist.pro b/languages/ppl/eval/hlist.pro deleted file mode 100644 index 27e8514..0000000 --- a/languages/ppl/eval/hlist.pro +++ /dev/null @@ -1,4 +0,0 @@ -% Vector form of horizontal composition -ppEval(hlist(Bs), L) :- - map(ppEval, Bs, Ls), - foldr(happend, [], Ls, L). diff --git a/languages/ppl/eval/hseplist.pro b/languages/ppl/eval/hseplist.pro deleted file mode 100644 index 431b09e..0000000 --- a/languages/ppl/eval/hseplist.pro +++ /dev/null @@ -1,5 +0,0 @@ -% hlist with separator -ppEval(hseplist(B, Bs1), L) :- - intersperse(B, Bs1, Bs2), - map(ppEval, Bs2, Ls), - foldr(happend, [], Ls, L). diff --git a/languages/ppl/eval/indent.pro b/languages/ppl/eval/indent.pro deleted file mode 100644 index 36666cd..0000000 --- a/languages/ppl/eval/indent.pro +++ /dev/null @@ -1,3 +0,0 @@ -% Apply indentation -ppEval(indent(B), L) :- - ppEval(hbox(text(' '), B), L). diff --git a/languages/ppl/eval/number.pro b/languages/ppl/eval/number.pro deleted file mode 100644 index d7b390b..0000000 --- a/languages/ppl/eval/number.pro +++ /dev/null @@ -1,3 +0,0 @@ -% Evaluate a text box -ppEval(number(A), [S]) :- - atom_codes(A, S). diff --git a/languages/ppl/eval/text.pro b/languages/ppl/eval/text.pro deleted file mode 100644 index df32799..0000000 --- a/languages/ppl/eval/text.pro +++ /dev/null @@ -1,3 +0,0 @@ -% Evaluate a text box -ppEval(text(A), [S]) :- - atom_codes(A, S). diff --git a/languages/ppl/eval/vbox.pro b/languages/ppl/eval/vbox.pro deleted file mode 100644 index e65ed5c..0000000 --- a/languages/ppl/eval/vbox.pro +++ /dev/null @@ -1,5 +0,0 @@ -% Evaluate a vertical composition -ppEval(vbox(B1, B2), L3) :- - ppEval(B1, L1), - ppEval(B2, L2), - append(L1, L2, L3). diff --git a/languages/ppl/eval/vlist.pro b/languages/ppl/eval/vlist.pro deleted file mode 100644 index b2811ea..0000000 --- a/languages/ppl/eval/vlist.pro +++ /dev/null @@ -1,4 +0,0 @@ -% Vector form of vertical composition -ppEval(vlist(Bs), L) :- - map(ppEval, Bs, Ls), - foldr(append, [], Ls, L). diff --git a/languages/ppl/tests/.ueber b/languages/ppl/tests/.ueber deleted file mode 100644 index cb053bb..0000000 --- a/languages/ppl/tests/.ueber +++ /dev/null @@ -1,26 +0,0 @@ -[ - % Samples of PPL - elementOf('text.ppl', ppl(term)), - elementOf('vbox.ppl', ppl(term)), - elementOf('vlist.ppl', ppl(term)), - elementOf('hbox.ppl', ppl(term)), - elementOf('hlist.ppl', ppl(term)), - elementOf('hseplist.ppl', ppl(term)), - elementOf('indent.ppl', ppl(term)), - - % Pretty printing baselines - elementOf('text.txt', text), - elementOf('vbox.txt', text), - elementOf('hbox.txt', text), - elementOf('hseplist.txt', text), - elementOf('indent.txt', text), - - % Applications of the evaluator - mapsTo(pp, ['text.ppl'], ['text.txt']), - mapsTo(pp, ['vbox.ppl'], ['vbox.txt']), - mapsTo(pp, ['vlist.ppl'], ['vbox.txt']), - mapsTo(pp, ['hbox.ppl'], ['hbox.txt']), - mapsTo(pp, ['hlist.ppl'], ['hbox.txt']), - mapsTo(pp, ['hseplist.ppl'], ['hseplist.txt']), - mapsTo(pp, ['indent.ppl'], ['indent.txt']) -]. diff --git a/languages/ppl/tests/hbox.ppl b/languages/ppl/tests/hbox.ppl deleted file mode 100644 index ce1b69d..0000000 --- a/languages/ppl/tests/hbox.ppl +++ /dev/null @@ -1 +0,0 @@ -hbox(text('a'), hbox(text(' '), text('b'))). diff --git a/languages/ppl/tests/hbox.txt b/languages/ppl/tests/hbox.txt deleted file mode 100644 index b2901ea..0000000 --- a/languages/ppl/tests/hbox.txt +++ /dev/null @@ -1 +0,0 @@ -a b diff --git a/languages/ppl/tests/hlist.ppl b/languages/ppl/tests/hlist.ppl deleted file mode 100644 index a864eb5..0000000 --- a/languages/ppl/tests/hlist.ppl +++ /dev/null @@ -1 +0,0 @@ -hlist([text('a'), text(' '), text('b')]). diff --git a/languages/ppl/tests/hseplist.ppl b/languages/ppl/tests/hseplist.ppl deleted file mode 100644 index 7c5fe30..0000000 --- a/languages/ppl/tests/hseplist.ppl +++ /dev/null @@ -1,2 +0,0 @@ -hseplist(text(', '), [text(a), text(b), text(c)]). - diff --git a/languages/ppl/tests/hseplist.txt b/languages/ppl/tests/hseplist.txt deleted file mode 100644 index d901c21..0000000 --- a/languages/ppl/tests/hseplist.txt +++ /dev/null @@ -1 +0,0 @@ -a, b, c diff --git a/languages/ppl/tests/indent.ppl b/languages/ppl/tests/indent.ppl deleted file mode 100644 index bbe5ed6..0000000 --- a/languages/ppl/tests/indent.ppl +++ /dev/null @@ -1 +0,0 @@ -indent(indent(text('42'))). diff --git a/languages/ppl/tests/indent.txt b/languages/ppl/tests/indent.txt deleted file mode 100644 index fab6ed5..0000000 --- a/languages/ppl/tests/indent.txt +++ /dev/null @@ -1 +0,0 @@ - 42 diff --git a/languages/ppl/tests/text.ppl b/languages/ppl/tests/text.ppl deleted file mode 100644 index 9733a72..0000000 --- a/languages/ppl/tests/text.ppl +++ /dev/null @@ -1,2 +0,0 @@ -text('text'). - diff --git a/languages/ppl/tests/text.txt b/languages/ppl/tests/text.txt deleted file mode 100644 index 8e27be7..0000000 --- a/languages/ppl/tests/text.txt +++ /dev/null @@ -1 +0,0 @@ -text diff --git a/languages/ppl/tests/vbox.ppl b/languages/ppl/tests/vbox.ppl deleted file mode 100644 index e200932..0000000 --- a/languages/ppl/tests/vbox.ppl +++ /dev/null @@ -1 +0,0 @@ -vbox(text('a'), vbox(text('b'), text('c'))). diff --git a/languages/ppl/tests/vbox.txt b/languages/ppl/tests/vbox.txt deleted file mode 100644 index de98044..0000000 --- a/languages/ppl/tests/vbox.txt +++ /dev/null @@ -1,3 +0,0 @@ -a -b -c diff --git a/languages/ppl/tests/vlist.ppl b/languages/ppl/tests/vlist.ppl deleted file mode 100644 index 1abba70..0000000 --- a/languages/ppl/tests/vlist.ppl +++ /dev/null @@ -1 +0,0 @@ -vlist([text('a'), text('b'), text('c')]). diff --git a/languages/ppl/to-string.pro b/languages/ppl/to-string.pro deleted file mode 100644 index 48060cf..0000000 --- a/languages/ppl/to-string.pro +++ /dev/null @@ -1,8 +0,0 @@ -% Top-level predicate -pp(Box, S) :- - ppEval(Box, L), - with_output_to(codes(S), map(ppLine, L)). - -% Helper for "printing" lines (strings) -ppLine(S) :- - format('~s~n', [S]). diff --git a/languages/text/.ueber b/languages/text/.ueber deleted file mode 100644 index 3a42495..0000000 --- a/languages/text/.ueber +++ /dev/null @@ -1,5 +0,0 @@ -[ - language(text), - membership(text, succeed, []), - equivalence(text, textEq, []) -]. diff --git a/languages/text/eq.pro b/languages/text/eq.pro deleted file mode 100644 index 8e77d3b..0000000 --- a/languages/text/eq.pro +++ /dev/null @@ -1,8 +0,0 @@ -% Equivalence of text encoded as lists codes -textEq(X,X). -textEq(X,Y) :- - length(X, L1), - length(Y, L2), - % Ignore difference regarding final "newline" - ( L1 is L2 + 1, append(Y, [10], X) - ; L2 is L1 + 1, append(X, [10], Y) ). diff --git a/languages/ueber/.ueber b/languages/ueber/.ueber deleted file mode 100644 index 4bd89b6..0000000 --- a/languages/ueber/.ueber +++ /dev/null @@ -1,4 +0,0 @@ -[ - macro(eslSyntax(ueber)), - elementOf('.ueber', ueber(term)) -]. diff --git a/languages/ueber/as.esl b/languages/ueber/as.esl deleted file mode 100644 index 7f5f024..0000000 --- a/languages/ueber/as.esl +++ /dev/null @@ -1,12 +0,0 @@ -type ueber = udecl* ; -symbol language : lang -> udecl ; -symbol membership : lang x goal x file* -> udecl ; -symbol equivalence : lang x goal x file* -> udecl ; -symbol function : func x lang+ x lang+ x goal x file* -> udecl ; -symbol elementOf : file x lang -> udecl ; -symbol mapsTo : func x file+ x file+ -> udecl ; -symbol macro : goal -> udecl ; -type file = atom ; -type func = atom ; -type lang = term ; -type goal = term ; diff --git a/languages/ueber/as.term b/languages/ueber/as.term deleted file mode 100644 index a19c00e..0000000 --- a/languages/ueber/as.term +++ /dev/null @@ -1 +0,0 @@ -[type(ueber,star(sort(udecl))),symbol(language,[sort(lang)],udecl),symbol(membership,[sort(lang),sort(goal),star(sort(file))],udecl),symbol(equivalence,[sort(lang),sort(goal),star(sort(file))],udecl),symbol(function,[sort(func),plus(sort(lang)),plus(sort(lang)),sort(goal),star(sort(file))],udecl),symbol(elementOf,[sort(file),sort(lang)],udecl),symbol(mapsTo,[sort(func),plus(sort(file)),plus(sort(file))],udecl),symbol(macro,[sort(goal)],udecl),type(file,atom),type(func,atom),type(lang,term),type(goal,term)]. diff --git a/languages/ueber/evaluator.pro b/languages/ueber/evaluator.pro deleted file mode 100644 index 64cbd7e..0000000 --- a/languages/ueber/evaluator.pro +++ /dev/null @@ -1,192 +0,0 @@ -% Run the megamodel -run :- - format('~nMegamodel execution:~n', []), - findall(D, declaration(D), L), - initTesting, - map(evaluate, L), - listing(problem/1), - ( problem(_) -> abort; true ). - -:- dynamic problem/1. - -% Report a problem -report(X) :- - problem(X) -> - true - ; assertz(problem(X)). - -% Evaluate a udecl -evaluate(D) :- - format(' * ~q: ',[D]), - once( - ( evaluate_(D) -> - format('OK~n',[]) - ; - format('FAIL~n',[]), - report(failedDeclaration(D)) - ) - ). - -evaluate_(language(_)). - -evaluate_(membership(Lang, _, _)) :- - requireLanguage(Lang). - -evaluate_(equivalence(Lang, _, _)) :- - requireLanguage(Lang). - -evaluate_(function(_, LangsIn, LangsOut, _, _)) :- - map(requireLanguage, LangsIn), - map(requireLanguage, LangsOut). - -evaluate_(elementOf(File, Lang)) :- - elementOf(File, Lang). - -% Apply a declared function -evaluate_(mapsTo(Func, FilesIn, FilesOut)) :- - declaration(function(Func, _, _, _, _)), - ( ( - declaration(function(Func, LangsIn, LangsOut, Pred1, ArgsAbs)), - map(getLanguages, FilesIn, LangsIn), - map(getLanguages, FilesOut, LangsOut) - ) -> - Pred1 =.. [Sym|PredArgs], - append(PredArgs, ArgsAbs, AllArgs), - Pred2 =.. [Sym|AllArgs], - mapsTo(Pred2, FilesIn, FilesOut) - ; - report(missingOverload(Func, FilesIn, FilesOut)) - ). - -% Apply a predicate as a function -evaluate_(mapsTo(Func, FilesIn, FilesOut)) :- - \+ declaration(function(Func, _, _, _, _)), - mapsTo(Func, FilesIn, FilesOut). - -evaluate_(not(X)) :- - not(evaluate_(X)). - -% Predicate for element-of test -elementOf(File, Lang) :- - findall( - (Pred, Args1), - declaration(membership(Lang, Pred, Args1)), - Preds), - ( Preds == [] -> - report(missingLanguage(Lang)) - ; - readFile(File, [Content]), - map(membership(Content), Preds) - ). - -% There may be multiple membership predicates -membership(Content, (Pred, Args1)) :- - append(Args1, [Content], Args2), - once(apply(Pred, Args2)). - -% Predicate application to files -mapsTo(Pred, FilesIn, FilesOut) :- - map(readFileStrictly, FilesIn, ContentsIn), - map(readFile, FilesOut, Expected), - map(getLanguage, FilesOut, LangsOut), - map(succeed, Expected, Actual), - append(ContentsIn, Actual, Args), - zip(FilesOut, LangsOut, Expected, Actual, ZArgs), - require( - mappable(Pred, FilesIn), - once(apply(Pred, Args)) - ), - map(equiv, ZArgs). - -% Fail for missing file -readFileStrictly(File, Content) :- - readFile(File, [Content]). - -% Read file, if present -readFile(File, MaybeContent) :- - exists_file(File) -> - ( ( - getLanguage(File, Lang), - baseLanguage(Lang, Base) - ) -> - ( Base == text, readTextFile(File, Content) - ; Base == term, readTermFile(File, Content) - ), - MaybeContent = [Content] - ; - report(obscureFile(File)), - MaybeContent = [] - ) - ; - report(missingFile(File)), - MaybeContent = []. - -% Write file, if present -writeFile(File, Content) :- - require( - languageOf(File), - getLanguage(File, Lang) - ), - baseLanguage(Lang, Base), - ( Base == text, writeTextFile(File, Content) - ; Base == term, writeTermFile(File, Content) - ). - -requireLanguage(Lang) :- - require( - declarationOfLanguage(Lang), - declaration(language(Lang)) - ). - -% A file's language is derived from not/elementOf declarations -getLanguage(File, Lang) :- - declaration(elementOf(File, Lang)) - ; declaration(not(elementOf(File, Lang))). - -% The immediate language and its supers for a file -getLanguages(File, Lang2) :- - getLanguage(File, Lang1), - subLanguageOf(Lang1, Lang2). - -% Establish equivalence between 'expected' and 'actual' -equiv((File, Lang, [Expected], Actual)) :- - ( declaration(equivalence(Lang, Pred, Args1)) -> - true - ; Pred = equivDefault(Lang), Args1 = [] - ), - append(Args1, [Expected, Actual], Args2), - ( apply(Pred, Args2) -> - true - ; - current_prolog_flag(argv, Argv), - ( member(override, Argv) -> - writeFile(File, Actual) - ; - error(equiv(File, Lang, Expected, Actual)) - ) - ). - -% Force creation of missing baseline -equiv((File, _, [], Content)) :- - current_prolog_flag(argv, Argv), - member(create, Argv), - writeFile(File, Content). - -% Slightly flexible equality -equivDefault(_, X, X). -equivDefault(Lang, X, Y) :- - baseLanguage(Lang, text), - ( append(X, [10], Y) ; append(Y, [10], X) ). - -% Determine 'text' or 'term' as the base language of any language -baseLanguage(text, text). -baseLanguage(term, term). -baseLanguage(X, Z) :- - X =.. [_,Y], - baseLanguage(Y, Z). - -% Sub-languages of languages -subLanguageOf(Lang, Lang). -subLanguageOf(Sub1, Super) :- - Sub1 =.. [_,Sub2], - subLanguageOf(Sub2, Super). diff --git a/languages/ueber/macros/README.md b/languages/ueber/macros/README.md deleted file mode 100644 index dbae67c..0000000 --- a/languages/ueber/macros/README.md +++ /dev/null @@ -1,3 +0,0 @@ -There is no .ueber file here. -These macros are loaded explicitly by prelude/ueber.pro. -This is necessary to have them available while preprocessing. diff --git a/languages/ueber/macros/bgl.pro b/languages/ueber/macros/bgl.pro deleted file mode 100644 index facd386..0000000 --- a/languages/ueber/macros/bgl.pro +++ /dev/null @@ -1,59 +0,0 @@ -% Pattern of a BGL- and BSL-based concrete syntax definition -bglSyntax(Lang) :- - - % Declare languages - TextLang =.. [Lang, text], - TokenLang =.. [Lang, tokens(term)], - PTreeLang =.. [Lang, ptree(term)], - TermLang =.. [Lang, term], - declare(language(TextLang)), - declare(language(TokenLang)), - declare(language(PTreeLang)), - declare(language(TermLang)), - - % Syntax definition artifacts - declare(elementOf('cs.bgl', bgl(text))), - declare(elementOf('cs.term', bgl(term))), - declare(elementOf('as.bsl', bsl(text))), - declare(elementOf('as.term', bsl(term))), - declare(mapsTo(parser, ['cs.bgl'], ['cs.term'])), - declare(mapsTo(parser, ['as.bsl'], ['as.term'])), - declare(mapsTo(projection, ['cs.term'], ['as.term'])), - - % Synthesize scanner predicate - atom_concat(Lang, 'Scanner', Scanner), - - % Declare membership tests - declare(membership(TextLang, bglTopDownAcceptor(Scanner), ['cs.term'])), - declare(membership(TokenLang, bglTopDownAcceptor, ['cs.term'])), - declare(membership(PTreeLang, succeed, [])), % See implosion/explosion - declare(membership(TermLang, bslChecker, ['as.term'])), - - % Declare scanner, parsers, unparsers, imploder, and exploder - declare(function(scanner, [TextLang], [TokenLang], Scanner, [])), - declare(function(parser, [TokenLang], [TermLang], bglTopDownParser, ['cs.term'])), - declare(function(parser, [TextLang], [TermLang], bglTopDownParser(Scanner), ['cs.term'])), - declare(function(unparser, [PTreeLang], [TokenLang], bglTreeToTokens, [])), - declare(function(unparser, [PTreeLang], [TextLang], bglTreeToText, [])), - declare(function(imploder, [PTreeLang], [TermLang], bglImploder, [])), - declare(function(exploder, [TermLang], [PTreeLang], bglExploder, ['cs.term'])). - - -% Pattern of a BGL-based sample -bglSample(Lang) :- - TextLang =.. [Lang, text], - TokenLang =.. [Lang, tokens(term)], - PTreeLang =.. [Lang, ptree(term)], - TermLang =.. [Lang, term], - atom_concat('sample.', Lang, Sample), - declare(elementOf(Sample, TextLang)), - declare(elementOf('sample.tokens', TokenLang)), - declare(elementOf('sample.ptree', PTreeLang)), - declare(elementOf('sample.term', TermLang)), - declare(mapsTo(scanner, [Sample], ['sample.tokens'])), - declare(mapsTo(parser, ['sample.tokens'], ['sample.term'])), - declare(mapsTo(parser, [Sample], ['sample.term'])), - declare(mapsTo(unparser, ['sample.ptree'], ['sample.tokens'])), - declare(mapsTo(unparser, ['sample.ptree'], [Sample])), - declare(mapsTo(imploder, ['sample.ptree'], ['sample.term'])), - declare(mapsTo(exploder, ['sample.term'], ['sample.ptree'])). diff --git a/languages/ueber/macros/egl.pro b/languages/ueber/macros/egl.pro deleted file mode 100644 index 2dd8662..0000000 --- a/languages/ueber/macros/egl.pro +++ /dev/null @@ -1,16 +0,0 @@ -% Pattern of a EGL-based concrete syntax definition -eglSyntax(Lang) :- - TextLang =.. [Lang, text], - TermLang =.. [Lang, term], - declare(language(TextLang)), - declare(language(TermLang)), - Files = ['cs.term', 'ls.term'], - atom_concat(Lang, 'Mapping', Mapping), - declare(membership(TextLang, eglAcceptor(Mapping), Files)), - declare(function(parser, [TextLang], [TermLang], eglParser(Mapping), Files)), - declare(elementOf('cs.egl', egl(text))), - declare(elementOf('cs.term', egl(term))), - declare(elementOf('ls.egl', egl(text))), - declare(elementOf('ls.term', egl(term))), - declare(mapsTo(parser, ['cs.egl'], ['cs.term'])), - declare(mapsTo(parser, ['ls.egl'], ['ls.term'])). diff --git a/languages/ueber/macros/esl.pro b/languages/ueber/macros/esl.pro deleted file mode 100644 index 46fb46a..0000000 --- a/languages/ueber/macros/esl.pro +++ /dev/null @@ -1,8 +0,0 @@ -% Pattern of an ESL-based abstract syntax definition -eslSyntax(Lang) :- - TermLang =.. [Lang, term], - declare(language(TermLang)), - declare(elementOf('as.esl', esl(text))), - declare(elementOf('as.term', esl(term))), - declare(mapsTo(parser, ['as.esl'], ['as.term'])), - declare(membership(TermLang, eslLanguage, ['as.term'])). diff --git a/languages/ueber/macros/mml.pro b/languages/ueber/macros/mml.pro deleted file mode 100644 index 2783713..0000000 --- a/languages/ueber/macros/mml.pro +++ /dev/null @@ -1,21 +0,0 @@ -% Pattern of a MML-based metamodel -mmlSyntax(Lang) :- - GraphLang =.. [Lang, graph(term)], - declare(language(GraphLang)), - declare(elementOf('mm.mml', mml(text))), - declare(elementOf('mm.term', mml(term))), - declare(elementOf('mm.graph', mml(graph(term)))), - declare(mapsTo(parser, ['mm.mml'], ['mm.term'])), - declare(mapsTo(resolver, ['mm.term'], ['mm.graph'])), - declare(membership(GraphLang, mmlChecker, ['mm.graph'])), - declare(equivalence(GraphLang, graphEq, [])). - -% Pattern of a MML-based sample -mmlSample(Lang, Sample) :- - GraphLang =.. [Lang, graph(term)], - atom_concat(Sample, '.graph', Graph), - declare(elementOf(Graph, GraphLang)). - -% Default for the sample's name -mmlSample(Lang) :- - mmlSample(Lang, sample). diff --git a/languages/ueber/macros/parse.pro b/languages/ueber/macros/parse.pro deleted file mode 100644 index a3f28b6..0000000 --- a/languages/ueber/macros/parse.pro +++ /dev/null @@ -1,20 +0,0 @@ -% Reusable pattern of parsing a file -parse(TextFile) :- - name(TextFile, Str), - append(StemStr, [0'.|LangStr], Str), - \+ member(0'., LangStr), - name(Lang, LangStr), - name(Stem, StemStr), - TextLang =.. [Lang, text], - TermLang =.. [Lang, term], - atom_concat([Stem, '.term'], TermFile), - declare(elementOf(TextFile, TextLang)), - declare(elementOf(TermFile, TermLang)), - declare(mapsTo(parser, [TextFile], [TermFile])). - -% Variation that takes just the language -parse(Lang) :- - name(Lang, Str), - \+ member(0'., Str), - atom_concat('sample.', Lang, TextFile), - parse(TextFile). diff --git a/languages/ueber/macros/ppl.pro b/languages/ueber/macros/ppl.pro deleted file mode 100644 index b3716b1..0000000 --- a/languages/ueber/macros/ppl.pro +++ /dev/null @@ -1,12 +0,0 @@ -% Pattern of a PPL-based sample -pplSample(Lang) :- - TextLang =.. [Lang, text], - TermLang =.. [Lang, term], - atomic_list_concat(['sample.', Lang], TextSample), - declare(elementOf(TextSample, TextLang)), - declare(elementOf('sample.ppl', ppl(term))), - declare(elementOf('sample.term', TermLang)), - atom_concat(Lang, 'Pp', Pp), - declare(mapsTo(Pp, ['sample.term'], ['sample.ppl'])), - declare(mapsTo(pp, ['sample.ppl'], [TextSample])). - diff --git a/logs/.gitignore b/logs/.gitignore deleted file mode 100644 index cfce1ad..0000000 --- a/logs/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -*.log - diff --git a/main.pro b/main.pro deleted file mode 100644 index 4953931..0000000 --- a/main.pro +++ /dev/null @@ -1,15 +0,0 @@ -% Load the prelude of SLEPRO -:- ['prelude/dynamic.pro']. -:- ['prelude/multifile.pro']. -:- ['prelude/data.pro']. -:- ['prelude/higher-order.pro']. -:- ['prelude/io.pro']. -:- ['prelude/test.pro']. -:- ['prelude/scanning.pro']. -:- ['prelude/http.pro']. -:- ['prelude/ueber.pro']. - -% UEBER-based processing of all code -:- init. -:- preprocess(languages), run. -:- halt. diff --git a/prelude/data.pro b/prelude/data.pro deleted file mode 100644 index ca37273..0000000 --- a/prelude/data.pro +++ /dev/null @@ -1,76 +0,0 @@ -% Construct a singleton set -singleton(X, [X]). - -% Equality on sets -setEq(S1, S2) :- - subset(S1, S2), - subset(S2, S1). - -% Convert a list into a tuple -list2tuple(Empty, [], Empty). -list2tuple(_, X, Y) :- - X \= [], - list2tuple_(X, Y). - -list2tuple_([X], X). -list2tuple_([X|Y], (X, Z)) :- - Y \= [], - list2tuple_(Y, Z). - -% Iterate append/3 over a list of lists -concat(Ls, L) :- - foldr(append, [], Ls, L). - -% Append atoms -atom_concat([X], X). -atom_concat([X,Y|T], R) :- atom_concat(X, Y, XY), atom_concat([XY|T], R). - -% Test a term to be a list -list(T) :- is_list(T). - -% Test a term to be an option -option([]). -option([_]). - -% Test a term to be a Boolean -boolean(true). -boolean(false). - -% Test a term to be a tuple -tuple((_, _)). - -% Test a list to be a set -set(List1) :- - is_set(List1). - -% Zip two lists to a list of pairs -zip([], [], []). -zip([H1|T1], [H2|T2], [(H1, H2)|T12]) :- - zip(T1, T2, T12). - -zip([], [], [], []). -zip([H1|T1], [H2|T2], [H3|T3], [(H1, H2, H3)|T123]) :- - zip(T1, T2, T3, T123). - -zip([], [], [], [], []). -zip([H1|T1], [H2|T2], [H3|T3], [H4|T4], [(H1, H2, H3, H4)|T1234]) :- - zip(T1, T2, T3, T4, T1234). - -% Unzip a list of pairs to two lists -unzip(L12, L1, L2) :- zip(L1, L2, L12). - -% Maximum -max(X,Y,Z) :- Z is max(X,Y). - -% Repeat a value a number of times -repeat(_, 0, []). -repeat(X, N, [X|Xs]) :- - N > 0, - M is N - 1, - repeat(X, M, Xs). - -% Intersperse a separator between elements -intersperse(_, [], []). -intersperse(_, [H], [H]). -intersperse(X, [H1,H2|T1], [H1,X|T2]) :- - intersperse(X, [H2|T1], T2). diff --git a/prelude/dynamic.pro b/prelude/dynamic.pro deleted file mode 100644 index 9988358..0000000 --- a/prelude/dynamic.pro +++ /dev/null @@ -1 +0,0 @@ -:- dynamic declaration/1. diff --git a/prelude/higher-order.pro b/prelude/higher-order.pro deleted file mode 100644 index e8fa11a..0000000 --- a/prelude/higher-order.pro +++ /dev/null @@ -1,153 +0,0 @@ -% Success of arity 1 -succeed(_). - -% Success of arity 2 -succeed(_, _). - -% Failure at arity 1 -fail(_) :- fail. - -% Failure at arity 2 -fail(_, _) :- fail. - -% Failure at arity 3 -fail(_, _, _) :- fail. - -% Identity function -id(X,X). - -% Add an argument; do not apply -addArg(P1, X, P2) :- - P1 =.. [F|T1], - append(T1, [X], T2), - P2 =.. [F|T2]. - -% Constant function -const(X,_,X). - -% const/2 applied to id/2 -constid(_, X, X). - -% Skip one argument with a unary predicate -skip(P, _, X) :- apply(P, [X]). - -% Skip one argument with a binary predicate -skip(P, _, X, Y) :- apply(P, [X, Y]). - -% Try an argument predicate; fall back to true in case of failure -try(P) :- - P -> - true - ; true. - -% Try an argument predicate; fall back to true in case of failure -try(P, X) :- - apply(P, [X]) -> - true - ; true. - -% Try an argument predicate; fall back to ID in case of failure -try(P, X, Y) :- - apply(P, [X, Y]) -> - true - ; id(X, Y). - -% Reify success/failure of a goal as a Boolean -toBoolean(G, B) :- - G -> B = true; B = false. - -% All list elements must meet a certain predicate. -map(_, []). -map(G, [H|T]) :- apply(G, [H]), map(G, T). - -% The optional element must meet a certain predicate. -option(_, []). -option(P, [X]) :- apply(P, [X]). - -% Map a function-like predicate over a list -map(_, [], []). -map(P, [H1|T1], [H2|T2]) :- apply(P, [H1, H2]), map(P, T1, T2). - -% Another cardinality for map -map(_, [], [], []). -map(P, [H1|T1], [H2|T2], [H3|T3]) :- apply(P, [H1, H2, H3]), map(P, T1, T2, T3). - -% Apply or map for unary predicate -applyOrMap(P, X) :- - list(X) -> map(P, X); apply(P, [X]). - -% Apply or map for binary predicate -applyOrMap(P, X, Y) :- - list(X) -> map(P, X, Y); apply(P, [X, Y]). - -% Flip two arguments of a predicate -flip(P, A1, A2) :- apply(P, [A2, A1]). - -% EBNF-like sequential composition for accumulating predicates -seq(_, [], X, X). -seq(P, [H|T], X, Z) :- - apply(P, [H, X, Y]), - seq(P, T, Y, Z). - -% EBNF-like "?" for accumulating predicate -option(P, X, Y) :- apply(P, [X, Y]). -option(_, X, X). - -% EBNF-like "+" for accumulating predicate -plus(P, X, Z) :- apply(P, [X, Y]), star(P, Y, Z). - -% EBNF-like "*" for accumulating predicate -star(P, X, Y) :- plus(P, X, Y). -star(_, X, X). - -% Extension of seq/4 to add list construction -seq(_, [], [], X, X). -seq(P, [H1|T1], [H2|T2], X, Z) :- - apply(P, [H1, H2, X, Y]), - seq(P, T1, T2, Y, Z). - -% Extension of option/3 to add list construction -option(P, [H], X, Y) :- apply(P, [H, X, Y]). -option(_, [], X, X). - -% Extension of plus/3 to add list construction -plus(P, [H|T], X, Z) :- apply(P, [H, X, Y]), star(P, T, Y, Z). - -% Extension of star/3 to add list construction -star(P, L, X, Y) :- plus(P, L, X, Y). -star(_, [], X, X). - -% Peek at accumulator -peek(P, X, X) :- apply(P, [X, _]). - -% Negation for accumulators -not(P, X, X) :- \+ peek(P, X, X). - -% Filter a list according to a predicate -filter(_, [], []). -filter(P, [H|T], R) :- - apply(P, [H]) -> - filter(P, T, Q), R = [H|Q] - ; filter(P, T, R). - -% A map that also filters -mapfilter(_, [], []). -mapfilter(P, [H1|T1], L) :- - mapfilter(P, T1, T2), - ( - apply(P, [H1, H2]) -> - L = [H2|T2] - ; L = T2 - ). - -% Left-associative list fold -foldl(_, U, [], U). -foldl(F, U, [H|T], Z) :- - apply(F, [U, H, Y]), - foldl(F, Y, T, Z). - -% Right-associative list fold -foldr(_, X, [], X). -foldr(F, X, [H|T], Z) :- - foldr(F, X, T, Y), - apply(F, [H, Y, Z]). diff --git a/prelude/http.pro b/prelude/http.pro deleted file mode 100644 index 6e26c98..0000000 --- a/prelude/http.pro +++ /dev/null @@ -1,106 +0,0 @@ -% HTTP client/server support - -/* - -Libraries for HTTP client/server support: -http://www.swi-prolog.org/pldoc/package/http.html -http://www.swi-prolog.org/howto/http/HelloText.html - -*/ - -:- use_module(library(http/html_write)). % server -:- use_module(library(http/http_open)). % client -:- use_module(library(http/http_header)). % client -:- use_module(library(http/http_client)). % client -:- use_module(library(http/thread_httpd)). % Web server -:- use_module(library(http/http_dispatch)). % Part of web server -:- use_module(library(http/http_server_files)). % Serve files through the web serve -r -:- use_module(library(thread_pool)). % Thread pool for web server -:- use_module(library(http/json)). % Basics of JSON -:- use_module(library(http/json_convert)). % JSON Conversion -:- use_module(library(http/http_json)). % JSON support for HTTP -% :- use_module(library(http/http_error)). % Debugging - -% Set up locations for file search -% http:location(static, root(static), [ priority(-100) ]). -% user:file_search_path(static, 'static'). - -/* - -Start an HTTP server. -Important: do not start server by a goal clause as in ":- start_http.". -This would put the server into the wrong thread. -Instead start server more like this "swipl -q -t main -f ...". - -*/ - -start_http(Handlers) :- - - % - % Set up a thread pool, if you need one. - % - % thread_pool_create(pool, 2, []), - - % - % Register handlers for web requests - % This should be done (eventually) by concrete services. - % See the "debug" example below. - % -% http_handler(static(.), noindex('static'), []), -% http_handler(static(.), serve_files_in_directory(static), [prefix]), - http_handler(root('debug'), debug_http, []), - Handlers, - - % - % Start server - % - http_server(http_dispatch, [port(4242),workers(2)]). - -/* - -Enter http://localhost:4242/debug -With reverse proxy http://localhost/debug - -*/ - -debug_http(Request) :- - format('Content-type: text/html~n~n', []), - format('~n', []), - format('~n'), - maplist(reqentry,Request), - format('~n
~n'), - format('~n', []). - -reqentry(X) :- - X =.. [Name, Value], - format('~w~w~n', [Name, Value]). - - -/* - -Handle requests until shutdown - -*/ - -service_http(Handlers) :- - current_prolog_flag(argv,Argv), - true(append(_,['--',Log],Argv)), - true(open(Log,write,S,[encoding(utf8)])), - true(assertz(log(S))), - !, - true(start_http(Handlers)), - format(S,'Server started.~n',[]), - flush_output(S), - true(loop_http), - !, - format(S,'Server stopped.~n',[]), - flush_output(S). - -loop_http :- - repeat, - sleep(2), - exists_file(shutdown), - !, - delete_file(shutdown), - http_stop_server(4242, []). diff --git a/prelude/io.pro b/prelude/io.pro deleted file mode 100644 index 4379ce1..0000000 --- a/prelude/io.pro +++ /dev/null @@ -1,28 +0,0 @@ -readTextFile(File, Text) :- - require( - fileExpected(File), - open(File, read, Input, []) - ), - read_stream_to_codes(Input, Text), - close(Input). - -writeTextFile(File, Text) :- - open(File, write, Output, []), - format(Output, '~s', [Text]), - close(Output). - -readTermFile(File, Term) :- - require( - fileExpected(File), - open(File, read, Input, []) - ), - require( - fileWithPrologTermExpected(File), - read(Input, Term) - ), - close(Input). - -writeTermFile(File, Term) :- - open(File, write, Output, []), - format(Output, '~q.', [Term]), - close(Output). diff --git a/prelude/multifile.pro b/prelude/multifile.pro deleted file mode 100644 index 9ec6b92..0000000 --- a/prelude/multifile.pro +++ /dev/null @@ -1,7 +0,0 @@ -% CRUD for dictionaries and graphs -:- multifile permute/2. -:- multifile key/2. -:- multifile lookup/3. -:- multifile add/4. -:- multifile update/4. -:- multifile remove/3. diff --git a/prelude/scanning.pro b/prelude/scanning.pro deleted file mode 100644 index 4c031bd..0000000 --- a/prelude/scanning.pro +++ /dev/null @@ -1,44 +0,0 @@ -% Recognize a token given a list of options -token(L, T, I1, I2) :- - member(T, L), - name(T, S), - append(S, I2, I1). - -% Map string to token sequence -tokens( - TPred, % predicate for invidual tokens - SPred, % predicate for tokens to be skipped - Input, % the input string - Ts % the resulting token sequence - ) :- - tokens_(TPred, SPred, Ts, Input, []). - -% Default for SPred to consume spaces -tokens(TPred, Input, Ts) :- - tokens(TPred, star(char(space)), Input, Ts). - -% Lists of tokens with spaces (possibly) -tokens_(TPred, SPred, [T|Ts], I1, I4) :- - apply(SPred, [I1, I2]), - apply(TPred, [T, I2, I3]), - tokens_(TPred, SPred, Ts, I3, I4). -tokens_(_, SPred, [], I1, I2) :- - apply(SPred, [I1, I2]). - -% Character classification in DCG notation -char(Type, [H|T], T) :- - char_type(H, Type). - -% Variation on char/3 to return character -char(Type, H, [H|T], T) :- - char_type_(H, Type). - -% Extension of char_type/2 -char_type_(Char, Type) :- - Type == noQuote -> - \+ char_type(Char, quote) - ; char_type(Char, Type). - -% Variation on but/3 to return consumed character -but(Chars, H, [H|T], T) :- - \+ member(H, Chars). diff --git a/prelude/test.pro b/prelude/test.pro deleted file mode 100644 index ef1f496..0000000 --- a/prelude/test.pro +++ /dev/null @@ -1,159 +0,0 @@ -% Low-level assertion checking -true(G) - :- - G -> true ; ( - format('Assertion failed: ~q.~n',[G]), - halt(-1) - ). - -runTests(Tests) :- - initTesting, - ( Tests; true ), - reportTesting. - -initTesting :- - nb_setval(true, 0), - nb_setval(fail, 0), - nb_setval(problems, 0). - -reportTesting :- - nb_getval(true, Trues), - nb_getval(fail, Fails), - format('Test summary: OK: ~w; FAIL: ~w~n', [Trues, Fails]), - - % Producing the right exit code - ( Fails > 0 -> - halt(1) - ; halt - ). - -% Assertion with predicate serving as reportable constraint -require(P) :- - P =.. [C|_], - require(C, P). - -% Assertion with explicit constraint naming -require(C, P) :- - ( P -> - true - ; - error(C) - ). - -% Report an error -error(C) :- - nb_getval(problems, X1), - ( X1 == 0 -> nl; true ), - format('Assertion failed: ~q~n', [C]), - X2 is X1 + 1, - nb_setval(problems, X2), - fail. - -% Monitor test-case execution -test(Goal) :- - require( - testGoalUnshowable, - showTestGoal(Goal)), - write(': '), - nb_setval(problems, 0), - ( ( applyToIO(Goal), nb_getval(problems, 0) ) -> - write('OK'), - nb_getval(true, Trues0), - Trues1 is Trues0 + 1, - nb_setval(true, Trues1) - ; - nb_getval(problems, X), - write('FAIL'), - ( X == 0 -> - true - ; format(' (~w failed assertions)', [X]) - ), - nb_getval(fail, Fails0), - Fails1 is Fails0 + 1, - nb_setval(fail, Fails1) - ), - nl. - -% Apply a predicate to terms to be read from / written to files. -applyToIO(Goal) :- - Goal =.. [P|IOs], - map(beforeApplyToIO, IOs, Terms), - once(apply(P, Terms)), - map(afterApplyToIO, IOs, Terms). - -% Obtain input from a file -beforeApplyToIO((i(Format), File), Data) :- - ( Format == term, readTermFile(File, Data) - ; Format == text, readTextFile(File, Data) - ). - -% Skip output "before" -beforeApplyToIO((o(_), _, _), _). -beforeApplyToIO((o(_), File), _) :- File \= (_, _). - -% Use (unify) a term as is -beforeApplyToIO((u, Term), Term). - -% Skip input "after" -afterApplyToIO((i(_), _), _). - -% Compare output with a file -afterApplyToIO((o(Format), File, Eq), Actual) :- - open(File, read, Input, []), - ( Format == term, read(Input, Expected) - ; Format == text, read_stream_to_codes(Input, Expected) - ), - close(Input), - ( - once(apply(Eq, [Expected, Actual])) -> - true - ; nl, - write('Expected: '), showTestData(Format, Expected), nl, - write('Actual: '), showTestData(Format, Actual), nl, - fail - ). - -% Auto-fill equality -afterApplyToIO((o(Format), File), Actual) :- - File \= (_, _), - afterApplyToIO((o(Format), File, (==)), Actual). - -% Use (unify) a term as is -afterApplyToIO((u, Term), Term). - -% Show test argument -showTestData(term, X) :- format('~n~q', [X]). -showTestData(text, X) :- format('~n~s', [X]). - -% Show a goal for reporting purposes -showTestGoal(Goal) :- - Goal =.. [P|Args], - write(P), - showTestArgs(0, Args). - -showTestArgs(0, []). -showTestArgs(P, []) :- - P > 0, - write(')'). -showTestArgs(0, [H|T]) :- - write('('), - showTestArg(H), - showTestArgs(1, T). -showTestArgs(P1, [H|T]) :- - P1 > 0, - write(', '), - showTestArg(H), - P2 is P1 + 1, - showTestArgs(P2, T). - -showTestArg((i(_), F)) :- - write(F), !. -showTestArg((o(_), F)) :- - F \= (_, _), - write(F), !. -showTestArg((o(_), F, _)) :- - write(F), !. -showTestArg((u, T)) :- - write(T), !. -showTestArg(T) :- - write(T), !. diff --git a/prelude/ueber.pro b/prelude/ueber.pro deleted file mode 100644 index 71a0e56..0000000 --- a/prelude/ueber.pro +++ /dev/null @@ -1,146 +0,0 @@ -:- ['languages/ueber/macros/esl.pro']. -:- ['languages/ueber/macros/bgl.pro']. -:- ['languages/ueber/macros/egl.pro']. -:- ['languages/ueber/macros/mml.pro']. -:- ['languages/ueber/macros/parse.pro']. -:- ['languages/ueber/macros/ppl.pro']. -:- nb_setval(ueber_level, 1). -:- nb_setval(ueber_dir, '.'). - -init :- - format('Megamodel preprocessing:~n', []). - -% Check directory to be ueber-preprocessable -preprocess(Dir) :- - atom_concat(Dir, '/.ueber', File), - ( exists_file(File) -> - preprocess(Dir, File) - ; - true - ). - -% Preprocess directory and .ueber file -preprocess(Dir, File) :- - readTermFile(File, Term), - nb_getval(ueber_level, OldLevel), - Level is OldLevel + 1, - nb_setval(ueber_level, Level), - nb_getval(ueber_dir, OldDir), - nb_setval(ueber_dir, Dir), - ueber_indent, - format('> enter(~q)~n',[Dir]), - atom_concat(Dir, '/*.pro', ProWildcard), - atom_concat(Dir, '/*.dcg', DcgWildcard), - expand_file_name(ProWildcard, ProFiles), - map(load, ProFiles), - expand_file_name(DcgWildcard, DcgFiles), - map(load, DcgFiles), -% elementOf('.ueber', ueber(term)), - maplist(declare, Term), - atom_concat(Dir, '/*', Wildcard), - expand_file_name(Wildcard, Files), - filter(exists_directory, Files, Dirs), - map(preprocess, Dirs), - nb_setval(ueber_level, OldLevel), - nb_setval(ueber_dir, OldDir). - -% Load a Prolog file -load(File) :- - ueber_indent, - format(' * load(~q)~n',[File]), - consult(File). - -% Pre-process language declaration -declare(language(Lang)) :- - ueber_indent, - format(' * language(~q)~n',[Lang]), - ( \+ declaration(language(Lang)) -> assertz(declaration(language(Lang))); true ). - -% Pre-process language declaration -declare(membership(Lang, Pred, ArgsRel)) :- - ueber_indent, - format(' * membership(~q, ~q, ~q)~n',[Lang, Pred, ArgsRel]), - map(ueber_absolute, ArgsRel, ArgsAbs), - assertz(declaration(membership(Lang, Pred, ArgsAbs))). - -% Pre-process equivalence declaration -declare(equivalence(Lang, Pred, ArgsRel)) :- - ueber_indent, - format(' * equivalence(~q, ~q, ~q)~n',[Lang, Pred, ArgsRel]), - map(ueber_absolute, ArgsRel, ArgsAbs), - assertz(declaration(equivalence(Lang, Pred, ArgsAbs))). - -% Pre-process parser declaration -declare(function(Func, LangsIn, LangsOut, Pred, ArgsRel)) :- - ueber_indent, - format(' * function(~q, ~q, ~q, ~q, ~q)~n',[Func, LangsIn, LangsOut, Pred, ArgsRel]), - map(ueber_absolute, ArgsRel, ArgsAbs), - assertz(declaration(function(Func, LangsIn, LangsOut, Pred, ArgsAbs))). - -% Pre-process elementOf/2 relationship -declare(elementOf(Rel, Lang)) :- - ueber_absolute(Rel, Abs), - ueber_indent, - format(' * elementOf(~q, ~q)~n',[Rel, Lang]), - assertz(declaration(elementOf(Abs, Lang))). - -% Pre-process negated elementOf/2 relationship -declare(not(elementOf(Rel, Lang))) :- - ueber_absolute(Rel, Abs), - ueber_indent, - format(' * not(elementOf(~q, ~q))~n',[Rel, Lang]), - assertz(declaration(not(elementOf(Abs, Lang)))). - -% Pre-process mapsTo relationship -declare(mapsTo(Func, ArgsRel, RessRel)) :- - map(ueber_absolute, ArgsRel, ArgsAbs), - map(ueber_absolute, RessRel, RessAbs), - ueber_indent, - format(' * mapsTo(~q, ~q, ~q)~n',[Func, ArgsRel, RessRel]), - assertz(declaration(mapsTo(Func, ArgsAbs, RessAbs))). - -% Pre-process negated mapsTo relationship -declare(not(mapsTo(Func, ArgsRel, RessRel))) :- - map(ueber_absolute, ArgsRel, ArgsAbs), - map(ueber_absolute, RessRel, RessAbs), - ueber_indent, - format(' * not(mapsTo(~q, ~q, ~q))~n',[Func, ArgsRel, RessRel]), - assertz(declaration(not(mapsTo(Func, ArgsAbs, RessAbs)))). - -% Pre-process macro applications -declare(macro(X)) :- - call(X). - -% Make a pseudo-absolute filename -ueber_absolute(Rel, Abs2) :- - nb_getval(ueber_dir, Dir), - ( - Dir == '' -> - Abs1 = Rel - ; atomic_list_concat([Dir, '/', Rel], Abs1) - ), - ueber_normalize(Abs1, Abs2). - -% Normalize ".." for uniqueness -ueber_normalize(Atom1, Atom3) :- - name(Atom1, Str1), - ( append(Str2, [0'/, 0'., 0'., 0'/|Str3], Str1) -> - append(Str4, [0'/|Str5], Str2), - \+ member(0'/, Str5), - concat([Str4, [0'/], Str3], Str6), - name(Atom2, Str6), - ueber_normalize(Atom2, Atom3) - ; - Atom3 = Atom1 - ). - -% Indentation -ueber_indent :- - nb_getval(ueber_level, L), - ueber_indent(L). -ueber_indent(0). -ueber_indent(L1) :- - L1 > 0, - write(' '), - L2 is L1 - 1, - ueber_indent(L2). diff --git a/services/editor/.gitignore b/services/editor/.gitignore deleted file mode 100644 index fc2bb46..0000000 --- a/services/editor/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -startup -shutdown diff --git a/services/editor/Makefile b/services/editor/Makefile deleted file mode 100644 index 8b468d7..0000000 --- a/services/editor/Makefile +++ /dev/null @@ -1,39 +0,0 @@ -# Start and stop Apache through Settings -> Sharing -> WebSharing. -# Consider firewall through Settings -> Security ... -# Consider blocking external access ditto. -# Add the following to /etc/apache2/httpd.conf (without "#") -# ProxyPass / http://localhost:4242/ -# ProxyPassReverse / http://localhost:4242/ -# One may need to restart Apache to take effect. - -web = /Library/WebServer/Documents -swipl = swipl -q -t editor_main -server = ${swipl} -f server.pro -log = ../../logs/editor.log - -# Show status -status: - ps -ef | grep "pl" | grep ${log} - -# Use when server was terminated irregularly -reset: - @rm -f startup shutdown - -# Restart server -restart: - make shutdown - make startup - -# Start up server -startup: - @touch startup # to prevent multiple servers - @${server} -- ${log} & - @echo Server started. Use \"make shutdown\" to shut it down. - -# Shut down server -shutdown: - @touch shutdown - @echo Stopping server. - @sleep 3 - @make reset - @echo Server stopped. Use \"make startup\" to start it up. diff --git a/services/editor/README.md b/services/editor/README.md deleted file mode 100644 index 388fbe3..0000000 --- a/services/editor/README.md +++ /dev/null @@ -1,21 +0,0 @@ -See here for material on this structure editor: - -http://softlang.uni-koblenz.de/splash13/ - -This is how the server can be tested: - -* Make sure slepro works on your system; run "make test" at the top. -* Run a Apache server on your system so that you can use localhost. -* Set up remote proxy so that Apache redirects to Prolog; see below. -* Start the server in services/editor with "make startup". -* Try out http://localhost/metamodels etc. -* Shut down the server in services/editor with "make shutdown". - -Remote proxy configuration: - -
-more /etc/apache2/httpd.conf
-...
-ProxyPass        / http://localhost:4242/
-ProxyPassReverse / http://localhost:4242/
-
diff --git a/services/editor/controller.pro b/services/editor/controller.pro deleted file mode 100644 index 884c866..0000000 --- a/services/editor/controller.pro +++ /dev/null @@ -1,9 +0,0 @@ -% Map URLs to handler predicates -editor_handlers :- - http_handler(root('metamodels'), metamodels_page, []), - http_handler(root('classes'), classes_page, []), - http_handler(root('edit'), edit_page, []), - http_handler(root('show'), show_page, []), - http_handler(root('new'), new_page, []), - http_handler(root('add'), add_page, []), - http_handler(root('remove'), remove_page, []). diff --git a/services/editor/runtime.pro b/services/editor/runtime.pro deleted file mode 100644 index d1150bb..0000000 --- a/services/editor/runtime.pro +++ /dev/null @@ -1,13 +0,0 @@ -% Runtime table for metamodels -:- dynamic metamodel/2. - -% Load a metamodel into memory -loadMetamodel(File) :- - readTermFile(File, Mm), - require( - invalidMetamodel, - metamodel(Mm) - ), - lookup(name, Mm, Name), - \+ metamodel(Name, _), - assertz(metamodel(Name, Mm)). diff --git a/services/editor/server.pro b/services/editor/server.pro deleted file mode 100644 index 497274b..0000000 --- a/services/editor/server.pro +++ /dev/null @@ -1,30 +0,0 @@ -% Service EDITOR: A simple metamodel-driven structure editor - -% Import -:- ensure_loaded('../../packages/prelude.pro'). -:- ensure_loaded('../../packages/mm.pro'). -:- ensure_loaded('../../packages/mt.pro'). -:- ensure_loaded('../../packages/pp.pro'). - -% Server components -:- ['runtime.pro']. -:- ['session.pro']. -:- ['controller.pro']. - -% View (pages) -:- ['view/metamodels.pro']. -:- ['view/classes.pro']. -:- ['view/new.pro']. -:- ['view/add.pro']. -:- ['view/remove.pro']. -:- ['view/edit.pro']. -:- ['view/show.pro']. - -% Metamodels -:- loadMetamodel('../../languages/expr/mm.graph'). -:- loadMetamodel('../../languages/family/mm1.graph'). -:- loadMetamodel('../../languages/mml/mm.graph'). - -% Server -editor_main :- - service_http(editor_handlers). diff --git a/services/editor/session.pro b/services/editor/session.pro deleted file mode 100644 index cd4c143..0000000 --- a/services/editor/session.pro +++ /dev/null @@ -1,28 +0,0 @@ -% Initialize session management -:- dynamic session/1. -:- dynamic state/3. -:- assertz(session(0)). - -% Start a new session -newSession(S2) :- - once(( - repeat, - sleep(0.01), - retract(session(S1)), - S2 is S1 + 1, - assertz(session(S2)) - )). - -% Initialize session -initSession(S, MmName, M) :- - \+ state(S, _, _), - assertz(state(S, MmName, M)). - -% Retrieve a session -retrieveSession(S, MmName, M) :- - state(S, MmName, M). - -% Update a session -updateSession(S, M) :- - retract(state(S, MmName, _)), % TODO: Undo not supported - assertz(state(S, MmName, M)). diff --git a/services/editor/view/add.pro b/services/editor/view/add.pro deleted file mode 100644 index bdd4fda..0000000 --- a/services/editor/view/add.pro +++ /dev/null @@ -1,20 +0,0 @@ -% Page for adding a sub-object -add_page(Request) :- - - % URL parsing - member(search(L), Request), - member((session=S1), L), - atom_number(S1, S2), - member((id=Id1), L), - atom_number(Id1, Id2), - member((key=Key), L), - member((class=ClassN), L), - - % Object creation - retrieveSession(S2, MmName, M1), - metamodel(MmName, MM), - addObject(MM, Id2, Key, ClassN, M1, M2), - updateSession(S2, M2), - - % Page rendering - editObject(S2). diff --git a/services/editor/view/classes.pro b/services/editor/view/classes.pro deleted file mode 100644 index 182757d..0000000 --- a/services/editor/view/classes.pro +++ /dev/null @@ -1,26 +0,0 @@ -% Page for class selection -classes_page(Request) :- - - % Data preparation - member(search(L), Request), - member((metamodel=MmName), L), - metamodel(MmName, MM), - concreteClassesOfMetamodel(MM, Names1), - sort(Names1, Names2), - - % Page creation - map(classes_page_(MmName), Names2, Items), - reply_html_page( - title('Model editor'), - [ - h3('Class selection'), - ul(Items) - ] - ). - -% HTML LI item per class -classes_page_( - MmName, - ClassName, - li(a(href='new?metamodel='+MmName+'&class='+ClassName, ClassName)) -). diff --git a/services/editor/view/edit.pro b/services/editor/view/edit.pro deleted file mode 100644 index 4bf0a01..0000000 --- a/services/editor/view/edit.pro +++ /dev/null @@ -1,88 +0,0 @@ -% Page rendering object for editing -edit_page(Request) :- - - % URL parsing - member(search(L), Request), - member((session=S1), L), - atom_number(S1, S2), - editObject(S2). - -% Reply for the page -editObject(S) :- - retrieveSession(S, MmName, Obj), - metamodel(MmName, MM), - editObject(S, MM, Obj, Html), - % Page assembly - reply_html_page( - title('Editable model'), - form( - action='show', - [ - h3('Model editing'), - p(Html), - input([type=hidden, name=session, value=S], []), - p(button([type=submit], 'Done')) - ] - ) - ). - -% Stateless version of editObject/1 -editObject( - S, - MM, - Id&Dict1, - [b(Id), ' & ', b(ClassN), ul(Items)] -) :- - - % Special treatment of KV pair for class - lookup(class, Dict1, ClassN), - remove(class, Dict1, Dict2), - - % Treatment of members - dictToList(Dict2, L), - map(editMember(S, MM, ClassN, Id), L, Items). - -% Per-member logic -editMember( - S, - MM, - ClassN, - Id, - (MemberN, V), - li( - [ - MemberN, - ul(NewHtml) - | ul(ObjsHtml) - ] - ) -) :- - lookupMember(ClassN, MemberN, MM, Member), - lookup(cardinality, Member, Card), - ( - ( lookup(class, Card, X), - member(X, [one, option]), - V = [_] - ) -> - NewHtml = [] - ; - concreteClassesForMember(MM, ClassN, MemberN, ClassNs), - map(editAddObject(S, Id, MemberN), ClassNs, NewHtml) - ), - map(editRemoveObject(S, MM), V, ObjsHtml). - -% Render add operation -editAddObject( - S, Id, K, ClassN, - li(['+', ' ', a(href='add?session='+S+'&id='+Id+'&key='+K+'&class='+ClassN, ClassN)]) -). - -% Render remove operation -editRemoveObject(S, MM, V, - li( - [ a(href='remove?session='+S+'&id='+Id, b('-')), - ' ' - | Html]) -) :- - V = (Id&_), - editObject(S, MM, V, Html). diff --git a/services/editor/view/metamodels.pro b/services/editor/view/metamodels.pro deleted file mode 100644 index 6fff441..0000000 --- a/services/editor/view/metamodels.pro +++ /dev/null @@ -1,23 +0,0 @@ -% Page for metamodel selection -metamodels_page(_Request) :- - - % Data preparation - findall(Name, metamodel(Name, _), Names1), - sort(Names1, Names2), - - % Page creation - map(metamodels_page_, Names2, Items), - reply_html_page( - title('Model editor'), - [ - h3('Metamodel selection'), - ul(Items) - ] - ). - - -% HTML LI item per metamodel -metamodels_page_( - Name, - li(a(href='classes?metamodel='+Name, Name)) -). diff --git a/services/editor/view/new.pro b/services/editor/view/new.pro deleted file mode 100644 index f34e9e5..0000000 --- a/services/editor/view/new.pro +++ /dev/null @@ -1,18 +0,0 @@ -% Page for constructing a new model -new_page(Request) :- - - % Start a new session - newSession(S), - - % URL parsing - member(search(L), Request), - member((metamodel=MmName), L), - member((class=CName), L), - - % Object creation - metamodel(MmName, MM), - newObject(MM, CName, Obj), - initSession(S, MmName, Obj), - - % Page rendering - editObject(S). diff --git a/services/editor/view/remove.pro b/services/editor/view/remove.pro deleted file mode 100644 index ea0de3c..0000000 --- a/services/editor/view/remove.pro +++ /dev/null @@ -1,18 +0,0 @@ -% Page for removing a sub-object -remove_page(Request) :- - - % URL parsing - member(search(L), Request), - member((session=S1), L), - atom_number(S1, S2), - member((id=Id1), L), - atom_number(Id1, Id2), - - % Object creation - retrieveSession(S2, MmName, M1), - metamodel(MmName, MM), - removeObject(MM, Id2, M1, M2), - updateSession(S2, M2), - - % Page rendering - editObject(S2). diff --git a/services/editor/view/show.pro b/services/editor/view/show.pro deleted file mode 100644 index 660dd02..0000000 --- a/services/editor/view/show.pro +++ /dev/null @@ -1,47 +0,0 @@ -% Page showing object in plain text -show_page(Request) :- - - % URL parsing - member(search(L), Request), - member((session=S1), L), - atom_number(S1, S2), - showObject(S2). - -% Reply for the page -showObject(S) :- - - % Data preparation - retrieveSession(S, MmName, Obj0), - metamodel(MmName, MM1), - - % Conformance checking - ( ( - relaxMetamodel(MM1, MM2), - recardinalize(MM2, MM1, Obj0, Obj) - ) -> - Conf = true - ; ( - Conf = false, - Obj = Obj0 - ) - ), - - % Pretty print object - ppGraph(Obj, Text1), - atom_codes(Text2, Text1), - - % Page assembly - reply_html_page( - title('Model editor'), - form( - action='edit', - [ - h3('Conformance'), - b(Conf), - h3('Pretty-printed model'), - pre(Text2), - input([type=hidden, name=session, value=S], []), - p(button([type=submit], 'Edit')) - ] - ) - ).