mirror of
https://github.com/CatalaLang/catala.git
synced 2024-11-08 07:51:43 +03:00
Scopelang: add toplevel mark for convenience
it allows to discriminate typed and non-typed ASTs
This commit is contained in:
parent
9349fb918d
commit
41315dc650
@ -627,10 +627,12 @@ let translate_scope (ctx : ctx) (scope : Ast.scope) :
|
||||
acc states)
|
||||
scope.scope_vars ScopeVarMap.empty
|
||||
in
|
||||
let pos = Marked.get_mark (ScopeName.get_info scope.scope_uid) in
|
||||
{
|
||||
Scopelang.Ast.scope_decl_name = scope.scope_uid;
|
||||
Scopelang.Ast.scope_decl_rules;
|
||||
Scopelang.Ast.scope_sig;
|
||||
Scopelang.Ast.scope_mark = Untyped { pos };
|
||||
}
|
||||
|
||||
(** {1 API} *)
|
||||
|
@ -77,6 +77,7 @@ type 'm scope_decl = {
|
||||
scope_decl_name : ScopeName.t;
|
||||
scope_sig : (typ * io) ScopeVarMap.t;
|
||||
scope_decl_rules : 'm rule list;
|
||||
scope_mark : 'm mark;
|
||||
}
|
||||
|
||||
type 'm program = {
|
||||
@ -115,7 +116,13 @@ let type_program (prg : 'm program) : typed program =
|
||||
(type_rule prg.program_ctx typing_env)
|
||||
scope_decl.scope_decl_rules
|
||||
in
|
||||
{ scope_decl with scope_decl_rules })
|
||||
let scope_mark =
|
||||
let pos =
|
||||
Marked.get_mark (ScopeName.get_info scope_decl.scope_decl_name)
|
||||
in
|
||||
Typed { pos; ty = Marked.mark pos TAny }
|
||||
in
|
||||
{ scope_decl with scope_decl_rules; scope_mark })
|
||||
prg.program_scopes
|
||||
in
|
||||
{ prg with program_scopes }
|
||||
|
@ -71,6 +71,7 @@ type 'm scope_decl = {
|
||||
scope_decl_name : ScopeName.t;
|
||||
scope_sig : (typ * io) ScopeVarMap.t;
|
||||
scope_decl_rules : 'm rule list;
|
||||
scope_mark : 'm mark;
|
||||
}
|
||||
|
||||
type 'm program = {
|
||||
|
Loading…
Reference in New Issue
Block a user