aboutsummaryrefslogtreecommitdiff
path: root/src/main/antlr4/FIRRTL.g4
diff options
context:
space:
mode:
authorAlbert Magyar2020-03-25 12:24:58 -0700
committerAlbert Magyar2020-03-26 11:14:28 -0700
commit4b3b5442bfe34502862eb070854aeef1e0cfc9c4 (patch)
tree49e09570ba220679ca51249ea9cb83f101ef66fa /src/main/antlr4/FIRRTL.g4
parent9995f081291d974a6b5ad319e67a9d19cdc4a56d (diff)
Support octal and binary literal formats as described in the spec
* Fixes #1464
Diffstat (limited to 'src/main/antlr4/FIRRTL.g4')
-rw-r--r--src/main/antlr4/FIRRTL.g420
1 files changed, 20 insertions, 0 deletions
diff --git a/src/main/antlr4/FIRRTL.g4 b/src/main/antlr4/FIRRTL.g4
index 0035423b..39988e18 100644
--- a/src/main/antlr4/FIRRTL.g4
+++ b/src/main/antlr4/FIRRTL.g4
@@ -186,6 +186,8 @@ intLit
: UnsignedInt
| SignedInt
| HexLit
+ | OctalLit
+ | BinaryLit
;
lowerBound
@@ -320,6 +322,14 @@ HexLit
: '"' 'h' ( '+' | '-' )? ( HexDigit )+ '"'
;
+OctalLit
+ : '"' 'o' ( '+' | '-' )? ( OctalDigit )+ '"'
+ ;
+
+BinaryLit
+ : '"' 'b' ( '+' | '-' )? ( BinaryDigit )+ '"'
+ ;
+
DoubleLit
: ( '+' | '-' )? Digit+ '.' Digit+ ( 'E' ( '+' | '-' )? Digit+ )?
;
@@ -334,6 +344,16 @@ HexDigit
: [a-fA-F0-9]
;
+fragment
+OctalDigit
+ : [0-7]
+ ;
+
+fragment
+BinaryDigit
+ : [01]
+ ;
+
StringLit
: '"' UnquotedString? '"'
;