Skip to content

Commit

Permalink
Fix missing error detection if extraneous input is passed to RDLCompi…
Browse files Browse the repository at this point in the history
…ler.expr()
  • Loading branch information
amykyta3 committed Jul 19, 2022
1 parent c88b9e3 commit bda90ef
Show file tree
Hide file tree
Showing 21 changed files with 2,433 additions and 2,269 deletions.
4 changes: 2 additions & 2 deletions systemrdl/compiler.py
Original file line number Diff line number Diff line change
Expand Up @@ -434,8 +434,8 @@ def eval(self, expression: str) -> rdltypes.RDLValue:

parsed_tree = sa_systemrdl.parse(
input_stream,
"expr",
messages.RdlSaErrorListener(self.msg)
"eval_expr_root",
messages.RdlSaErrorListener(msg_handler)
)

visitor = ExprVisitor(self)
Expand Down
3 changes: 3 additions & 0 deletions systemrdl/core/BaseVisitor.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ def visitUdp_data_type(self, ctx: SystemRDLParser.Udp_data_typeContext) -> Any:

def visitUdp_comp_type(self, ctx: SystemRDLParser.Udp_comp_typeContext) -> Any:
return self.passthru_kw_token(ctx)

def visitEval_expr_root(self, ctx:SystemRDLParser.Eval_expr_rootContext) -> Any:
return self.visit(ctx.expr()) # type: ignore
2 changes: 2 additions & 0 deletions systemrdl/parser/SystemRDL.g4
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@ grammar SystemRDL;

root: (root_elem ';')* EOF;

eval_expr_root: expr EOF;

root_elem : component_def
| enum_def
| udp_def
Expand Down
3 changes: 2 additions & 1 deletion systemrdl/parser/SystemRDL.interp

Large diffs are not rendered by default.

2,054 changes: 1,051 additions & 1,003 deletions systemrdl/parser/SystemRDLParser.py

Large diffs are not rendered by default.

Loading

0 comments on commit bda90ef

Please sign in to comment.