fix(frontends/lean/parser): add existing command macros when creating parser object
Signed-off-by: Leonardo de Moura <leonardo@microsoft.com>
This commit is contained in:
parent
8e4560a866
commit
ef18cc4a92
3 changed files with 32 additions and 4 deletions
|
@ -2546,19 +2546,22 @@ public:
|
|||
m_script_state(S),
|
||||
m_set_parser(m_script_state, this) {
|
||||
m_check_identifiers = true;
|
||||
updt_options();
|
||||
m_found_errors = false;
|
||||
m_num_local_decls = 0;
|
||||
m_scanner.set_command_keywords(g_command_keywords);
|
||||
if (m_script_state) {
|
||||
m_script_state->apply([&](lua_State * L) {
|
||||
m_expr_macros = &get_expr_macros(L);
|
||||
m_cmd_macros = &get_cmd_macros(L);
|
||||
for (auto const & p : *m_cmd_macros) {
|
||||
m_scanner.add_command_keyword(p.first);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
m_expr_macros = nullptr;
|
||||
m_cmd_macros = nullptr;
|
||||
}
|
||||
updt_options();
|
||||
m_found_errors = false;
|
||||
m_num_local_decls = 0;
|
||||
m_scanner.set_command_keywords(g_command_keywords);
|
||||
scan();
|
||||
}
|
||||
|
||||
|
|
20
tests/lean/nested.lean
Normal file
20
tests/lean/nested.lean
Normal file
|
@ -0,0 +1,20 @@
|
|||
(**
|
||||
cmd_macro("Simple",
|
||||
{ macro_arg.String },
|
||||
function (env, str)
|
||||
print("OUTPUT: " .. str)
|
||||
end
|
||||
)
|
||||
|
||||
parse_lean_cmds([[
|
||||
Simple "foo"
|
||||
]])
|
||||
**)
|
||||
|
||||
Simple "testing"
|
||||
|
||||
(**
|
||||
parse_lean_cmds([[
|
||||
Simple "bla"
|
||||
]])
|
||||
**)
|
5
tests/lean/nested.lean.expected.out
Normal file
5
tests/lean/nested.lean.expected.out
Normal file
|
@ -0,0 +1,5 @@
|
|||
Set: pp::colors
|
||||
Set: pp::unicode
|
||||
OUTPUT: foo
|
||||
OUTPUT: testing
|
||||
OUTPUT: bla
|
Loading…
Reference in a new issue