
https://svn.lrde.epita.fr/svn/oln/trunk Index: ChangeLog from Quentin Hocquet <mefyl@lrde.epita.fr> Scool parser. * tools: New. * tools/test.yml: New. * tools/transformer: New. * tools/transformer/scoolc.str: New. * tools/transformer/Makefile: New. * tools/tests: New. * tools/tests/syntax error: New. * tools/tests/syntax error/wrong.scl: New. * tools/tests/parse-ref: New. * tools/tests/parse-ref/vardec.ref: New. * tools/tests/parse-ref/fundec.ref: New. * tools/tests/parse-ref/funcall_no-args.ref: New. * tools/tests/parse-ref/emtpy-class_dec.ref: New. * tools/tests/parse-ref/empty-class_dec.ref: New. * tools/tests/parse-ref/varinit.ref: New. * tools/tests/parse-ref/no-args_funtype.ref: New. * tools/tests/parse-ref/manydec.ref: New. * tools/tests/parse-ref/class_dec.ref: New. * tools/tests/parse-ref/wiki1.ref: New. * tools/tests/parse-ref/funcall.ref: New. * tools/tests/parse-ref/bi-exp.ref: New. * tools/tests/parse-ref/function.ref: New. * tools/tests/parse-ref/wiki2.ref: New. * tools/tests/parse-ref/consinit.ref: New. * tools/tests/parse-ref/wiki3.ref: New. * tools/tests/parse-ref/funtype.ref: New. * tools/tests/parse-ref/empty.ref: New. * tools/tests/parse-ref/type_static-call.ref: New. * tools/tests/parse-ref/guard.ref: New. * tools/tests/good: New. * tools/tests/good/type_static-call.scl: New. * tools/tests/good/guard.scl: New. * tools/tests/good/fundec.scl: New. * tools/tests/good/vardec.scl: New. * tools/tests/good/funcall_no-args.scl: New. * tools/tests/good/varinit.scl: New. * tools/tests/good/empty-class_dec.scl: New. * tools/tests/good/manydec.scl: New. * tools/tests/good/class_dec.scl: New. * tools/tests/good/no-args_funtype.scl: New. * tools/tests/good/bi-exp.scl: New. * tools/tests/good/wiki1.scl: New. * tools/tests/good/funcall.scl: New. * tools/tests/good/wiki2.scl: New. * tools/tests/good/function.scl: New. * tools/tests/good/consinit.scl: New. * tools/tests/good/wiki3.scl: New. * tools/tests/good/funtype.scl: New. * tools/tests/good/empty.scl: New. * tools/scoolc: New. * tools/gen.yml: New. * tools/parser: New. * tools/parser/grammar: New. * tools/parser/grammar/Class.sdf: New. * tools/parser/grammar/Decl.sdf: New. * tools/parser/grammar/Exp.sdf: New. * tools/parser/grammar/ExpOrType.sdf: New. * tools/parser/grammar/Scool.sdf: New. * tools/parser/grammar/Lexical.sdf: New. * tools/parser/grammar/Type.sdf: New. * tools/parser/grammar/Guard.sdf: New. * tools/parser/grammar/Stm.sdf: New. * tools/parser/parse-scool: New. * tools/parser/Makefile: New. * tools/Makefile: New. Makefile | 14 ++++++++++ gen.yml | 9 ++++++ parser/Makefile | 20 ++++++++++++++ parser/grammar/Class.sdf | 18 +++++++++++++ parser/grammar/Decl.sdf | 48 +++++++++++++++++++++++++++++++++++ parser/grammar/Exp.sdf | 43 +++++++++++++++++++++++++++++++ parser/grammar/ExpOrType.sdf | 12 ++++++++ parser/grammar/Guard.sdf | 10 +++++++ parser/grammar/Lexical.sdf | 28 ++++++++++++++++++++ parser/grammar/Scool.sdf | 11 ++++++++ parser/grammar/Stm.sdf | 17 ++++++++++++ parser/grammar/Type.sdf | 18 +++++++++++++ parser/parse-scool | 8 +++++ scoolc | 4 ++ test.yml | 18 +++++++++++++ tests/good/bi-exp.scl | 1 tests/good/class_dec.scl | 15 ++++++++++ tests/good/consinit.scl | 1 tests/good/empty-class_dec.scl | 1 tests/good/funcall.scl | 4 ++ tests/good/funcall_no-args.scl | 4 ++ tests/good/function.scl | 4 ++ tests/good/fundec.scl | 2 + tests/good/funtype.scl | 1 tests/good/guard.scl | 1 tests/good/manydec.scl | 4 ++ tests/good/no-args_funtype.scl | 1 tests/good/type_static-call.scl | 1 tests/good/vardec.scl | 1 tests/good/varinit.scl | 1 tests/good/wiki1.scl | 9 ++++++ tests/good/wiki2.scl | 5 +++ tests/good/wiki3.scl | 9 ++++++ tests/parse-ref/bi-exp.ref | 1 tests/parse-ref/class_dec.ref | 1 tests/parse-ref/consinit.ref | 1 tests/parse-ref/empty-class_dec.ref | 1 tests/parse-ref/empty.ref | 1 tests/parse-ref/funcall.ref | 1 tests/parse-ref/funcall_no-args.ref | 1 tests/parse-ref/function.ref | 1 tests/parse-ref/fundec.ref | 1 tests/parse-ref/funtype.ref | 1 tests/parse-ref/guard.ref | 1 tests/parse-ref/manydec.ref | 1 tests/parse-ref/no-args_funtype.ref | 1 tests/parse-ref/type_static-call.ref | 1 tests/parse-ref/vardec.ref | 1 tests/parse-ref/varinit.ref | 1 tests/parse-ref/wiki1.ref | 1 tests/parse-ref/wiki2.ref | 1 tests/parse-ref/wiki3.ref | 1 tests/syntax | 1 transformer/Makefile | 6 ++++ transformer/scoolc.str | 6 ++++ 55 files changed, 375 insertions(+) Index: tools/test.yml --- tools/test.yml (revision 0) +++ tools/test.yml (revision 0) @@ -0,0 +1,18 @@ +--- +Test of the Scool parser: !S::Suite + contents: + - Valid input tests: !S::Iterate + over: !pathlist <<pwd>>/tests/good/(*).scl + iter: [it_file, it_name] + test: + Test <<it_name>>: !S::Cmd + command: parser/parse-scool "<<it_file>>" + exit: 0 + output: !path "tests/parse-ref/<<it_name>>.ref" + - Wrong input tests: !S::Iterate + over: !pathlist "<<pwd>>/tests/syntax error/(*).scl" + iter: [it_file, it_name] + test: + Test <<it_name>>: !S::Cmd + command: parser/parse-scool "<<it_file>>" + exit: 1 Index: tools/transformer/scoolc.str --- tools/transformer/scoolc.str (revision 0) +++ tools/transformer/scoolc.str (revision 0) @@ -0,0 +1,6 @@ +module scoolc + +imports liblib Scool + +strategies + main = io-wrap(id) Index: tools/transformer/Makefile --- tools/transformer/Makefile (revision 0) +++ tools/transformer/Makefile (revision 0) @@ -0,0 +1,6 @@ + +scoolc: scoolc.str + strc -i $< -I ../parser -la stratego-lib + +clean: + rm -rf scoolc scoolc.dep scoolc.o scoolc.c .libs Index: tools/tests/syntax error/wrong.scl --- tools/tests/syntax error/wrong.scl (revision 0) +++ tools/tests/syntax error/wrong.scl (revision 0) @@ -0,0 +1 @@ +var i::int; Index: tools/tests/parse-ref/vardec.ref --- tools/tests/parse-ref/vardec.ref (revision 0) +++ tools/tests/parse-ref/vardec.ref (revision 0) @@ -0,0 +1 @@ +Program([VarDec("i",Var("int"))]) Index: tools/tests/parse-ref/fundec.ref --- tools/tests/parse-ref/fundec.ref (revision 0) +++ tools/tests/parse-ref/fundec.ref (revision 0) @@ -0,0 +1 @@ +Program([FunDec("f",[("a",Var("int")),("b",Var("int"))],Var("bool"),[])]) Index: tools/tests/parse-ref/funcall_no-args.ref --- tools/tests/parse-ref/funcall_no-args.ref (revision 0) +++ tools/tests/parse-ref/funcall_no-args.ref (revision 0) @@ -0,0 +1 @@ +Program([FunDec("doit",[],Var("int"),[Return(FunCall("chiche",[]))])]) Index: tools/tests/parse-ref/emtpy-class_dec.ref Index: tools/tests/parse-ref/empty-class_dec.ref --- tools/tests/parse-ref/empty-class_dec.ref (revision 0) +++ tools/tests/parse-ref/empty-class_dec.ref (revision 0) @@ -0,0 +1 @@ +Program([ConsDec("foo",Class,Class([]))]) Index: tools/tests/parse-ref/varinit.ref --- tools/tests/parse-ref/varinit.ref (revision 0) +++ tools/tests/parse-ref/varinit.ref (revision 0) @@ -0,0 +1 @@ +Program([VarDec("i",Var("int"),Int("42"))]) Index: tools/tests/parse-ref/no-args_funtype.ref --- tools/tests/parse-ref/no-args_funtype.ref (revision 0) +++ tools/tests/parse-ref/no-args_funtype.ref (revision 0) @@ -0,0 +1 @@ +Program([VarDec("f",FunType([],Var("void")))]) Index: tools/tests/parse-ref/manydec.ref --- tools/tests/parse-ref/manydec.ref (revision 0) +++ tools/tests/parse-ref/manydec.ref (revision 0) @@ -0,0 +1 @@ +Program([ConsDec("answer",Var("int"),Int("42")),VarDec("i",Var("int")),VarDec("j",Var("int"),Var("i"))]) Index: tools/tests/parse-ref/class_dec.ref --- tools/tests/parse-ref/class_dec.ref (revision 0) +++ tools/tests/parse-ref/class_dec.ref (revision 0) @@ -0,0 +1 @@ +Program([ConsDec("point",Class,Class([Accessblock(Public,[FunDec("x",[],Var("int"),[Return(Var("x"))])]),Accessblock(Private,[VarDec("x",Var("int")),VarDec("y",Var("int"))])]))]) Index: tools/tests/parse-ref/wiki1.ref --- tools/tests/parse-ref/wiki1.ref (revision 0) +++ tools/tests/parse-ref/wiki1.ref (revision 0) @@ -0,0 +1 @@ +Program([FunDec("f",[],Var("void"),[ConsDec("i",Var("int16"),Int("3")),ExpStm(Affect(Var("i"),Int("4"))),VarDec("j",Var("int16"),Int("3")),ExpStm(Affect(Var("j"),Int("4")))])]) Index: tools/tests/parse-ref/funcall.ref --- tools/tests/parse-ref/funcall.ref (revision 0) +++ tools/tests/parse-ref/funcall.ref (revision 0) @@ -0,0 +1 @@ +Program([FunDec("doit",[],Var("int"),[Return(FunCall("chiche",[String("\"pelle\""),String("\"branle\"")]))])]) Index: tools/tests/parse-ref/bi-exp.ref --- tools/tests/parse-ref/bi-exp.ref (revision 0) +++ tools/tests/parse-ref/bi-exp.ref (revision 0) @@ -0,0 +1 @@ +Program([ConsDec("i",Var("int"),BiFunCall("pow",[Int("4")],[Int("3")]))]) Index: tools/tests/parse-ref/function.ref --- tools/tests/parse-ref/function.ref (revision 0) +++ tools/tests/parse-ref/function.ref (revision 0) @@ -0,0 +1 @@ +Program([FunDec("answer",[],Var("int"),[Return(Int("42"))])]) Index: tools/tests/parse-ref/wiki2.ref --- tools/tests/parse-ref/wiki2.ref (revision 0) +++ tools/tests/parse-ref/wiki2.ref (revision 0) @@ -0,0 +1 @@ +Program([FunDec("f",[],Var("void"),[VarDec("a",StaticFunCall("array",[Int("2"),Var("int16")])),VarDec("i",Var("int16"),MethodCall("a","at",[Int("0")]))])]) Index: tools/tests/parse-ref/consinit.ref --- tools/tests/parse-ref/consinit.ref (revision 0) +++ tools/tests/parse-ref/consinit.ref (revision 0) @@ -0,0 +1 @@ +Program([ConsDec("i",Var("int"),Int("3"))]) Index: tools/tests/parse-ref/wiki3.ref --- tools/tests/parse-ref/wiki3.ref (revision 0) +++ tools/tests/parse-ref/wiki3.ref (revision 0) @@ -0,0 +1 @@ +Program([FunDec("f",[],Var("void"),[VarDec("i",Var("int")),VarDec("j",Var("int")),ExpStm(Affect(Var("i"),Int("0"))),ExpStm(Affect(Var("j"),Var("i"))),ExpStm(Affect(Var("i"),Sum(Var("j"),Var("i"))))])]) Index: tools/tests/parse-ref/funtype.ref --- tools/tests/parse-ref/funtype.ref (revision 0) +++ tools/tests/parse-ref/funtype.ref (revision 0) @@ -0,0 +1 @@ +Program([VarDec("f",FunType([Var("int"),Var("bool")],Var("float")))]) Index: tools/tests/parse-ref/empty.ref --- tools/tests/parse-ref/empty.ref (revision 0) +++ tools/tests/parse-ref/empty.ref (revision 0) @@ -0,0 +1 @@ +Program([]) Index: tools/tests/parse-ref/type_static-call.ref --- tools/tests/parse-ref/type_static-call.ref (revision 0) +++ tools/tests/parse-ref/type_static-call.ref (revision 0) @@ -0,0 +1 @@ +Program([VarDec("l",StaticFunCall("list",[Var("int")]))]) Index: tools/tests/parse-ref/guard.ref --- tools/tests/parse-ref/guard.ref (revision 0) +++ tools/tests/parse-ref/guard.ref (revision 0) @@ -0,0 +1 @@ +Program([BiFunDec("f",[("i",Var("int"),Guard(Sup(Var("i"),Int("0"))))],[],Var("int"),[])]) Index: tools/tests/good/type_static-call.scl --- tools/tests/good/type_static-call.scl (revision 0) +++ tools/tests/good/type_static-call.scl (revision 0) @@ -0,0 +1 @@ +var l : list[int]; Index: tools/tests/good/guard.scl --- tools/tests/good/guard.scl (revision 0) +++ tools/tests/good/guard.scl (revision 0) @@ -0,0 +1 @@ +f : [i : int where i > 0]() -> int = {} \ No newline at end of file Index: tools/tests/good/fundec.scl --- tools/tests/good/fundec.scl (revision 0) +++ tools/tests/good/fundec.scl (revision 0) @@ -0,0 +1,2 @@ +f : (a: int, b : int) -> bool = +{} Index: tools/tests/good/vardec.scl --- tools/tests/good/vardec.scl (revision 0) +++ tools/tests/good/vardec.scl (revision 0) @@ -0,0 +1 @@ +var i : int; Index: tools/tests/good/funcall_no-args.scl --- tools/tests/good/funcall_no-args.scl (revision 0) +++ tools/tests/good/funcall_no-args.scl (revision 0) @@ -0,0 +1,4 @@ +doit : () -> int = +{ + -> chiche(); +} \ No newline at end of file Index: tools/tests/good/varinit.scl --- tools/tests/good/varinit.scl (revision 0) +++ tools/tests/good/varinit.scl (revision 0) @@ -0,0 +1 @@ +var i : int := 42; Index: tools/tests/good/empty-class_dec.scl --- tools/tests/good/empty-class_dec.scl (revision 0) +++ tools/tests/good/empty-class_dec.scl (revision 0) @@ -0,0 +1 @@ +foo : class = {}; \ No newline at end of file Index: tools/tests/good/manydec.scl --- tools/tests/good/manydec.scl (revision 0) +++ tools/tests/good/manydec.scl (revision 0) @@ -0,0 +1,4 @@ +answer : int = 42; + +var i : int; +var j : int := i; Index: tools/tests/good/class_dec.scl --- tools/tests/good/class_dec.scl (revision 0) +++ tools/tests/good/class_dec.scl (revision 0) @@ -0,0 +1,15 @@ +point : class = +{ + public + { + x : () -> int = + { + -> x; + } + } + private + { + var x :int; + var y :int; + } +}; \ No newline at end of file Index: tools/tests/good/no-args_funtype.scl --- tools/tests/good/no-args_funtype.scl (revision 0) +++ tools/tests/good/no-args_funtype.scl (revision 0) @@ -0,0 +1 @@ +var f : () -> void; \ No newline at end of file Index: tools/tests/good/bi-exp.scl --- tools/tests/good/bi-exp.scl (revision 0) +++ tools/tests/good/bi-exp.scl (revision 0) @@ -0,0 +1 @@ +i : int = pow[4](3); \ No newline at end of file Index: tools/tests/good/wiki1.scl --- tools/tests/good/wiki1.scl (revision 0) +++ tools/tests/good/wiki1.scl (revision 0) @@ -0,0 +1,9 @@ + +f : () -> void = +{ + i : int16 = 3; + i := 4; + + var j : int16 := 3; + j := 4; +} \ No newline at end of file Index: tools/tests/good/funcall.scl --- tools/tests/good/funcall.scl (revision 0) +++ tools/tests/good/funcall.scl (revision 0) @@ -0,0 +1,4 @@ +doit : () -> int = +{ + -> chiche("pelle", "branle"); +} \ No newline at end of file Index: tools/tests/good/wiki2.scl --- tools/tests/good/wiki2.scl (revision 0) +++ tools/tests/good/wiki2.scl (revision 0) @@ -0,0 +1,5 @@ +f : () -> void = +{ + var a : array[2,int16]; + var i : int16 := a.at(0); +} Index: tools/tests/good/function.scl --- tools/tests/good/function.scl (revision 0) +++ tools/tests/good/function.scl (revision 0) @@ -0,0 +1,4 @@ +answer : () -> int = +{ + -> 42; +} \ No newline at end of file Index: tools/tests/good/consinit.scl --- tools/tests/good/consinit.scl (revision 0) +++ tools/tests/good/consinit.scl (revision 0) @@ -0,0 +1 @@ +i : int = 3; \ No newline at end of file Index: tools/tests/good/wiki3.scl --- tools/tests/good/wiki3.scl (revision 0) +++ tools/tests/good/wiki3.scl (revision 0) @@ -0,0 +1,9 @@ +f : () -> void = +{ + var i : int; + var j : int; + + i := 0; + j := i; + i := j + i; +} Index: tools/tests/good/funtype.scl --- tools/tests/good/funtype.scl (revision 0) +++ tools/tests/good/funtype.scl (revision 0) @@ -0,0 +1 @@ +var f : (int, bool) -> float; \ No newline at end of file Index: tools/tests/good/empty.scl Index: tools/scoolc --- tools/scoolc (revision 0) +++ tools/scoolc (revision 0) @@ -0,0 +1,4 @@ +#!/bin/sh +# -*- sh -*- + +parser/parse-scool $1 | transformer/scoolc Property changes on: tools/scoolc ___________________________________________________________________ Name: svn:executable + * Index: tools/gen.yml --- tools/gen.yml (revision 0) +++ tools/gen.yml (revision 0) @@ -0,0 +1,9 @@ +--- +Autogeneration of the Scool parser references: !S::Suite + contents: + - Generation: !S::Iterate + over: !pathlist <<pwd>>/tests/good/(*).scl + iter: [it_file, it_name] + test: + Generation <<it_name>>: !S::Cmd + command: parser/parse-scool "<<it_file>>" > "<<pwd>>/tests/good/<<it_name>>.ref" Index: tools/parser/grammar/Class.sdf --- tools/parser/grammar/Class.sdf (revision 0) +++ tools/parser/grammar/Class.sdf (revision 0) @@ -0,0 +1,18 @@ +module Class + +imports + Lexical Decl + +exports + sorts Class AccessBlock AccessModifier + context-free syntax + "{" AccessBlock* "}" -> Class {cons("Class")} + + AccessModifier "{" Decl* "}" -> AccessBlock {cons("Accessblock")} + + "public" -> AccessModifier {cons("Public")} + "protected" -> AccessModifier {cons("Protected")} + "private" -> AccessModifier {cons("Private")} + + lexical restrictions + AccessModifier -/- [A-Za-z] Index: tools/parser/grammar/Decl.sdf --- tools/parser/grammar/Decl.sdf (revision 0) +++ tools/parser/grammar/Decl.sdf (revision 0) @@ -0,0 +1,48 @@ +module Decl + +imports + Lexical Type Guard Stm + +exports + sorts Decl + context-free syntax + + "var" Id ":" Type ";" -> Decl {cons("VarDec")} + "var" Id ":" Type ":=" Exp ";" -> Decl {cons("VarDec")} + Id ":" Type "=" Exp ";" -> Decl {cons("ConsDec")} + Id ":" Type ";" -> Decl {cons("ConsDec")} + + Id ":" "(" {(Id ":" Type) ","}* ")" "->" Type + "=" "{" Stm* "}" -> Decl {cons("FunDec")} + + Id ":" "[" {(Id ":" Type Guard) ","}* "]" "->" Type + "=" "{" Stm* "}" -> Decl {cons("StaticFunDec")} + + Id ":" "[" {(Id ":" Type Guard) ","}* "]" "(" {(Id ":" Type) ","}* ")" "->" Type + "=" "{" Stm* "}" -> Decl {cons("BiFunDec")} + + Id ":" "(" {(Id ":" Type) ","}* ")" "->" Type + "=>" Exp -> Decl {cons("FunDec")} + + Id ":" "[" {(Id ":" Type Guard) ","}* "]" "->" Type + "=>" Exp -> Decl {cons("StaticFunDec")} + + Id ":" "[" {(Id ":" Type Guard) ","}* "]" "(" {(Id ":" Type) ","}* ")" "->" Type + "=>" Exp -> Decl {cons("BiFunDec")} + + + "decl" Id ":" "(" {(Type | (Id ":" Type)) ","}* ")" + "->" Type ";" -> Decl {cons("FunPreDec")} + + + Id ":" "[" {(Id ":" Type) ","}* "]" "->" Type + "=" "{" Stm* "}" -> Decl {cons("StaticFunDec")} + + Id ":" "[" {(Id ":" Type) ","}* "]" "(" {(Id ":" Type) ","}* ")" "->" Type + "=" "{" Stm* "}" -> Decl {cons("BiFunDec")} + + Id ":" "[" {(Id ":" Type) ","}* "]" "->" Type + "=>" Exp -> Decl {cons("StaticFunDec")} + + Id ":" "[" {(Id ":" Type) ","}* "]" "(" {(Id ":" Type) ","}* ")" "->" Type + "=>" Exp -> Decl {cons("BiFunDec")} \ No newline at end of file Index: tools/parser/grammar/Exp.sdf --- tools/parser/grammar/Exp.sdf (revision 0) +++ tools/parser/grammar/Exp.sdf (revision 0) @@ -0,0 +1,43 @@ +module Exp + +imports + Lexical Type ExpOrType Class + +exports + sorts Exp + context-free syntax + + ExpOrType -> Exp + Int -> Exp {cons("Int")} + String -> Exp {cons("String")} + Id "(" {Exp ","}* ")" -> Exp {cons("FunCall")} + Id "[" {Exp ","}* "]" + "(" {Exp ","}* ")" -> Exp {cons("BiFunCall")} + Exp "+" Exp -> Exp {cons("Sum")} + Exp "-" Exp -> Exp {cons("Sub")} + Exp "*" Exp -> Exp {cons("Mul")} + Exp "/" Exp -> Exp {cons("Div")} + Exp "=" Exp -> Exp {cons("Eq")} + Exp "!=" Exp -> Exp {cons("Neq")} + Exp "<" Exp -> Exp {cons("Inf")} + Exp ">" Exp -> Exp {cons("Sup")} + Exp ">=" Exp -> Exp {cons("SupEq")} + Exp "<=" Exp -> Exp {cons("InfEq")} + Exp ":=" Exp -> Exp {cons("Affect")} + Class -> Exp + Exp "." Id -> Exp {cons("Field")} + Id "." Id "(" {Exp ","}* ")" -> Exp {cons("MethodCall")} + + context-free priorities + + {left: + Exp "/" Exp -> Exp + Exp "*" Exp -> Exp + } +> {left: + Exp "+" Exp -> Exp + Exp "-" Exp -> Exp + } +> {right: + Exp ":=" Exp -> Exp + } \ No newline at end of file Index: tools/parser/grammar/ExpOrType.sdf --- tools/parser/grammar/ExpOrType.sdf (revision 0) +++ tools/parser/grammar/ExpOrType.sdf (revision 0) @@ -0,0 +1,12 @@ +module ExpOrType + +imports + Lexical Exp + +exports + + sorts ExpOrType + context-free syntax + Id "[" {Exp ","}* "]" -> ExpOrType {cons("StaticFunCall")} + Id -> ExpOrType {cons("Var")} + Id "::" Exp -> ExpOrType {cons("Scope")} Index: tools/parser/grammar/Scool.sdf --- tools/parser/grammar/Scool.sdf (revision 0) +++ tools/parser/grammar/Scool.sdf (revision 0) @@ -0,0 +1,11 @@ +module Scool + +imports + Decl + +exports + sorts Program + context-free start-symbols Program + context-free syntax + + Decl* -> Program {cons("Program")} Index: tools/parser/grammar/Lexical.sdf --- tools/parser/grammar/Lexical.sdf (revision 0) +++ tools/parser/grammar/Lexical.sdf (revision 0) @@ -0,0 +1,28 @@ +module Lexical + +exports + sorts Id Int String Asterisk Slash BlockComment CommentPart Cpp + lexical syntax + + [A-Za-z][A-Za-z0-9\_]* -> Id {cons("Id")} + [0-9]+ -> Int {cons("Int")} + "\"" [A-Za-z0-9]* "\"" -> String {cons("String")} + "//" ~[\n]* [\n] -> LAYOUT + [\ \t\n] -> LAYOUT + "/+" ~[]* "+/" -> Cpp + "class" -> Id {reject} + + BlockComment -> LAYOUT + + "/*" CommentPart* "*/" -> BlockComment + ~[\/\*] -> CommentPart + Asterisk -> CommentPart + Slash -> CommentPart + BlockComment -> CommentPart + [\/] -> Slash + [\*] -> Asterisk + + lexical restrictions + Id -/- [A-Za-z] + Asterisk -/- [\/] + Slash -/- [\*] Index: tools/parser/grammar/Type.sdf --- tools/parser/grammar/Type.sdf (revision 0) +++ tools/parser/grammar/Type.sdf (revision 0) @@ -0,0 +1,18 @@ +module Type + +imports + ExpOrType + + +exports + + sorts Type + context-free syntax + + ExpOrType -> Type + "(" {Type ","}* ")" "->" Type -> Type {cons("FunType")} + "[" {Type ","}* "]" "->" Type -> Type {cons("StaticFunType")} + "[" {Type ","}* "]" + "(" {Type ","}* ")" "->" Type -> Type {cons("BiFunType")} + "class" -> Type {cons("Class")} + "class" "<" Type -> Type {cons("Class")} Index: tools/parser/grammar/Guard.sdf --- tools/parser/grammar/Guard.sdf (revision 0) +++ tools/parser/grammar/Guard.sdf (revision 0) @@ -0,0 +1,10 @@ +module Guard + +imports + Exp + +exports + sorts Guard + context-free syntax + + "where" Exp -> Guard {cons("Guard")} Index: tools/parser/grammar/Stm.sdf --- tools/parser/grammar/Stm.sdf (revision 0) +++ tools/parser/grammar/Stm.sdf (revision 0) @@ -0,0 +1,17 @@ +module Stm + +imports + Lexical Exp Decl + +exports + sorts Stm + context-free syntax + + ";" -> Stm {cons("EmptyStm")} + Exp ";" -> Stm {cons("ExpStm")} + "->" Exp ";" -> Stm {cons("Return")} + "{" Stm* "}" -> Stm {cons("Block")} + "if" "(" Exp ")" Stm ("else" Stm)? -> Stm {cons("If")} + "while" "(" Exp ")" Stm -> Stm {cons("While")} + Decl -> Stm + Cpp -> Stm {cons("CppStm")} Index: tools/parser/parse-scool --- tools/parser/parse-scool (revision 0) +++ tools/parser/parse-scool (revision 0) @@ -0,0 +1,8 @@ +#!/bin/sh +# -*- sh -*- + +if [ $# -eq 0 ]; then + echo "usage: parse-scool file.scl" +else + sglri -p parser/Scool.tbl -i $1 +fi Property changes on: tools/parser/parse-scool ___________________________________________________________________ Name: svn:executable + * Index: tools/parser/Makefile --- tools/parser/Makefile (revision 0) +++ tools/parser/Makefile (revision 0) @@ -0,0 +1,20 @@ +SDF = $(wildcard grammar/*.sdf) +OUT = Scool + +all: Scool.def Scool.tbl Scool.str + +Scool.def: $(SDF) + pack-sdf -i grammar/Scool.sdf -o $@ + +Scool.tbl: Scool.def + sdf2table -i $< -o $@ -m Scool + +Scool.rtg: Scool.def + sdf2rtg -i $< -m Scool -o $@ + +Scool.str: Scool.rtg + rtg2sig --module Scool -i $< -o $@ + +clean: + rm -rf Scool.* log.* + Index: tools/Makefile --- tools/Makefile (revision 0) +++ tools/Makefile (revision 0) @@ -0,0 +1,14 @@ +all: + cd parser && make + cd transformer && make + +clean: + rm -rf log.* + cd parser && make clean + cd transformer && make clean + +check: all + uttk test.yml + +gen: all + uttk gen.yml

mefyl <mefyl@free.fr> writes:
https://svn.lrde.epita.fr/svn/oln/trunk
Index: ChangeLog from Quentin Hocquet <mefyl@lrde.epita.fr>
Scool parser.
* tools: New. * tools/test.yml: New. * tools/transformer: New. * tools/transformer/scoolc.str: New. * tools/transformer/Makefile: New. * tools/tests: New. * tools/tests/syntax error: New. * tools/tests/syntax error/wrong.scl: New. * tools/tests/parse-ref: New. * tools/tests/parse-ref/vardec.ref: New. * tools/tests/parse-ref/fundec.ref: New. * tools/tests/parse-ref/funcall_no-args.ref: New. * tools/tests/parse-ref/emtpy-class_dec.ref: New. * tools/tests/parse-ref/empty-class_dec.ref: New. * tools/tests/parse-ref/varinit.ref: New. * tools/tests/parse-ref/no-args_funtype.ref: New. * tools/tests/parse-ref/manydec.ref: New. * tools/tests/parse-ref/class_dec.ref: New. * tools/tests/parse-ref/wiki1.ref: New. * tools/tests/parse-ref/funcall.ref: New. * tools/tests/parse-ref/bi-exp.ref: New. * tools/tests/parse-ref/function.ref: New. * tools/tests/parse-ref/wiki2.ref: New. * tools/tests/parse-ref/consinit.ref: New. * tools/tests/parse-ref/wiki3.ref: New. * tools/tests/parse-ref/funtype.ref: New. * tools/tests/parse-ref/empty.ref: New. * tools/tests/parse-ref/type_static-call.ref: New. * tools/tests/parse-ref/guard.ref: New. * tools/tests/good: New. * tools/tests/good/type_static-call.scl: New. * tools/tests/good/guard.scl: New. * tools/tests/good/fundec.scl: New. * tools/tests/good/vardec.scl: New. * tools/tests/good/funcall_no-args.scl: New. * tools/tests/good/varinit.scl: New. * tools/tests/good/empty-class_dec.scl: New. * tools/tests/good/manydec.scl: New. * tools/tests/good/class_dec.scl: New. * tools/tests/good/no-args_funtype.scl: New. * tools/tests/good/bi-exp.scl: New. * tools/tests/good/wiki1.scl: New. * tools/tests/good/funcall.scl: New. * tools/tests/good/wiki2.scl: New. * tools/tests/good/function.scl: New. * tools/tests/good/consinit.scl: New. * tools/tests/good/wiki3.scl: New. * tools/tests/good/funtype.scl: New. * tools/tests/good/empty.scl: New. * tools/scoolc: New. * tools/gen.yml: New. * tools/parser: New. * tools/parser/grammar: New. * tools/parser/grammar/Class.sdf: New. * tools/parser/grammar/Decl.sdf: New. * tools/parser/grammar/Exp.sdf: New. * tools/parser/grammar/ExpOrType.sdf: New. * tools/parser/grammar/Scool.sdf: New. * tools/parser/grammar/Lexical.sdf: New. * tools/parser/grammar/Type.sdf: New. * tools/parser/grammar/Guard.sdf: New. * tools/parser/grammar/Stm.sdf: New. * tools/parser/parse-scool: New. * tools/parser/Makefile: New. * tools/Makefile: New.
Wow! That's a big contribution! :) I suggest renaming `tools' to `scool' (and adding a ChangeLog to this directory). What do you think? (And if you don't need Transformers anymore, consider removing the svn::external links.) Thanks!
participants (2)
-
mefyl
-
Roland Levillain