Skip to content

Commit

Permalink
About to move to the new repo
Browse files Browse the repository at this point in the history
  • Loading branch information
rlaemmel committed Dec 30, 2014
1 parent b9f64df commit f4e2522
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 149 deletions.
24 changes: 0 additions & 24 deletions languages/bgl/derive-signature.pro

This file was deleted.

File renamed without changes.
2 changes: 1 addition & 1 deletion languages/bgl/egl/.ueber
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
macro(eglSyntax(bgl_egl))
macro(eglSyntax(bgl))
].

4 changes: 2 additions & 2 deletions languages/bgl/egl/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
A redundant EGL-based syntax of BGL.
It is redundant because the EGL parser is used.
See egl2bgl.pro for the restriction of EGL to 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.
6 changes: 3 additions & 3 deletions languages/bgl/egl/cs.egl
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
grammar : {rule}* ;
rule : '[' label ']' nonterminal ':' {symbol}* ';' ;
[t] symbol : terminal ;
[n] symbol : nonterminal ;
rule : '[' label ']' nonterminal ':' {gsymbol}* ';' ;
[t] gsymbol : terminal ;
[n] gsymbol : nonterminal ;
label : name ;
terminal : qstring ;
nonterminal : name ;
2 changes: 1 addition & 1 deletion languages/bgl/egl/cs.term
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[ ([],grammar,[star([n(rule)])]), ([],rule,[t('['),n(label),t(']'),n(nonterminal),t(:),star([n(symbol)]),t(;)]), ([t],symbol,[n(terminal)]), ([n],symbol,[n(nonterminal)]), ([],label,[n(name)]), ([],terminal,[n(qstring)]), ([],nonterminal,[n(name)])].
[ ([],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)])].
2 changes: 1 addition & 1 deletion languages/bgl/esl/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
A redundant ESL-based syntax of BGL.
It is redundant because the more general signature of EGL could be used.
See egl2bgl.pro for the restriction of EGL to BGL.
See egl-to-bgl.pro for the restriction of EGL to BGL.
18 changes: 18 additions & 0 deletions languages/bsl/bgl-to-bsl.pro
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
% 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).
1 change: 0 additions & 1 deletion languages/bsl/conformance.pro
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
% Recursive test for term symbols to comply with a profile
manySortedTerm(Profiles, Term, Result) :-
Term =.. [Symbol|Terms],
member((Symbol, Arguments, Result), Profiles),
Expand Down
2 changes: 1 addition & 1 deletion languages/bsl/egl/.ueber
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
macro(eglSyntax(bsl_egl))
macro(eglSyntax(bsl))
].

4 changes: 2 additions & 2 deletions languages/bsl/egl/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
A redundant EGL-based syntax of BSL.
It is redundant because the ESL parser is used.
See esl2bsl.pro for the restriction of ESL to 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.
File renamed without changes.
2 changes: 1 addition & 1 deletion languages/bsl/esl/.ueber
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
[
macro(eslSyntax(bsl_esl))
macro(eslSyntax(bsl))
].

4 changes: 2 additions & 2 deletions languages/bsl/esl/README.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
A redundant ESL-based syntax of BSL.
It is redundant because the ESL signature is used.
See esl2bsl.pro for the restriction of ESL to 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.
4 changes: 2 additions & 2 deletions languages/bsl/esl/as.esl
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
type signature = symbol* ;
type symbol = (atom, atom*, atom) ;
type signature = profile* ;
type profile = (atom, atom*, atom) ;
2 changes: 1 addition & 1 deletion languages/bsl/esl/as.term
Original file line number Diff line number Diff line change
@@ -1 +1 @@
[type(signature,star(sort(symbol))),type(symbol,tuple([atom,star(atom),atom]))].
[type(signature,star(sort(profile))),type(profile,tuple([atom,star(atom),atom]))].
14 changes: 7 additions & 7 deletions languages/egl/cs.egl
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
grammar : {rule}* ;
rule : {'[' label ']'}? nonterminal ':' symbols ';' ;
[t] symbol : terminal ;
[n] symbol : nonterminal ;
[star] symbol : '{' symbols '}' '*' ;
[plus] symbol : '{' symbols '}' '+' ;
[option] symbol : '{' symbols '}' '?' ;
symbols : {symbol}* ;
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 ;
25 changes: 1 addition & 24 deletions languages/egl/cs.term
Original file line number Diff line number Diff line change
@@ -1,24 +1 @@
[
([], grammar, [star([n(rule)])]),

([], rule, [
option([t('['), n(label), t(']')]),
n(nonterminal),
t(':'),
n(symbols),
t(';')
]),

([t], symbol, [n(terminal)]),
([n], symbol, [n(nonterminal)]),
([star], symbol, [t('{'), n(symbols), t('}'), t('*')]),
([plus], symbol, [t('{'), n(symbols), t('}'), t('+')]),
([option], symbol, [t('{'), n(symbols), t('}'), t('?')]),

([], symbols, [star([n(symbol)])]),

([], label, [n(name)]),
([], terminal, [n(qstring)]),
([], nonterminal, [n(name)])

].
[ ([],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)])].
2 changes: 1 addition & 1 deletion languages/esl/api.pro
Original file line number Diff line number Diff line change
Expand Up @@ -7,4 +7,4 @@ eslLanguage(File, Term) :-
[Decl|_] = Decls,
( Decl = symbol(_, _, Sort)
; Decl = type(Sort, _) ),
wellTypedTerm(Decls, Sort, Term).
wellTypedTerm(Decls, sort(Sort), Term).
103 changes: 28 additions & 75 deletions languages/esl/conformance.pro
Original file line number Diff line number Diff line change
@@ -1,88 +1,41 @@
% Well-typed terms
wellTypedTerm(Decls, Sort, Term) :-
require(
appliedSignatureExpected,
appliedSignature(Decls)
),
require(
appliedTermExpected,
appliedTerm(Term)
),
wellTypedTerm_(Decls, sort(Sort), Term).

% Apply symbol
wellTypedTerm_(Decls, sort(Result), Term) :-
% Apply symbol declaration
wellTypedTerm(Decls, sort(Result), Term) :-
\+ (list(Term); tuple(Term)),
Term =.. [Symbol|Terms],
member(symbol(Symbol, Arguments, Result), Decls),
map(wellTypedTerm_(Decls), Arguments, Terms).
Term =.. [FSym|Terms],
member(symbol(FSym, Args, Result), Decls),
map(wellTypedTerm(Decls), Args, Terms).

% Apply type
wellTypedTerm_(Decls, sort(Sort), Term) :-
% Apply type declaration
wellTypedTerm(Decls, sort(Sort), Term) :-
member(type(Sort, Type), Decls),
wellTypedTerm_(Decls, Type, Term).

% Test for atoms
wellTypedTerm_(_, term, Term) :-
appliedTerm(Term).

% Test for atoms
wellTypedTerm_(_, atom, Term) :-
atom(Term).

% Test for integers
wellTypedTerm_(_, integer, Term) :-
integer(Term).
wellTypedTerm(Decls, Type, Term).

% Test for floats
wellTypedTerm_(_, float, Term) :-
float(Term).

% Test for numbers
wellTypedTerm_(_, number, Term) :-
number(Term).

% Test for Booleans
wellTypedTerm_(_, boolean, Term) :-
boolean(Term).

% Test for (any) applied term
wellTypedTerm_(_, term, Term) :-
appliedTerm(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) :-
wellTypedTerm(Decls, star(Type), Terms) :-
map(wellTypedTerm(Decls, Type), Terms).
wellTypedTerm(Decls, plus(Type), Terms) :-
Terms \= [],
map(wellTypedTerm_(Decls, Type), Terms).
map(wellTypedTerm(Decls, Type), Terms).

% Test for options
wellTypedTerm_(Decls, option(Type), Terms) :-
length(Terms, Len),
Len < 2,
map(wellTypedTerm_(Decls, Type), Terms).
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).
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).

% Test for optional terms
wellTypedTerm_(Decls, option(Type), Terms) :-
length(Terms, Len),
member(Len, [0,1]),
map(wellTypedTerm_(Decls, Type), Terms).
wellTypedTerm(Decls, tuple([Type|Types]), (Term, Terms)) :-
Types \= [],
wellTypedTerm(Decls, Type, Term),
wellTypedTerm(Decls, tuple(Types), Terms).

0 comments on commit f4e2522

Please sign in to comment.