diff options
author | Alex Auvolat <alex.auvolat@ansys.com> | 2014-07-15 11:35:12 +0200 |
---|---|---|
committer | Alex Auvolat <alex.auvolat@ansys.com> | 2014-07-15 11:35:12 +0200 |
commit | 4e66de932b91e91e4cadd943ff8859d6f69f57e1 (patch) | |
tree | ced73719216f2f1fd2eb9057001079a39dbad68e /frontend | |
parent | 7205927e18ea355a619e95b1036aac9b94a22667 (diff) | |
download | scade-analyzer-4e66de932b91e91e4cadd943ff8859d6f69f57e1.tar.gz scade-analyzer-4e66de932b91e91e4cadd943ff8859d6f69f57e1.zip |
Clean up & comment a bit.
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 |