-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3 from engboris/engboris-metaprog
[WIP] Prototype of metaprogramming language for constellations
- Loading branch information
Showing
29 changed files
with
388 additions
and
100 deletions.
There are no files selected for viewing
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,7 +1,7 @@ | ||
(executables | ||
(public_names lsc ilsc) | ||
(names lsc ilsc) | ||
(libraries lsclib base)) | ||
(public_names lsc ilsc sgen) | ||
(names lscrun ilsc sgen) | ||
(libraries lsc stellogen base)) | ||
(env | ||
(dev | ||
(flags (:standard -warn-error -A)))) |
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
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,17 @@ | ||
open Base | ||
open Stellogen.Sgen_ast | ||
open Stellogen.Sgen_parser | ||
open Stellogen.Sgen_lexer | ||
|
||
let usage_msg = "sgen <filename>" | ||
let input_file = ref "" | ||
|
||
let anon_fun filename = input_file := filename | ||
|
||
let speclist = [] | ||
|
||
let _ = | ||
Stdlib.Arg.parse speclist anon_fun usage_msg; | ||
let lexbuf = Lexing.from_channel (Stdlib.open_in !input_file) in | ||
let p = program read lexbuf in | ||
eval_program p |
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 |
---|---|---|
@@ -0,0 +1,28 @@ | ||
'''' | ||
Syntax of Stellogen programs | ||
'''' | ||
|
||
'print text | ||
print "Welcome" | ||
|
||
'definition of constellation | ||
def x | ||
+a; -a b; | ||
end | ||
def y x | ||
|
||
'union | ||
def union_x_y | ||
x@y | ||
end | ||
|
||
'execution | ||
def exec_x | ||
exec x | ||
end | ||
|
||
'print contellations | ||
print { a; b; c; } | ||
print a; b; c; end | ||
print (x @ x) | ||
print (exec x) |
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,3 @@ | ||
%token EOF | ||
|
||
%% |
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 @@ | ||
../common_tokens.mly |
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,9 +1,10 @@ | ||
(library | ||
(name lsclib) | ||
(name lsc) | ||
(libraries base)) | ||
(env | ||
(dev | ||
(flags (:standard -warn-error -A)))) | ||
(menhir (modules parser) | ||
(menhir (modules common_tokens lsc_parser) | ||
(merge_into lsc_parser) | ||
(flags --explain --dump)) | ||
(ocamllex lexer) | ||
(ocamllex lsc_lexer) |
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,5 +1,5 @@ | ||
{ | ||
open Parser | ||
open Lsc_parser | ||
} | ||
|
||
let var_id = ['A'-'Z'] ['A'-'Z' '0'-'9' '_' '-']* '\''* | ||
|
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,59 @@ | ||
%{ | ||
open Lsc_ast | ||
%} | ||
|
||
%token COMMA | ||
%token LBRACK RBRACK | ||
%token LPAR RPAR | ||
%token <string> VAR | ||
%token <string> SYM | ||
%token PLUS MINUS | ||
%token CONS | ||
%token AT | ||
%token SEMICOLON | ||
%token PLACEHOLDER | ||
%token EMPTY_SYM | ||
|
||
%right CONS | ||
|
||
%start <marked_constellation> constellation_file | ||
%start <marked_constellation> marked_constellation | ||
|
||
%% | ||
|
||
constellation_file: | ||
| EOF { [] } | ||
| cs = marked_constellation; EOF { cs } | ||
|
||
marked_constellation: | ||
| cs = star+ { cs } | ||
|
||
star: | ||
| AT; s = star_content; SEMICOLON { Marked s } | ||
| s = star_content; SEMICOLON { Unmarked s } | ||
|
||
star_content: | ||
| LBRACK; RBRACK { [] } | ||
| rs = separated_nonempty_list(COMMA?, ray) { rs } | ||
|
||
symbol: | ||
| PLUS; f = SYM { (Pos, f) } | ||
| MINUS; f = SYM { (Neg, f) } | ||
| f = SYM { (Null, f) } | ||
|
||
ray: | ||
| EMPTY_SYM { to_func ((Null, "$"), []) } | ||
| PLACEHOLDER { to_var ("_"^(fresh_placeholder ())) } | ||
| x = VAR { to_var x } | ||
| e = func_expr { e } | ||
|
||
func_expr: | ||
| e = cons_expr { e } | ||
| pf = symbol; LPAR; ts = separated_nonempty_list(COMMA?, ray); RPAR | ||
{ to_func (pf, ts) } | ||
| pf = symbol { to_func (pf, []) } | ||
|
||
cons_expr: | ||
| r1 = ray; CONS; r2 = ray { to_func ((Null, ":"), [r1; r2]) } | ||
| LPAR; e = cons_expr; RPAR; CONS; r = ray | ||
{ to_func ((Null, ":"), [e; r]) } |
File renamed without changes.
File renamed without changes.
Oops, something went wrong.