-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
20 changed files
with
72 additions
and
149 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[ | ||
macro(eglSyntax(bgl_egl)) | ||
macro(eglSyntax(bgl)) | ||
]. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[ | ||
macro(eglSyntax(bsl_egl)) | ||
macro(eglSyntax(bsl)) | ||
]. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
[ | ||
macro(eslSyntax(bsl_esl)) | ||
macro(eslSyntax(bsl)) | ||
]. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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]))]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 ; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)])]. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |