Scopelang: add toplevel mark for convenience

it allows to discriminate typed and non-typed ASTs
This commit is contained in:
Louis Gesbert 2022-09-30 16:40:10 +02:00
parent 9349fb918d
commit 41315dc650
3 changed files with 11 additions and 1 deletions

View File

@ -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} *)

View File

@ -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 }

View File

@ -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 = {