Skip to content

Commit

Permalink
changed return type of (initial|always)Statement and (input|output|in…
Browse files Browse the repository at this point in the history
…out)Declaration

from ModuleItem_ to Stmt_ and Sig_ respectively.
  • Loading branch information
kei-os committed Dec 27, 2008
1 parent 9ad24b9 commit f45d7e3
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 24 deletions.
2 changes: 2 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
* regDeclarationの return typeを ModuleItem_から Sig_に変更。
* blockDeclarationの return typeを ModuleItem_ から Block_ に変更。
* Block_と BlockItem_ をわけた。seqBlockを AST化。
* alwaysStatement, initialStatementの return typeを ModuleItem_ から Stmt_ に変更。
* (input|output|inout)Declarationの return typeを ModuleItem_ から Sig_ に変更。

2008-12-26 kei-os <[email protected]>

Expand Down
45 changes: 21 additions & 24 deletions Vparsec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,6 @@ data LValue_ = LV_IDENT String
| LV_CONCAT [Expr_]
deriving (Eq, Show)

--type RegLValue_ = LValue_ -- XXX pending

data BlockAssign_ = BLOCK_ASSIGN LValue_ DelayOrEvent_ Expr_ deriving (Eq, Show)

data BlockItem_ = BI_PARAM -- XXX TODO impl
Expand All @@ -175,7 +173,7 @@ data Sig_ = PORT_SIG { direction_ :: Direction_ , name_ :: [String] , range_ ::
| REG_SIG { regType_ :: RegType_, name_ :: [String], range_ :: Range_ }
deriving (Eq, Show, Ord)

data Direction_ = INPUT | OUTPUT | INOUT | NONE deriving (Eq, Show, Ord)
data Direction_ = IN | OUT | INOUT | NONE deriving (Eq, Show, Ord)
data NetType_ = NET_WIRE | NET_TRI | NET_TRI1 | NET_SUPPLY0 | NET_WAND
| NET_TRIAND | NET_TRI0 | NET_SUPPLY1 | NET_WOR | NET_TRIOR
deriving (Eq, Show, Ord)
Expand Down Expand Up @@ -311,15 +309,15 @@ constantExpression = do { expression; return "expression:ok " }
moduleItem :: Parser ModuleItem_
moduleItem = try(lexeme parameterDeclaration)
<|> try(lexeme continuousAssign)
<|> try(lexeme inputDeclaration)
<|> try(lexeme outputDeclaration)
<|> try(lexeme inoutDeclaration)
<|> try(do { a <- lexeme inputDeclaration; return $ MI_PORT_DECL a })
<|> try(do { a <- lexeme outputDeclaration; return $ MI_PORT_DECL a })
<|> try(do { a <- lexeme inoutDeclaration; return $ MI_PORT_DECL a })
<|> try(do { a <- lexeme regDeclaration; return $ MI_REG_DECL a })
<|> try(lexeme timeDeclaration)
<|> try(lexeme integerDeclaration)
<|> try(lexeme netDeclaration)
<|> try(lexeme initialStatement)
<|> try(lexeme alwaysStatement)
<|> try(do { a <- lexeme initialStatement; return $ MI_INITIAL a })
<|> try(do { a <- lexeme alwaysStatement; return $ MI_ALWAYS a })
<?> "moduleItem"

parameterDeclaration :: Parser ModuleItem_
Expand Down Expand Up @@ -348,12 +346,12 @@ commaParamAssignment = do { a <- comma
; return $ a ++ b }
<?> "commaParamAssignment"

inputDeclaration :: Parser ModuleItem_
inputDeclaration :: Parser Sig_
inputDeclaration = do { symbol "input"
; r <- rangeOrEmpty
; l <- listOfPortIdentifiers
; semi
; return $ MI_PORT_DECL $ PORT_SIG { direction_ = INPUT, name_ = l, range_ = r } }
; return $ PORT_SIG { direction_ = IN, name_ = l, range_ = r } }
<?> "inputDeclaration"

listOfPortIdentifiers :: Parser [String]
Expand Down Expand Up @@ -386,20 +384,20 @@ range = do { symbol "["; r <- range'; symbol "]"; return r }
; return (read max, read min, (read max) - (read min) + 1 ) } -- XXX TODO improve
<?> "range'"

outputDeclaration :: Parser ModuleItem_
outputDeclaration :: Parser Sig_
outputDeclaration = do { symbol "output"
; r <- rangeOrEmpty
; l <- listOfPortIdentifiers
; semi
; return $ MI_PORT_DECL $ PORT_SIG { direction_ = OUTPUT, name_ = l, range_ = r } }
; return $ PORT_SIG { direction_ = OUT, name_ = l, range_ = r } }
<?> "outputDeclaration"

inoutDeclaration :: Parser ModuleItem_
inoutDeclaration :: Parser Sig_
inoutDeclaration = do { symbol "inout"
; r <- rangeOrEmpty
; l <- listOfPortIdentifiers
; semi
; return $ MI_PORT_DECL $ PORT_SIG { direction_ = INOUT, name_ = l, range_ = r } }
; return $ PORT_SIG { direction_ = INOUT, name_ = l, range_ = r } }
<?> "inoutDeclaration"

netDeclaration :: Parser ModuleItem_
Expand Down Expand Up @@ -520,12 +518,12 @@ netAssignment = do { lv <- lexeme lvalue
; return $ NET_ASSIGN lv expr }
<?> "netAssignment"

initialStatement :: Parser ModuleItem_
initialStatement = do { symbol "initial"; a <- lexeme statement; return $ MI_INITIAL a }
initialStatement :: Parser Stmt_
initialStatement = do { symbol "initial"; a <- lexeme statement; return a }
<?> "initialStatement"

alwaysStatement :: Parser ModuleItem_
alwaysStatement = do { symbol "always"; a <- lexeme statement; return $ MI_ALWAYS $ a }
alwaysStatement :: Parser Stmt_
alwaysStatement = do { symbol "always"; a <- lexeme statement; return a }
<?> "alwaysStatement"

statementOrNull :: Parser Stmt_
Expand Down Expand Up @@ -688,12 +686,10 @@ optEventExpression = try(do { symbol "posedge"; lexeme expression; return "expr:

-- XXX TODO : semantic value
eventExpression' :: Parser [EventExpr_]
eventExpression' = do { symbol "or"
; e <- lexeme eventExpression
; es <- eventExpression'
; return (e:es) }
<|> do {a <- string ""; return [] }
<?> "eventExpression'"
eventExpression'
= do { symbol "or"; e <- lexeme eventExpression; es <- eventExpression'; return (e:es) }
<|> do {a <- string ""; return [] }
<?> "eventExpression'"

-- Expressions
lvalue :: Parser LValue_
Expand All @@ -711,6 +707,7 @@ reglValue :: Parser LValue_ -- XXX pending : RegLValue_
reglValue = lvalue
<?> "reglValue"

-- XXX TODO : test
expression :: Parser Expr_
expression = do { a <- optExpression
; b <- expression' <|> expression''
Expand Down

0 comments on commit f45d7e3

Please sign in to comment.