aboutsummaryrefslogtreecommitdiff
path: root/src/main/antlr4
diff options
context:
space:
mode:
authorJack Koenig2021-12-01 12:04:36 -0800
committerGitHub2021-12-01 12:04:36 -0800
commitb14ed79d416883eb858a191e29326ec08c040a2d (patch)
tree37b93b1c487f78e39acd17f94faf5f5c3b24b9d8 /src/main/antlr4
parenta4d13a5024f7488e1d2b9fdd27d3917157a67268 (diff)
parent17250fba841ae3129dc798c0bc48d10200be18ae (diff)
Merge pull request #2343 from chipsalliance/improve-parser
Improve ANTLR Parser
Diffstat (limited to 'src/main/antlr4')
-rw-r--r--src/main/antlr4/FIRRTL.g422
1 files changed, 14 insertions, 8 deletions
diff --git a/src/main/antlr4/FIRRTL.g4 b/src/main/antlr4/FIRRTL.g4
index f5116485..d40c6560 100644
--- a/src/main/antlr4/FIRRTL.g4
+++ b/src/main/antlr4/FIRRTL.g4
@@ -99,9 +99,9 @@ stmt
| mdir 'mport' id '=' id '[' exp ']' exp info?
| 'inst' id 'of' id info?
| 'node' id '=' exp info?
- | exp '<=' exp info?
- | exp '<-' exp info?
- | exp 'is' 'invalid' info?
+ | ref '<=' exp info?
+ | ref '<-' exp info?
+ | ref 'is' 'invalid' info?
| when
| 'stop(' exp exp intLit ')' stmtName? info?
| 'printf(' exp exp StringLit ( exp)* ')' stmtName? info?
@@ -167,16 +167,22 @@ ruw
exp
: 'UInt' ('<' intLit '>')? '(' intLit ')'
| 'SInt' ('<' intLit '>')? '(' intLit ')'
- | id // Ref
- | exp '.' fieldId
- | exp '.' DoubleLit // TODO Workaround for #470
- | exp '[' intLit ']'
- | exp '[' exp ']'
+ | ref
| 'mux(' exp exp exp ')'
| 'validif(' exp exp ')'
| primop exp* intLit* ')'
;
+ref
+ : id subref?
+ ;
+
+subref
+ : '.' fieldId subref?
+ | '.' DoubleLit subref? // TODO Workaround for #470
+ | '[' (intLit | exp) ']' subref?
+ ;
+
id
: Id
| keywordAsId