Commit 1a96b802 authored by POTTIER Francois's avatar POTTIER Francois

Remove trailing whitespace in test files.

parent 041bd10d
%start<int> b %start<int> b
%% %%
b: {} b: {}
......
%start a %start a
%type <unit> a %type <unit> a
%token B %token B
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
%token BAZAR %token BAZAR
%left FOO BAR %left FOO BAR
%right /* error */ %right /* error */
%nonassoc BAR QWD QWD QWD ASD QWD D QWD WQD QWD %nonassoc BAR QWD QWD QWD ASD QWD D QWD WQD QWD
%token BAR %token BAR
%% %%
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
%type<int> date time %type<int> date time
%token BAZAR %token BAZAR
%left FOO BAR %left FOO BAR
%nonassoc BAR QWD QWD QWD ASD QWD D QWD WQD QWD %nonassoc BAR QWD QWD QWD ASD QWD D QWD WQD QWD
%token BAR %token BAR
%% %%
......
...@@ -24,12 +24,12 @@ let rcsid = "$Id: obc.mly,v 1.1 2005/08/23 11:15:14 fpottier Exp $" ...@@ -24,12 +24,12 @@ let rcsid = "$Id: obc.mly,v 1.1 2005/08/23 11:15:14 fpottier Exp $"
/* punctuation */ /* punctuation */
%token SEMI DOT COLON LPAR RPAR COMMA SUB BUS LBRACE RBRACE %token SEMI DOT COLON LPAR RPAR COMMA SUB BUS LBRACE RBRACE
%token STAR UPARROW EQUAL MINUS PLUS ASSIGN VBAR DOTDOT %token STAR UPARROW EQUAL MINUS PLUS ASSIGN VBAR DOTDOT
%token BADTOK %token BADTOK
/* keywords */ /* keywords */
%token ARRAY BEGIN CONST DO ELSE ELSIF END IF IMPORT IS OF %token ARRAY BEGIN CONST DO ELSE ELSIF END IF IMPORT IS OF
%token FOR MODULE PROCEDURE RECORD REPEAT RETURN THEN TO TYPE %token FOR MODULE PROCEDURE RECORD REPEAT RETURN THEN TO TYPE
%token UNTIL VAR WHILE NOT POINTER NIL WITH %token UNTIL VAR WHILE NOT POINTER NIL WITH
%token CASE LOOP EXIT BY LOCAL ABSTRACT %token CASE LOOP EXIT BY LOCAL ABSTRACT
...@@ -48,7 +48,7 @@ let rcsid = "$Id: obc.mly,v 1.1 2005/08/23 11:15:14 fpottier Exp $" ...@@ -48,7 +48,7 @@ let rcsid = "$Id: obc.mly,v 1.1 2005/08/23 11:15:14 fpottier Exp $"
%start program %start program
%{ %{
let parse_error msg = let parse_error msg =
syn_error "$ at token '$'" [fStr msg; fToken] syn_error "$ at token '$'" [fStr msg; fToken]
let parse_error2 msg loc2 = let parse_error2 msg loc2 =
...@@ -79,7 +79,7 @@ let make_call e = ...@@ -79,7 +79,7 @@ let make_call e =
let fix e = let fix e =
match e.e_guts with match e.e_guts with
Decimal s -> Decimal s ->
makeExpr (Const (IntVal (Int32.of_string s), numtype), e.e_loc) makeExpr (Const (IntVal (Int32.of_string s), numtype), e.e_loc)
| _ -> e | _ -> e
...@@ -93,12 +93,12 @@ let neg e = ...@@ -93,12 +93,12 @@ let neg e =
let mkExpr e = makeExpr (e, lloc ()) let mkExpr e = makeExpr (e, lloc ())
let mkTypexpr tx = makeTypexpr (tx, lloc ()) let mkTypexpr tx = makeTypexpr (tx, lloc ())
%} %}
%% %%
program : program :
MODULE modname semi imports block opt_ident DOT MODULE modname semi imports block opt_ident DOT
{ check_end $2.x_name $6 (rloc 6); { check_end $2.x_name $6 (rloc 6);
Module ($2, $4, $5, ref []) } ; Module ($2, $4, $5, ref []) } ;
modname : modname :
...@@ -115,22 +115,22 @@ import : ...@@ -115,22 +115,22 @@ import :
name { ($1, $1.x_name, ref 0) } name { ($1, $1.x_name, ref 0) }
| name ASSIGN IDENT { ($1, $3, ref 0) } ; | name ASSIGN IDENT { ($1, $3, ref 0) } ;
block : block :
decls body END { Block ($1, $2, ref 0) } ; decls body END { Block ($1, $2, ref 0) } ;
body : body :
/* empty */ { makeStmt (SkipStmt, no_loc) } /* empty */ { makeStmt (SkipStmt, no_loc) }
| BEGIN stmts { $2 } ; | BEGIN stmts { $2 } ;
decls : decls :
/* empty */ { [] } /* empty */ { [] }
| decls decl { $1 @ $2 } ; | decls decl { $1 @ $2 } ;
decl : decl :
CONST const_decls { $2 } CONST const_decls { $2 }
| VAR var_decls { $2 } | VAR var_decls { $2 }
| TYPE type_decls { $2 } | TYPE type_decls { $2 }
| proc { [$1] } | proc { [$1] }
| error SEMI { [] } ; | error SEMI { [] } ;
const_decls : const_decls :
...@@ -144,7 +144,7 @@ type_decls : ...@@ -144,7 +144,7 @@ type_decls :
type_decl { [$1] } type_decl { [$1] }
| type_decl type_decls { $1 :: $2 } ; | type_decl type_decls { $1 :: $2 } ;
type_decl : type_decl :
defid EQUAL typexpr semi { TypeDecl ($1, $3) } ; defid EQUAL typexpr semi { TypeDecl ($1, $3) } ;
var_decls : var_decls :
...@@ -155,7 +155,7 @@ var_decl : ...@@ -155,7 +155,7 @@ var_decl :
defids COLON typexpr semi { VarDecl (VarDef, $1, $3) } ; defids COLON typexpr semi { VarDecl (VarDef, $1, $3) } ;
proc : proc :
PROCEDURE defid params semi block opt_ident semi PROCEDURE defid params semi block opt_ident semi
{ check_end $2.x_name $6 (rloc 6); { check_end $2.x_name $6 (rloc 6);
ProcDecl (Procedure, $2, $3, $5) } ProcDecl (Procedure, $2, $3, $5) }
| PROCEDURE receiver defid params semi block opt_ident semi | PROCEDURE receiver defid params semi block opt_ident semi
...@@ -166,14 +166,14 @@ proc : ...@@ -166,14 +166,14 @@ proc :
{ let (Heading (ps, r)) = $5 in { let (Heading (ps, r)) = $5 in
ProcDecl (AbsMeth, $4, Heading ($3::ps, r), NoBlock) } ProcDecl (AbsMeth, $4, Heading ($3::ps, r), NoBlock) }
| PROCEDURE defid params IS STRING semi | PROCEDURE defid params IS STRING semi
{ PrimDecl ($2, $3, $5) } { PrimDecl ($2, $3, $5) }
| PROCEDURE error block opt_ident semi | PROCEDURE error block opt_ident semi
{ DummyDecl } ; { DummyDecl } ;
receiver : receiver :
LPAR defid COLON typename RPAR LPAR defid COLON typename RPAR
{ VarDecl(ParamDef, [$2], $4) } { VarDecl(ParamDef, [$2], $4) }
| LPAR VAR defid COLON typename RPAR | LPAR VAR defid COLON typename RPAR
{ VarDecl(VParamDef, [$3], $5) } ; { VarDecl(VParamDef, [$3], $5) } ;
params : params :
...@@ -181,11 +181,11 @@ params : ...@@ -181,11 +181,11 @@ params :
| LPAR RPAR result { Heading ([], $3) } | LPAR RPAR result { Heading ([], $3) }
| LPAR formals RPAR result { Heading ($2, $4) } ; | LPAR formals RPAR result { Heading ($2, $4) } ;
formals : formals :
formal { [$1] } formal { [$1] }
| formal semi formals { $1 :: $3 } ; | formal semi formals { $1 :: $3 } ;
formal : formal :
defids COLON typexpr { VarDecl (ParamDef, $1, $3) } defids COLON typexpr { VarDecl (ParamDef, $1, $3) }
| VAR defids COLON typexpr { VarDecl (VParamDef, $2, $4) } ; | VAR defids COLON typexpr { VarDecl (VParamDef, $2, $4) } ;
...@@ -202,7 +202,7 @@ gracefully with missing and duplicated semicolons. The nonterminal ...@@ -202,7 +202,7 @@ gracefully with missing and duplicated semicolons. The nonterminal
'stmts_a' generates sequences that (if non-empty) end with a 'stmts_a' generates sequences that (if non-empty) end with a
semicolon, and 'stmts_b' generates non-empty sequences that do not end semicolon, and 'stmts_b' generates non-empty sequences that do not end
with a semicolon. Missing semicolons are inserted before any with a semicolon. Missing semicolons are inserted before any
statement that begins with a keyword. statement that begins with a keyword.
The salient fact is that the parser ends up with two states, one The salient fact is that the parser ends up with two states, one
(linked to stmts_a) where it has sen a semicolon and is ready to see (linked to stmts_a) where it has sen a semicolon and is ready to see
...@@ -216,12 +216,12 @@ stmts : ...@@ -216,12 +216,12 @@ stmts :
stmts_a : stmts_a :
/* empty */ { [] } /* empty */ { [] }
| stmts_a SEMI { $1 } | stmts_a SEMI { $1 }
| stmts_b SEMI { $1 } | stmts_b SEMI { $1 }
| stmts_b error SEMI { $1 } ; | stmts_b error SEMI { $1 } ;
stmts_b : stmts_b :
stmts_a stmt0 { makeStmt ($2, rloc 2) :: $1 } stmts_a stmt0 { makeStmt ($2, rloc 2) :: $1 }
| stmts_a stmt1 { makeStmt ($2, rloc 2) :: $1 } | stmts_a stmt1 { makeStmt ($2, rloc 2) :: $1 }
| stmts_b missing stmt1 { makeStmt ($3, rloc 3) :: $1 } ; | stmts_b missing stmt1 { makeStmt ($3, rloc 3) :: $1 } ;
missing : missing :
...@@ -244,8 +244,8 @@ stmt1 : ...@@ -244,8 +244,8 @@ stmt1 :
| LOOP stmts END { LoopStmt $2 } | LOOP stmts END { LoopStmt $2 }
| EXIT { ExitStmt } | EXIT { ExitStmt }
| FOR designator ASSIGN expr TO expr by_part DO stmts END | FOR designator ASSIGN expr TO expr by_part DO stmts END
{ ForStmt ($2, $4, $6, $7, $9, ref dummy_def) } { ForStmt ($2, $4, $6, $7, $9, ref dummy_def) }
| WITH with_branches else_part END | WITH with_branches else_part END
{ WithStmt ($2, $3) } { WithStmt ($2, $3) }
| LOCAL decls body END { LocalStmt ($2, $3) } | LOCAL decls body END { LocalStmt ($2, $3) }
| error { ErrStmt } ; | error { ErrStmt } ;
...@@ -293,7 +293,7 @@ by_part : ...@@ -293,7 +293,7 @@ by_part :
expr : expr :
simple %prec error { $1 } simple %prec error { $1 }
| simple RELOP simple { mkExpr (Binop ($2, $1, $3)) } | simple RELOP simple { mkExpr (Binop ($2, $1, $3)) }
| simple EQUAL simple { mkExpr (Binop (Eq, $1, $3)) } | simple EQUAL simple { mkExpr (Binop (Eq, $1, $3)) }
| simple IS qualid { mkExpr (TypeTest ($1, $3)) } ; | simple IS qualid { mkExpr (TypeTest ($1, $3)) } ;
simple : simple :
...@@ -314,16 +314,16 @@ factor : ...@@ -314,16 +314,16 @@ factor :
| DECIMAL { mkExpr (Decimal $1) } | DECIMAL { mkExpr (Decimal $1) }
| FLOCON { mkExpr (Const (FloVal $1, realtype)) } | FLOCON { mkExpr (Const (FloVal $1, realtype)) }
| DBLCON { mkExpr (Const (FloVal $1, longreal)) } | DBLCON { mkExpr (Const (FloVal $1, longreal)) }
| CHAR { mkExpr (Const (IntVal (Int32.of_int | CHAR { mkExpr (Const (IntVal (Int32.of_int
(int_of_char $1)), character)) } (int_of_char $1)), character)) }
| STRING { mkExpr (String (save_string $1, | STRING { mkExpr (String (save_string $1,
String.length $1)) } String.length $1)) }
| NIL { mkExpr Nil } | NIL { mkExpr Nil }
| designator %prec error { $1 } | designator %prec error { $1 }
| LBRACE RBRACE { mkExpr (Set []) } | LBRACE RBRACE { mkExpr (Set []) }
| LBRACE elements RBRACE { mkExpr (Set $2) } | LBRACE elements RBRACE { mkExpr (Set $2) }
| NOT factor { mkExpr (Monop (Not, fix $2)) } | NOT factor { mkExpr (Monop (Not, fix $2)) }
| LPAR expr RPAR { $2 } | LPAR expr RPAR { $2 }
| LPAR expr %prec error { parse_error2 "mismatched brackets" (rloc 1); | LPAR expr %prec error { parse_error2 "mismatched brackets" (rloc 1);
raise Parse_error } ; raise Parse_error } ;
...@@ -332,32 +332,32 @@ designator : ...@@ -332,32 +332,32 @@ designator :
| designator UPARROW { mkExpr (Deref $1) } | designator UPARROW { mkExpr (Deref $1) }
| designator SUB exprs BUS { let sub a i = mkExpr (Sub (a, i)) in | designator SUB exprs BUS { let sub a i = mkExpr (Sub (a, i)) in
List.fold_left sub $1 $3 } List.fold_left sub $1 $3 }
| designator SUB exprs %prec error | designator SUB exprs %prec error
{ parse_error2 "mismatched brackets" (rloc 2); { parse_error2 "mismatched brackets" (rloc 2);
raise Parse_error } raise Parse_error }
| designator DOT name { mkExpr (Select ($1, $3)) } | designator DOT name { mkExpr (Select ($1, $3)) }
| designator actuals { mkExpr (FuncCall ($1, $2)) } ; | designator actuals { mkExpr (FuncCall ($1, $2)) } ;
actuals : actuals :
LPAR RPAR { [] } LPAR RPAR { [] }
| LPAR exprs RPAR { $2 } | LPAR exprs RPAR { $2 }
| LPAR exprs %prec error { parse_error2 | LPAR exprs %prec error { parse_error2
"mismatched brackets in procedure call" "mismatched brackets in procedure call"
(rloc 1); (rloc 1);
raise Parse_error } ; raise Parse_error } ;
exprs : exprs :
expr %prec error { [$1] } expr %prec error { [$1] }
| expr COMMA exprs { $1 :: $3 } ; | expr COMMA exprs { $1 :: $3 } ;
typexpr : typexpr :
typename { $1 } typename { $1 }
| LPAR defids RPAR { mkTypexpr (Enum $2) } | LPAR defids RPAR { mkTypexpr (Enum $2) }
| POINTER TO typexpr { mkTypexpr (Pointer $3) } | POINTER TO typexpr { mkTypexpr (Pointer $3) }
| ARRAY exprs OF typexpr { let array n t = mkTypexpr (Array (n, t)) in | ARRAY exprs OF typexpr { let array n t = mkTypexpr (Array (n, t)) in
List.fold_right array $2 $4 } List.fold_right array $2 $4 }
| ARRAY OF typexpr { mkTypexpr (Flex $3) } | ARRAY OF typexpr { mkTypexpr (Flex $3) }
| absmark RECORD parent fields END | absmark RECORD parent fields END
{ mkTypexpr (Record ($1, $3, $4)) } { mkTypexpr (Record ($1, $3, $4)) }
| PROCEDURE params { mkTypexpr (Proc $2) } ; | PROCEDURE params { mkTypexpr (Proc $2) } ;
...@@ -376,15 +376,15 @@ fields : ...@@ -376,15 +376,15 @@ fields :
fieldlist { $1 } fieldlist { $1 }
| fieldlist SEMI fields { $1 @ $3 } ; | fieldlist SEMI fields { $1 @ $3 } ;
fieldlist : fieldlist :
/* empty */ { [] } /* empty */ { [] }
| defids COLON typexpr { [VarDecl (FieldDef, $1, $3)] } ; | defids COLON typexpr { [VarDecl (FieldDef, $1, $3)] } ;
qualid : qualid :
IDENT %prec DOT { makeName (!current, $1, lloc ()) } IDENT %prec DOT { makeName (!current, $1, lloc ()) }
| IDENT DOT IDENT { makeName ($1, $3, lloc ()) }; | IDENT DOT IDENT { makeName ($1, $3, lloc ()) };
name : name :
IDENT { makeName (!current, $1, lloc ()) } ; IDENT { makeName (!current, $1, lloc ()) } ;
defids : defids :
......
%start<unit> s %start<unit> s
%token A %token A
%% %%
s: A _1=A { () } s: A _1=A { () }
%start<int> a %start<int> a
%% %%
a: { $startpos(x) } a: { $startpos(x) }
%start<int> a %start<int> a
%token A %token A
%% %%
......
/* /*
* Parts of this file taken from the fullfsub implementation * Parts of this file taken from the fullfsub implementation
* by the POPLmark team. * by the POPLmark team.
* *
...@@ -68,9 +68,9 @@ Type : ...@@ -68,9 +68,9 @@ Type :
/* Atomic types are those that never need extra parentheses */ /* Atomic types are those that never need extra parentheses */
AType : AType :
| LPAREN Type RPAREN | LPAREN Type RPAREN
{ $2 } { $2 }
| UCID | UCID
{ TVar $1 } { TVar $1 }
| TTOP | TTOP
{ TTop } { TTop }
...@@ -94,7 +94,7 @@ ArrowType : ...@@ -94,7 +94,7 @@ ArrowType :
Term : Term :
| AppTerm | AppTerm
{ $1 } { $1 }
| LAMBDA LCID COLON Type DOT Term | LAMBDA LCID COLON Type DOT Term
{ EAbs ($2, $4, $6) } { EAbs ($2, $4, $6) }
| LET Pattern EQ Term IN Term | LET Pattern EQ Term IN Term
{ ELet ($2, $4, $6) } { ELet ($2, $4, $6) }
...@@ -128,16 +128,16 @@ NEFieldTypes : ...@@ -128,16 +128,16 @@ NEFieldTypes :
{ StringMap.add $1 $3 $5 } { StringMap.add $1 $3 $5 }
TermSeq : TermSeq :
| Term | Term
{ $1 } { $1 }
| Term SEMI TermSeq | Term SEMI TermSeq
{ ELet (PWildcard, $1, $3) } { ELet (PWildcard, $1, $3) }
/* Atomic terms are ones that never require extra parentheses */ /* Atomic terms are ones that never require extra parentheses */
ATerm : ATerm :
| LPAREN TermSeq RPAREN | LPAREN TermSeq RPAREN
{ $2 } { $2 }
| LCID | LCID
{ EVar $1 } { EVar $1 }
| LCURLY Fields RCURLY | LCURLY Fields RCURLY
{ ERecord $2 } { ERecord $2 }
...@@ -157,7 +157,7 @@ NEFields : ...@@ -157,7 +157,7 @@ NEFields :
OType : OType :
| /* empty */ | /* empty */
{ TTop} { TTop}
| LEQ Type | LEQ Type
{ $2 } { $2 }
Pattern : Pattern :
......
/* Yet another attempt to parse nicely. /* Yet another attempt to parse nicely.
This parses to tree-structured preterms with remaining ambiguity as follows: This parses to tree-structured preterms with remaining ambiguity as follows:
1. Commas might be either pair constructors 1. Commas might be either pair constructors
(within parens inside terms) or and-constructors (within parens inside terms) or and-constructors
(outside of propositions). (outside of propositions).
2. Identifiers are not resolved to syntactic classes 2. Identifiers are not resolved to syntactic classes
(e.g. atom, variable, term symbol). (e.g. atom, variable, term symbol).
These preterms are the input to typechecking, These preterms are the input to typechecking,
Typechecking resolves identifiers to variables, symbols, or atoms Typechecking resolves identifiers to variables, symbols, or atoms
and translates propositions to goals/program clauses and translates propositions to goals/program clauses
and translates terms to internal terms. and translates terms to internal terms.
*/ */
%{ %{
open Absyn;; open Absyn;;
...@@ -17,9 +17,9 @@ open Nstbl;; ...@@ -17,9 +17,9 @@ open Nstbl;;
type quantifier = QForall | QExists | QNew;; type quantifier = QForall | QExists | QNew;;
let do_quantify q tvs e = let do_quantify q tvs e =
let do_quantifier q (tv,st) e = let do_quantifier q (tv,st) e =
match q with match q with
QForall -> Forall(tv,st,e) QForall -> Forall(tv,st,e)
| QExists -> Exists(tv,st,e) | QExists -> Exists(tv,st,e)
| QNew -> New(tv,st,e) | QNew -> New(tv,st,e)
...@@ -27,9 +27,9 @@ let do_quantify q tvs e = ...@@ -27,9 +27,9 @@ let do_quantify q tvs e =
List.fold_right (do_quantifier q) tvs e List.fold_right (do_quantifier q) tvs e
;; ;;
let do_literal' s t = let do_literal' s t =
let n = String.length s in let n = String.length s in
let rec go i = let rec go i =
if i = n then t if i = n then t
else Cons(CharC(String.get s i), go (i+1)) else Cons(CharC(String.get s i), go (i+1))
in go 0 in go 0
...@@ -43,47 +43,47 @@ type dcg_term = Nonterm of atomic | Char of char | Seq of dcg_term * dcg_term ...@@ -43,47 +43,47 @@ type dcg_term = Nonterm of atomic | Char of char | Seq of dcg_term * dcg_term
;; ;;
let translate_dcg (hd,tl) t = let translate_dcg (hd,tl) t =
let rec tr t x y = let rec tr t x y =
match t with match t with
Char c -> Eq(Var x, Cons(CharC c, Var y)) Char c -> Eq(Var x, Cons(CharC c, Var y))
| Literal s -> Eq (Var x, do_literal' s (Var y)) | Literal s -> Eq (Var x, do_literal' s (Var y))
| Seq (t1,t2) -> | Seq (t1,t2) ->
let w = Var.mkvar "W" in let w = Var.mkvar "W" in
And(tr t1 x w, tr t2 w y) And(tr t1 x w, tr t2 w y)
| Alt(t1,t2) -> | Alt(t1,t2) ->
Or(tr t1 x y, tr t2 x y) Or(tr t1 x y, tr t2 x y)
| Goal(t) -> | Goal(t) ->
And(Eq(Var x,Var y), t) And(Eq(Var x,Var y), t)
| Nonterm (hd,tl) -> | Nonterm (hd,tl) ->
Atomic(hd,tl@[Var x; Var y]) Atomic(hd,tl@[Var x; Var y])
in in
let x = Var.mkvar "X" in let x = Var.mkvar "X" in
let y = Var.mkvar "Y" in let y = Var.mkvar "Y" in
Implies(tr t x y, Atomic(hd,tl@[Var x; Var y])) Implies(tr t x y, Atomic(hd,tl@[Var x; Var y]))