aboutsummaryrefslogtreecommitdiff
path: root/src/main/antlr4
diff options
context:
space:
mode:
authorZachary Yedidia2022-08-26 07:52:04 -0700
committerGitHub2022-08-26 14:52:04 +0000
commit19fe90bb0fd37457c47f3873392db5cbb9b87d38 (patch)
tree8d81c6b3d0ddf3b050a021300033d40f377acab7 /src/main/antlr4
parenta6851b8ec4044eef4af759a21887fdae6226e1cd (diff)
FIRRTL version support (#2543)
* Parse version and hardcode emitted version * Throw error if version is too high * Parse version even if rest is invalid * Change pattern match to if statement * Improve version grammar * Update tests * Remove outdated comment * Simplify grammar and use version class * Simplify and add no version test * Fix for conflicting lexer rule
Diffstat (limited to 'src/main/antlr4')
-rw-r--r--src/main/antlr4/FIRRTL.g411
1 files changed, 10 insertions, 1 deletions
diff --git a/src/main/antlr4/FIRRTL.g4 b/src/main/antlr4/FIRRTL.g4
index d40c6560..10a87c9e 100644
--- a/src/main/antlr4/FIRRTL.g4
+++ b/src/main/antlr4/FIRRTL.g4
@@ -29,7 +29,16 @@ import firrtl.LexerHelper;
// Does there have to be at least one module?
circuit
- : 'circuit' id ':' info? INDENT module* DEDENT EOF
+ : version? NEWLINE* 'circuit' id ':' info? INDENT module* DEDENT EOF
+ ;
+
+version
+ : 'FIRRTL' 'version' semver NEWLINE
+ ;
+
+// Due to lexer problems, something like 1.1.0 is lexed as DoubleLit '.' UnsignedInt
+semver
+ : DoubleLit '.' UnsignedInt
;
module