aboutsummaryrefslogtreecommitdiff
path: root/src/main/stanza/ir-parser.stanza
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/stanza/ir-parser.stanza')
-rw-r--r--src/main/stanza/ir-parser.stanza22
1 files changed, 14 insertions, 8 deletions
diff --git a/src/main/stanza/ir-parser.stanza b/src/main/stanza/ir-parser.stanza
index 7e07eb8b..fdf4c383 100644
--- a/src/main/stanza/ir-parser.stanza
+++ b/src/main/stanza/ir-parser.stanza
@@ -4,6 +4,7 @@ defpackage firrtl/parser :
import firrtl/ir2
import stz/parser
import firrtl/lexer
+ import bigint
;======= Convenience Functions ========
defn first-info? (form) -> FileInfo|False :
@@ -81,6 +82,9 @@ defsyntax firrtl :
int = (?x) when unwrap-token(x) typeof Int :
unwrap-token(x)
+ string = (?x) when unwrap-token(x) typeof String :
+ unwrap-token(x)
+
;Parses next form if long literal
intorlong = (?x) when unwrap-token(x) typeof Int|Long :
unwrap-token(x)
@@ -88,7 +92,7 @@ defsyntax firrtl :
;Parses next form if symbol
sym = (?x) when unwrap-token(x) typeof Symbol :
unwrap-token(x)
-
+
;Error Handling Productions
defrule :
;Error if not an identifier
@@ -210,10 +214,7 @@ defsyntax firrtl :
accdir = (rdwr) : RDWR
defrule width :
- width = (?x:#intorlong) :
- match(x) :
- (x:Int) : IntWidth(x)
- (x:Long) : LongWidth(x)
+ width = (?x:#int) : IntWidth(x)
width = (?) : UnknownWidth()
;Main Statement Productions
@@ -257,10 +258,15 @@ defsyntax firrtl :
expop = (. ?f:#id!) : (fn (x) : Subfield(x, f, UnknownType()))
;Prefix Operators
- expterm = (?t:#inttype(?v:#long$)) :
+ expterm = (?t:#inttype(?v:#string)) :
+ match(t) :
+ (t:UIntType) : UIntValue(BigIntLit(v as String), width(t))
+ (t:SIntType) : SIntValue(BigIntLit(v as String), width(t))
+
+ expterm = (?t:#inttype(?v:#int$)) :
match(t) :
- (t:UIntType) : UIntValue(v, width(t))
- (t:SIntType) : SIntValue(v, width(t))
+ (t:UIntType) : UIntValue(BigIntLit(v as Int,32), width(t))
+ (t:SIntType) : SIntValue(BigIntLit(v as Int,32), width(t))
expterm = (?op:#sym(?es:#exp ... ?ints:#int ... ?rest ...)) :
if not empty?(rest) :