diff options
Diffstat (limited to 'frontend')
-rw-r--r-- | frontend/ast.ml | 11 | ||||
-rw-r--r-- | frontend/ast_printer.ml | 20 | ||||
-rw-r--r-- | frontend/file_parser.ml | 17 | ||||
-rw-r--r-- | frontend/rename.ml | 10 |
4 files changed, 22 insertions, 36 deletions
diff --git a/frontend/ast.ml b/frontend/ast.ml index d55626d..773efa4 100644 --- a/frontend/ast.ml +++ b/frontend/ast.ml @@ -2,6 +2,15 @@ open Lexing open Util +(* + Abstract Syntax Tree for a subset of the SCADE language. + + This subset includes : + - basic dataflow core (excluding when, merge, and all other clock primitives) + - activate blocks + - automata with weak transitions only +*) + type 'a ext = 'a * extent type id = string @@ -63,7 +72,7 @@ type expr = type var_def = bool * id * typ type automaton = id * state ext list * id list -and state = { +and state = { initial : bool; st_name : id; st_locals : var_def list; diff --git a/frontend/ast_printer.ml b/frontend/ast_printer.ml index 8908687..09f4986 100644 --- a/frontend/ast_printer.ml +++ b/frontend/ast_printer.ml @@ -3,23 +3,9 @@ open Lexing open Typing open Util - -(* Locations *) - -let string_of_position p = - Printf.sprintf "%s:%i:%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) - -let string_of_extent (p,q) = - if p.pos_fname = q.pos_fname then - if p.pos_lnum = q.pos_lnum then - if p.pos_cnum = q.pos_cnum then - Printf.sprintf "%s:%i.%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) - else - Printf.sprintf "%s:%i.%i-%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) (q.pos_cnum - q.pos_bol) - else - Printf.sprintf "%s:%i.%i-%i.%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) q.pos_lnum (q.pos_cnum - q.pos_bol) - else - Printf.sprintf "%s:%i.%i-%s:%i.%i" p.pos_fname p.pos_lnum (p.pos_cnum - p.pos_bol) q.pos_fname q.pos_lnum (q.pos_cnum - q.pos_bol) +(* + Just a pretty-printer, nothing to see here. +*) (* Operators *) diff --git a/frontend/file_parser.ml b/frontend/file_parser.ml deleted file mode 100644 index 85eb9cd..0000000 --- a/frontend/file_parser.ml +++ /dev/null @@ -1,17 +0,0 @@ -open Ast -open Ast_printer -open Lexing - -let parse_file (filename : string) : prog = - let f = open_in filename in - let lex = from_channel f in - try - lex.lex_curr_p <- { lex.lex_curr_p with pos_fname = filename; }; - Parser.file Lexer.token lex - with - | Parser.Error -> - Util.error (Printf.sprintf "Parse error (invalid syntax) near %s" - (string_of_position lex.lex_start_p)) - | Failure "lexing: empty token" -> - Util.error (Printf.sprintf "Parse error (invalid token) near %s" - (string_of_position lex.lex_start_p)) diff --git a/frontend/rename.ml b/frontend/rename.ml index 9c4cc31..71ec321 100644 --- a/frontend/rename.ml +++ b/frontend/rename.ml @@ -1,4 +1,12 @@ -(* Scope analyzer *) +(* + Scope analyzer + + Does a tiny bit of renaming, so that in a given node, every + variable declaration is unique. + + Variable name unicity is not assured program-wide. Node paths are + handled only once the program has been "rooted" (see fronted/typing.ml) +*) open Ast open Util |