Commit 46749969 authored by Pascal Raymond's avatar Pascal Raymond
Browse files

essais de syntaxe

parent 32f5edd6
...@@ -43,7 +43,6 @@ test-lutin: ...@@ -43,7 +43,6 @@ test-lutin:
cd lutin/external_code && make test; cd lutin/external_code && make test;
cd lutin/luciole && make test ; cd lutin/luciole && make test ;
cd lutin/lustre && make test ; cd lutin/lustre && make test ;
cd lutin/test_ok && make test ;
cd lutin/C && make test; cd lutin/C && make test;
echo "All lutin tests ran correctly." echo "All lutin tests ran correctly."
......
Constraint: Constraint:
(if
(if
(x + y) >= 0 (x + y) >= 0
then then
(x + y) >= 3 (x + y) >= 3
......
...@@ -41,6 +41,7 @@ Hashtbl.add keywords "fby" (function s -> TK_FBY s) ;; ...@@ -41,6 +41,7 @@ Hashtbl.add keywords "fby" (function s -> TK_FBY s) ;;
Hashtbl.add keywords "loop" (function s -> TK_LOOP s) ;; Hashtbl.add keywords "loop" (function s -> TK_LOOP s) ;;
(* Hashtbl.add keywords "weight" (function s -> TK_WEIGHT s) ;; *) (* Hashtbl.add keywords "weight" (function s -> TK_WEIGHT s) ;; *)
Hashtbl.add keywords "run" (function s -> TK_RUN s) ;;
Hashtbl.add keywords "type" (function s -> TK_TYPE s) ;; Hashtbl.add keywords "type" (function s -> TK_TYPE s) ;;
Hashtbl.add keywords "bool" (function s -> TK_BOOL s) ;; Hashtbl.add keywords "bool" (function s -> TK_BOOL s) ;;
Hashtbl.add keywords "int" (function s -> TK_INT s) ;; Hashtbl.add keywords "int" (function s -> TK_INT s) ;;
...@@ -96,6 +97,7 @@ let token_code tk = ( ...@@ -96,6 +97,7 @@ let token_code tk = (
| TK_TRAP lxm -> ("TK_TRAP", lxm) | TK_TRAP lxm -> ("TK_TRAP", lxm)
| TK_DO lxm -> ("TK_DO", lxm) | TK_DO lxm -> ("TK_DO", lxm)
| TK_EXIST lxm -> ("TK_EXIST", lxm) | TK_EXIST lxm -> ("TK_EXIST", lxm)
| TK_RUN lxm -> ("TK_RUN", lxm)
| TK_FBY lxm -> ("TK_FBY", lxm) | TK_FBY lxm -> ("TK_FBY", lxm)
| TK_LOOP lxm -> ("TK_LOOP", lxm) | TK_LOOP lxm -> ("TK_LOOP", lxm)
(* | TK_WEIGHT lxm -> ("TK_WEIGHT", lxm) *) (* | TK_WEIGHT lxm -> ("TK_WEIGHT", lxm) *)
......
...@@ -129,6 +129,7 @@ let make_val_exp ven lxm = { ...@@ -129,6 +129,7 @@ let make_val_exp ven lxm = {
%token <Lexeme.t> TK_RETURNS %token <Lexeme.t> TK_RETURNS
%token <Lexeme.t> TK_EXIST %token <Lexeme.t> TK_EXIST
%token <Lexeme.t> TK_RUN
%token <Lexeme.t> TK_WEAK %token <Lexeme.t> TK_WEAK
%token <Lexeme.t> TK_STRONG %token <Lexeme.t> TK_STRONG
%token <Lexeme.t> TK_ASSERT %token <Lexeme.t> TK_ASSERT
...@@ -366,6 +367,20 @@ lutIdentList: ...@@ -366,6 +367,20 @@ lutIdentList:
{ $3::$1 } { $3::$1 }
; ;
lutRunVars:
TK_OPEN_PAR lutRunVarList TK_CLOSE_PAR
{ List.rev $2 }
| lutRunVarList
{ List.rev $1 }
;
lutRunVarList:
lutRunVar
{ [$1] }
| lutRunVarList TK_COMA lutRunVar
{ $3::$1 }
;
lutRangeOpt: lutRangeOpt:
/* nada */ /* nada */
...@@ -433,6 +448,17 @@ lutIdentList TK_COLON lutParamType ...@@ -433,6 +448,17 @@ lutIdentList TK_COLON lutParamType
{ distrib_type $1 $3} { distrib_type $1 $3}
; ;
lutRunVar:
lutIdent lutOptType lutOptInit
{ ($1, $2, $3) }
;
lutOptInit:
/* nada */
{ None }
| TK_EQ lutExp
{ Some $2 }
;
/* Immediate type */ /* Immediate type */
...@@ -537,6 +563,8 @@ lutTraceExp: ...@@ -537,6 +563,8 @@ lutTraceExp:
{ make_val_exp (LET_n (snd $1,$3)) ((fst $1).src) } { make_val_exp (LET_n (snd $1,$3)) ((fst $1).src) }
| lutAssertFlag TK_ASSERT lutExp TK_IN lutTraceExp | lutAssertFlag TK_ASSERT lutExp TK_IN lutTraceExp
{ make_val_exp (ASSERT_n ($1,$3,$5)) $2 } { make_val_exp (ASSERT_n ($1,$3,$5)) $2 }
| TK_RUN lutRunVars TK_EQ lutExp TK_IN lutTraceExp
{ make_val_exp (RUN_n ($2, $4, $6)) $1 }
| TK_EXIST lutTypedIdentList TK_IN lutTraceExp | TK_EXIST lutTypedIdentList TK_IN lutTraceExp
{ make_val_exp (EXIST_n (List.rev $2,$4)) $1 } { make_val_exp (EXIST_n (List.rev $2,$4)) $1 }
| TK_EXCEPTION lutIdentList TK_IN lutTraceExp | TK_EXCEPTION lutIdentList TK_IN lutTraceExp
......
...@@ -115,6 +115,7 @@ and val_exp_node = ...@@ -115,6 +115,7 @@ and val_exp_node =
| CALL_n of ident * val_exp list | CALL_n of ident * val_exp list
(* special : dclaration, on garde l'info source *) (* special : dclaration, on garde l'info source *)
| LET_n of let_info * val_exp | LET_n of let_info * val_exp
| RUN_n of (ident * type_exp option * val_exp option) list * val_exp * val_exp
(* utilitaires *) (* utilitaires *)
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment