Skip to content

Commit

Permalink
Fixed several statements per input. Ouput if no semicolon.
Browse files Browse the repository at this point in the history
git-svn-id: https://openmodelica.org/svn/OpenModelica/trunk@932 f25d12d1-65f4-0310-ae8a-bbce733d8d8e
  • Loading branch information
Peter Aronsson committed Mar 4, 2003
1 parent 496fc44 commit 472f2e7
Show file tree
Hide file tree
Showing 8 changed files with 252 additions and 112 deletions.
17 changes: 12 additions & 5 deletions modeq/absyn_builder/expression_parser.g
Expand Up @@ -42,13 +42,20 @@ tokens {
INTERACTIVE_EXP;
}

interactiveStmt! returns [void *ast]
interactiveStmts
:
(interactiveStmt (SEMICOLON)? EOF!) => interactiveStmt (SEMICOLON)? EOF!
|
interactiveStmt SEMICOLON! interactiveStmts

;

interactiveStmt!
:
(expression) => e:expression (SEMICOLON!)? EOF! {
(expression) => e:expression {
#interactiveStmt = #([INTERACTIVE_EXP,"INTERACTIVE_EXP"],#e);
}
| ( a:algorithm (SEMICOLON!)? EOF! )
{
}
| ( a:algorithm) {
#interactiveStmt = #([INTERACTIVE_ALG,"INTERACTIVE_ALG"],#a);
}
;
Expand Down
2 changes: 1 addition & 1 deletion modeq/absyn_builder/parse.cpp
Expand Up @@ -184,7 +184,7 @@ RML_BEGIN_LABEL(Parser__parsestringexp)

modelica_lexer lex(stream);
modelica_expression_parser parse(lex);
parse.interactiveStmt();
parse.interactiveStmts();
antlr::RefAST t = parse.getAST();

if (t)
Expand Down
26 changes: 16 additions & 10 deletions modeq/absyn_builder/walker.g
Expand Up @@ -124,19 +124,25 @@ stored_definition returns [void *ast]

interactive_stmt returns [void *ast]
{
void *a1=0;
void *e1=0;
void *al=0;
void *el=0;
l_stack el_stack;
}
:
#(INTERACTIVE_ALG
a1 = algorithm)
{
ast = Interactive__ISTMTS(mk_cons(Interactive__IALG(a1),mk_nil()));
}
|
#(INTERACTIVE_EXP e1 = expression )
(
#(INTERACTIVE_ALG (al = algorithm) )
{
el_stack.push(Interactive__IALG(al));
}
|
#(INTERACTIVE_EXP (el = expression ))
{
el_stack.push(Interactive__IEXP(el));
}

)* (s:SEMICOLON)?
{
ast = Interactive__ISTMTS(mk_cons(Interactive__IEXP(e1),mk_nil()));
ast = Interactive__ISTMTS(make_rml_list_from_stack(el_stack), RML_PRIM_MKBOOL(s != 0));
}
;

Expand Down
12 changes: 6 additions & 6 deletions modeq/dump.rml
Expand Up @@ -221,27 +221,27 @@ relation dump_istmt : Interactive.InteractiveStmts => () =
print_algorithmitem(alg) => () &
Print.print_buf ")\n"
--------------------------
dump_istmt(Interactive.ISTMTS([Interactive.IALG(alg)])) => ()
dump_istmt(Interactive.ISTMTS([Interactive.IALG(alg)],_)) => ()

rule Print.print_buf ("IEXP(") &
print_exp(expr) &
Print.print_buf ")\n"
----------------------
dump_istmt(Interactive.ISTMTS([Interactive.IEXP(expr)])) => ()
dump_istmt(Interactive.ISTMTS([Interactive.IEXP(expr)],_)) => ()

rule Print.print_buf "IALG(" &
print_algorithmitem(alg) => () &
Print.print_buf "," &
dump_istmt(Interactive.ISTMTS(l)) => ()
dump_istmt(Interactive.ISTMTS(l,sc)) => ()
--------------------------
dump_istmt(Interactive.ISTMTS(Interactive.IALG(alg)::l)) => ()
dump_istmt(Interactive.ISTMTS(Interactive.IALG(alg)::l,sc)) => ()

rule Print.print_buf "IEXP(" &
print_exp(expr) => () &
Print.print_buf "," &
dump_istmt(Interactive.ISTMTS(l)) => ()
dump_istmt(Interactive.ISTMTS(l,sc)) => ()
--------------------------
dump_istmt(Interactive.ISTMTS(Interactive.IEXP(expr)::l)) => ()
dump_istmt(Interactive.ISTMTS(Interactive.IEXP(expr)::l,sc)) => ()

axiom dump_istmt(_) => ()
end
Expand Down

0 comments on commit 472f2e7

Please sign in to comment.