diff --git a/Sujet.pdf b/Sujet.pdf index ed4afb2c37cb3aa20fa8e9b2497572827c921033..ed27c4de70d2a64a110d461d0ddbfa835fffc187 100644 Binary files a/Sujet.pdf and b/Sujet.pdf differ diff --git a/alpaga/grammar_lexer.mll b/alpaga/grammar_lexer.mll index a332afebc71eb503d788271d146c6b64a8fd03e2..effa0a6b287559517d091baf648f88ec527ef4ac 100644 --- a/alpaga/grammar_lexer.mll +++ b/alpaga/grammar_lexer.mll @@ -9,6 +9,7 @@ let id = letter (digit|letter|'_')* rule token = parse | [' ' '\t'] { token lexbuf } | "//" { comment lexbuf } + | "/*" { comment_multiline lexbuf } | '\n' { Lexing.new_line lexbuf; EOL } | '{' { action 0 "" lexbuf } | "->" { ARROW } @@ -29,3 +30,7 @@ and action level s = parse and comment = parse | '\n' { Lexing.new_line lexbuf; token lexbuf } | _ { comment lexbuf } +and comment_multiline = parse + | '\n' { Lexing.new_line lexbuf; comment_multiline lexbuf } + | "*/" { token lexbuf } + | _ { comment_multiline lexbuf } diff --git a/alpaga/ml_parser_generator.ml b/alpaga/ml_parser_generator.ml index 0b225417edc7309471063616b967b72a5596f203..3e314c28f6f5958def178090595faa5db79ce583 100644 --- a/alpaga/ml_parser_generator.ml +++ b/alpaga/ml_parser_generator.ml @@ -19,7 +19,8 @@ let rec make_list l = (* Return the list of elements of the rule. *) let default_action (pl: string list) : string = - make_list (List.mapi (fun i e -> i) pl) + (* make_list (List.mapi (fun i e -> i) pl) *) + "()" let resolve_vars s = Str.global_replace (Str.regexp "\\$\\([0-9]+\\)") "p\\1" s diff --git a/expr_grammar_action.g b/expr_grammar_action.g index f4fdbf8c1c2da7dd85d0319f6140e150ad0ed628..0710a942074f5f4405241859dd1c462e3ddeb06e 100644 --- a/expr_grammar_action.g +++ b/expr_grammar_action.g @@ -29,11 +29,4 @@ axiom S } rules -S -> GLOBDEF SYM_EOF { Node (Tlistglobdef, [$1]) } -IDENTIFIER -> SYM_IDENTIFIER { StringLeaf ($1) } -INTEGER -> SYM_INTEGER { IntLeaf ($1) } -GLOBDEF -> IDENTIFIER SYM_LPARENTHESIS LPARAMS SYM_RPARENTHESIS INSTR { - let fargs = $3 in - let instr = $5 in - Node (Tfundef, [$1; Node (Tfunargs, fargs) ; instr ]) -} +S -> GLOBDEF SYM_EOF { Node (Tlistglobdef, []) } diff --git a/src/ast.ml b/src/ast.ml index b9bf4550ce204e00cb214dea3c2e826212a60bc3..64d50fb94d64f2e7c126921282d64695ab58c8ff 100644 --- a/src/ast.ml +++ b/src/ast.ml @@ -1,6 +1,28 @@ open Batteries open BatPrintf +(* Les AST sont des arbres, du type [tree], étiquetés par des [tag]. + + Un arbre [tree] est soit un nœud [Node(t, children)] où [t] est un tag et + [children] une liste de sous-arbres ; soit une feuille qui contient une + chaîne de caractères ([StringLeaf]), un entier ([IntLeaf]), un caractère + ([CharLeaf]), ou rien du tout ([NullLeaf]). + + La signification des différents tags : + + - importe peu : vous pouvez définir de nouveaux types de tags si ça vous + semble nécessaire / profitable, pour peu de compléter la fonction + [string_of_tag] ci-dessous. + + - devrait être assez claire d'après le nom du tag ou l'utilisation qui en est + faite dans l'exemple donné dans le sujet. + + - peut être demandée à votre encadrant de TP favori (ou celui présent en + séance, à défaut) + + +*) + type tag = Tassign | Tif | Twhile | Tblock | Treturn | Tprint | Tint | Tadd | Tmul | Tdiv | Tmod | Txor | Tsub @@ -9,7 +31,7 @@ type tag = Tassign | Tif | Twhile | Tblock | Treturn | Tprint | Tlistglobdef | Tfundef | Tfunname | Tfunargs | Tfunbody | Tassignvar - | Targ | Targs + | Targ type tree = | Node of tag * tree list | StringLeaf of string @@ -52,9 +74,9 @@ let string_of_tag = function | Tfunbody -> "Tfunbody" | Tassignvar -> "Tassignvar" | Targ -> "Targ" - | Targs -> "Targs" -(* return (node, nextnode, dotcode) *) + +(* Écrit un fichier .dot qui correspond à un AST *) let rec draw_ast a next = match a with | Node (t, l) -> diff --git a/src/main.ml b/src/main.ml index 6ad983293d9033c60f041854df0a08fa60291c29..a86df17b1069f6431ac463a8db06ccaebad571a9 100644 --- a/src/main.ml +++ b/src/main.ml @@ -335,7 +335,9 @@ let _ = run "LTL" !ltl_run (exec_ltl_prog) ltl; (if !ltl_debug then debug_ltl_prog input ltl !heapsize !params); - dump !riscv_dump dump_riscv_prog ltl (fun file () -> ignore (compile_rv basename file ())); + dump !riscv_dump dump_riscv_prog ltl (fun file () -> + add_to_report "riscv" "RISC-V" (Code (file_contents file)); + ignore (compile_rv basename file ())); if not !Options.nostart then begin run "Risc-V" !riscv_run (exec_rv_prog ltl basename) !riscv_dump end;