white_space ::= ' ' | '\r' | '\n' | '\t'
ident ::= ('a'|...|'z'|'A'|..|'Z'|'_')('a'|...|'z'|'A'|..|'Z'|'_'|'0'|...|'9')*
number ::= ('0'|...|'9')+
This file contains hidden or 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
| % elvm on prolog | |
| :- style_check(-singleton). | |
| reg(a). reg(b). reg(c). reg(d). reg(sp). reg(bp). | |
| imm(N) :- integer(N), N >= 0, MAX is 256 * 65536, N < MAX. | |
| update([],V,[V]). | |
| update([Reg=_|R],Reg=V,[Reg=V|R]). | |
| update([V1|R],V,[V1|R2]) :- update(R,V,R2). |
This file contains hidden or 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
| ## NSON BNF | |
| bool ::= 'true' | 'false' | |
| value ::= '"' (not('"')|'\' _)+ '"' | |
| | ('a'|...|'z'|'A'|...|'Z'|'_')('a'|...|'z'|'A'|...|'Z'|'_'|'0'|...'9')* | |
| number ::= ('0'|...|'9')+ | |
| | ('0'|...|'9')* '.' ('0'|...|'9')+ | ('0'|...|'9')+ '.' ('0'|...|'9')* | |
| value ::= atom | number | bool | |
| expression ::= value | object | array | |
| object ::= '{' (value ':' expression ','?)* '}' |
This file contains hidden or 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
| <html> | |
| <head> | |
| <script src="http://pengines.swi-prolog.org/vendor/jquery/jquery-2.0.3.min.js"></script> | |
| <script src="http://pengines.swi-prolog.org/pengine/pengines.js"></script> | |
| <script type="text/x-prolog"> | |
| /* | |
| TLLP interpreter in Prolog | |
| */ | |
| :- op(1060, xfy, (&)). | |
| :- op( 950, xfy, [-<>, =>]). |
This file contains hidden or 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
| <!doctype html> | |
| <html> | |
| <head> | |
| <meta charset="UTF-8" /> | |
| <meta name="viewport" content="width=device-width" /> | |
| <title>$title</title> | |
| $styles | |
| </head> | |
| <body> | |
| <h1>$title</h1> |
This file contains hidden or 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
| /* Syntax of SortOfWhile */ | |
| % Statements | |
| stm(skip()). | |
| stm((S1; S2)) :- stm(S1), stm(S2). | |
| stm(X = E) :- atom(X), aexp(E). | |
| stm(if(E, S1, S2)) :- bexp(E), stm(S1), stm(S2). | |
| stm(while(E; S)) :- bexp(E), stm(S). | |
| stm(or(S1, S2)) :- stm(S1), stm(S2). | |
| stm(par(S1, S2)) :- stm(S1), stm(S2). |
This file contains hidden or 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
| /* | |
| 構文 | |
| x, y, z 変数 | |
| v ::= 値 | |
| λ(x:T)t ラムダ | |
| s, t, u ::= 項 | |
| x 変数 | |
| v 値 | |
| x y 関数適用 |
This file contains hidden or 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
| :- initialization(main). | |
| eval1(Ctx,L,Ctx_,V) :- print_term(L,[]),nl,eval(Ctx,L,Ctx_,V),!. | |
| eval(Ctx,["set",X,E],[X=V|Ctx_],null) :- eval1(Ctx, E, Ctx_, V). | |
| eval(Ctx,["get",X],Ctx,V) :- member(X=V, Ctx). | |
| eval(Ctx,["+",E1,E2],Ctx2,V) :- eval1(Ctx,E1,Ctx1,V1),eval1(Ctx1,E2,Ctx2,V2), V is V1 + V2. | |
| eval(Ctx,["=",E1,E2],Ctx2,V) :- eval1(Ctx,E1,Ctx1,V1),eval1(Ctx1,E2,Ctx2,V2), (V1 = V2,V=true;V=false). | |
| eval(Ctx,["until",E1,E2],Ctx3,null) :- | |
| eval1(Ctx,E1,Ctx1,V1), | |
| (V1=true,Ctx3=Ctx1; eval1(Ctx1,E2,Ctx2,_),eval1(Ctx2,["until",E1,E2],Ctx3,_)). | |
| eval(Ctx,["step"|[]],Ctx,null). |
This file contains hidden or 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
| /* | |
| Featherweight Java on Prolog | |
| Featherweight Javaは形式化されたJavaのシンプルなサブセットです。 | |
| Featherweight Java on PrologはProlog上のDSLとしてFeatherweight Javaを実装したものです。 | |
| Featherweight Java on Prologの構文はProlog上で実装しやすい形に書き換えてあります: | |
| 構文 | |
| CL ::= クラス宣言: |
This file contains hidden or 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
| %{ | |
| open Source | |
| open Types | |
| open Kernel | |
| open Ast | |
| open Script | |
| (* Error handling *) |