Commit 9259fef2 by Zachary Snow

tolerate spaces in numeric literals in line with the spec

parent 90bd6b34
......@@ -27,20 +27,18 @@ $decimalDigit = [0-9]
@unsignedNumber = $decimalDigit ("_" | $decimalDigit)*
@size = @unsignedNumber
@size = @unsignedNumber " "?
@decimalNumber
= @unsignedNumber
| @size? @decimalBase @unsignedNumber
@binaryNumber = @size? @binaryBase @binaryValue
@octalNumber = @size? @octalBase @octalValue
@hexNumber = @size? @hexBase @hexValue
@decimalNumber = @size? @decimalBase " "? @unsignedNumber
@binaryNumber = @size? @binaryBase " "? @binaryValue
@octalNumber = @size? @octalBase " "? @octalValue
@hexNumber = @size? @hexBase " "? @hexValue
@unbasedUnsizedLiteral = "'" ( 0 | 1 | x | X | z | Z )
@number
= @decimalNumber
= @unsignedNumber
| @decimalNumber
| @octalNumber
| @binaryNumber
| @hexNumber
......
......@@ -24,7 +24,14 @@ unskippableDirectives :: [String]
unskippableDirectives = ["else", "elsif", "endif"]
preprocess :: [Token] -> (StateT PP IO) [Token]
preprocess tokens = pp tokens
preprocess tokens = pp tokens >>= return . combineNumbers
-- a bit of a hack to allow things like: `WIDTH'b0
combineNumbers :: [Token] -> [Token]
combineNumbers (Token Lit_number size pos : Token Lit_number ('\'' : num) _ : tokens) =
Token Lit_number (size ++ "'" ++ num) pos : combineNumbers tokens
combineNumbers (token : tokens) = token : combineNumbers tokens
combineNumbers [] = []
data Cond
= CurrentlyTrue
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment