From 19fe90bb0fd37457c47f3873392db5cbb9b87d38 Mon Sep 17 00:00:00 2001 From: Zachary Yedidia Date: Fri, 26 Aug 2022 07:52:04 -0700 Subject: 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--- src/main/antlr4/FIRRTL.g4 | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'src/main/antlr4') 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 -- cgit v1.2.3