aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorJack Koenig2017-02-28 00:50:11 -0800
committerJack Koenig2017-03-01 18:01:28 -0600
commit51f8f4a5e868a8e655091e3e61445d3cd772d2ba (patch)
treeea48ec6acbd9828770494d8489e34b03ef590f09 /src
parente8a8fd794cbddaaaa1dbdb1fdb10b8bb46c06ffe (diff)
Fix bug in Lexer rule for DoubleLit and add tests
Diffstat (limited to 'src')
-rw-r--r--src/main/antlr4/FIRRTL.g42
-rw-r--r--src/test/scala/firrtlTests/ParserSpec.scala23
2 files changed, 24 insertions, 1 deletions
diff --git a/src/main/antlr4/FIRRTL.g4 b/src/main/antlr4/FIRRTL.g4
index 47802cd6..69b7ba5d 100644
--- a/src/main/antlr4/FIRRTL.g4
+++ b/src/main/antlr4/FIRRTL.g4
@@ -300,7 +300,7 @@ HexLit
;
DoubleLit
- : ( '+' | '-' )? Digit+ '.' Digit+ ( 'E' Digit+ )?
+ : ( '+' | '-' )? Digit+ '.' Digit+ ( 'E' ( '+' | '-' )? Digit+ )?
;
fragment
diff --git a/src/test/scala/firrtlTests/ParserSpec.scala b/src/test/scala/firrtlTests/ParserSpec.scala
index 7978ad63..a1f14c8e 100644
--- a/src/test/scala/firrtlTests/ParserSpec.scala
+++ b/src/test/scala/firrtlTests/ParserSpec.scala
@@ -92,6 +92,29 @@ class ParserSpec extends FirrtlFlatSpec {
s" ${keyword} <= ${keyword}")))
}
}
+
+ // ********** Doubles as parameters **********
+ "Doubles" should "be legal parameters for extmodules" in {
+ val nums = Seq("1.0", "7.6", "3.00004", "1.0E10", "1.0023E-17")
+ val signs = Seq("", "+", "-")
+ val tests = "0.0" +: (signs flatMap (s => nums map (n => s + n)))
+ for (test <- tests) {
+ println(s"Trying $test")
+ val input = s"""
+ |circuit Test :
+ | extmodule Ext :
+ | input foo : UInt<32>
+ |
+ | defname = MyExtModule
+ | parameter REAL = $test
+ |
+ | module Test :
+ | input foo : UInt<32>
+ | output bar : UInt<32>
+ """.stripMargin
+ firrtl.Parser.parse(input split "\n")
+ }
+ }
}
class ParserPropSpec extends FirrtlPropSpec {