Rain: added parsing of all the integer types (along with associated tests)
This commit is contained in:
parent
7e51ad1b1c
commit
ce84ae3db6
14
RainParse.hs
14
RainParse.hs
|
@ -78,8 +78,6 @@ sSeqeach = reserved "seqeach"
|
|||
sPareach = reserved "pareach"
|
||||
sChannel = reserved "channel"
|
||||
sOne2One = reserved "one2one"
|
||||
sBool = reserved "bool"
|
||||
sInt = reserved "int"
|
||||
sIf = reserved "if"
|
||||
sElse = reserved "else"
|
||||
sWhile = reserved "while"
|
||||
|
@ -121,8 +119,16 @@ name
|
|||
|
||||
dataType :: RainParser A.Type
|
||||
dataType
|
||||
= do {sBool ; return A.Bool}
|
||||
<|> do {sInt ; return A.Int}
|
||||
= do {reserved "bool" ; return A.Bool}
|
||||
<|> do {reserved "int" ; return A.Int}
|
||||
<|> do {reserved "uint8" ; return A.Byte}
|
||||
<|> do {reserved "uint16" ; return A.UInt16}
|
||||
<|> do {reserved "uint32" ; return A.UInt32}
|
||||
<|> do {reserved "uint64" ; return A.UInt64}
|
||||
<|> do {reserved "sint8" ; return A.Int8}
|
||||
<|> do {reserved "sint16" ; return A.Int16}
|
||||
<|> do {reserved "sint32" ; return A.Int32}
|
||||
<|> do {reserved "sint64" ; return A.Int64}
|
||||
<|> do {sChannel ; inner <- dataType ; return $ A.Chan A.DirUnknown (A.ChanAttributes {A.caWritingShared = False, A.caReadingShared = False}) inner}
|
||||
<|> do {sIn ; inner <- dataType ; return $ A.Chan A.DirInput (A.ChanAttributes {A.caWritingShared = False, A.caReadingShared = False}) inner}
|
||||
<|> do {sOut ; inner <- dataType ; return $ A.Chan A.DirOutput (A.ChanAttributes {A.caWritingShared = False, A.caReadingShared = False}) inner}
|
||||
|
|
|
@ -224,15 +224,25 @@ testDataType =
|
|||
[
|
||||
pass ("bool",RP.dataType,assertEqual "testDataType 0" A.Bool)
|
||||
,pass ("int",RP.dataType,assertEqual "testDataType 1" A.Int)
|
||||
,pass ("uint8",RP.dataType,assertEqual "testDataType 2" A.Byte)
|
||||
,pass ("uint16",RP.dataType,assertEqual "testDataType 2" A.UInt16)
|
||||
,pass ("uint32",RP.dataType,assertEqual "testDataType 2" A.UInt32)
|
||||
,pass ("uint64",RP.dataType,assertEqual "testDataType 2" A.UInt64)
|
||||
,pass ("sint8",RP.dataType,assertEqual "testDataType 2" A.Int8)
|
||||
,pass ("sint16",RP.dataType,assertEqual "testDataType 2" A.Int16)
|
||||
,pass ("sint32",RP.dataType,assertEqual "testDataType 2" A.Int32)
|
||||
,pass ("sint64",RP.dataType,assertEqual "testDataType 2" A.Int64)
|
||||
,fail ("boolean",RP.dataType)
|
||||
,fail ("uint24",RP.dataType)
|
||||
,fail ("int0",RP.dataType)
|
||||
|
||||
,pass ("?int",RP.dataType,assertEqual "testDataType 2" $ A.Chan A.DirInput nonShared A.Int)
|
||||
,pass ("! bool",RP.dataType,assertEqual "testDataType 3" $ A.Chan A.DirOutput nonShared A.Bool)
|
||||
,pass ("?int",RP.dataType,assertEqual "testDataType 102" $ A.Chan A.DirInput nonShared A.Int)
|
||||
,pass ("! bool",RP.dataType,assertEqual "testDataType 103" $ A.Chan A.DirOutput nonShared A.Bool)
|
||||
--These types should succeed in the *parser* -- they would be thrown out further down the line:
|
||||
,pass ("??int",RP.dataType,assertEqual "testDataType 4" $ A.Chan A.DirInput nonShared $ A.Chan A.DirInput nonShared A.Int)
|
||||
,pass ("? ? int",RP.dataType,assertEqual "testDataType 4" $ A.Chan A.DirInput nonShared $ A.Chan A.DirInput nonShared A.Int)
|
||||
,pass ("!!bool",RP.dataType,assertEqual "testDataType 5" $ A.Chan A.DirOutput nonShared $ A.Chan A.DirOutput nonShared A.Bool)
|
||||
,pass ("?!bool",RP.dataType,assertEqual "testDataType 6" $ A.Chan A.DirInput nonShared $ A.Chan A.DirOutput nonShared A.Bool)
|
||||
,pass ("??int",RP.dataType,assertEqual "testDataType 104" $ A.Chan A.DirInput nonShared $ A.Chan A.DirInput nonShared A.Int)
|
||||
,pass ("? ? int",RP.dataType,assertEqual "testDataType 105" $ A.Chan A.DirInput nonShared $ A.Chan A.DirInput nonShared A.Int)
|
||||
,pass ("!!bool",RP.dataType,assertEqual "testDataType 106" $ A.Chan A.DirOutput nonShared $ A.Chan A.DirOutput nonShared A.Bool)
|
||||
,pass ("?!bool",RP.dataType,assertEqual "testDataType 107" $ A.Chan A.DirInput nonShared $ A.Chan A.DirOutput nonShared A.Bool)
|
||||
|
||||
,fail ("?",RP.dataType)
|
||||
,fail ("!",RP.dataType)
|
||||
|
|
Loading…
Reference in New Issue
Block a user