Skip to content

Commit

Permalink
not support some syntax in port parser.
Browse files Browse the repository at this point in the history
  • Loading branch information
kei-os committed Dec 30, 2008
1 parent dd8606a commit c7e8d7e
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 30 deletions.
4 changes: 4 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
2008-12-31 kei-os <[email protected]>

* portのいくつかの構文を not supportにした。

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

* expression実装テストファイル ExprTest.hs を追加。
Expand Down
38 changes: 9 additions & 29 deletions Vparsec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ moduleDeclaration = do { try(symbol "module"); a <- moduleDeclaration'; return a
moduleDeclaration' :: Parser Module_
moduleDeclaration'
= do { n <- lexeme nameOfModule
; p <- listOfPorts
; p <- lexeme listOfPorts
; semi
; m <- lexeme(many moduleItem)
; symbol "endmodule"
Expand All @@ -237,20 +237,13 @@ listOfPorts = parens listOfPorts'
<|> do { string ""; return [] }
<?> "listOfPorts"
where
listOfPorts' = do { whiteSpace; p <- lexeme port; ps <- lexeme(many commaPorts); return (p:ps) }
listOfPorts' = do { p <- lexeme port; ps <- lexeme(many commaPorts); return (p:ps) }
<?> "listOfPorts'"

-- XXX TODO : AST
port :: Parser String
port = try(portExpression)
<|> do { a <- dot; b <- lexeme nameOfPort; c <- parens port'; return $ a ++ b ++ c }
<|> string ""
<?> "port"
where
port' :: Parser String
port' = portExpression
<|> string ""
<?> "port'"

commaPorts :: Parser String
commaPorts = do { comma; a <- port; return a }
Expand All @@ -259,35 +252,22 @@ commaPorts = do { comma; a <- port; return a }
-- XXX TODO : AST
portExpression :: Parser String
portExpression = try(portReference)
<|> braces portExpression'
-- <|> braces portExpression' -- not support
<?> "portExpression"
where
portExpression' :: Parser String
portExpression' = do { a <- portReference
; b <- many(commaPortReference)
; return $ a ++ concat(b) }
-- where
-- portExpression' :: Parser String
-- portExpression' = do { a <- portReference
-- ; b <- many(commaPortReference)
-- ; return $ a ++ concat(b) }

commaPortReference :: Parser String
commaPortReference = do { comma; a <- portReference; return a }
<?> "commaPortReference"

-- XXX TODO : AST
portReference :: Parser String
portReference = do { a <- nameOfVariable
-- ; b <- portReference' -- XXX get port information
; portReference' -- XXX get port information (currently not use lower block's info)
; return a }
portReference = nameOfVariable
<?> "portReference"
where
portReference' :: Parser String
portReference' = do { a <- brackets constantExpression'; return a }
<|> string ""
constantExpression' :: Parser String
constantExpression' = constantExpression
<|> do { a <- lexeme constantExpression
; b <- colon
; c <- lexeme constantExpression
; return $ a ++ b ++ c}

nameOfPort :: Parser String
nameOfPort = identifier <?> "nameOfPort"
Expand Down
2 changes: 1 addition & 1 deletion s1.v
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ end
assign a = 10;

always@(posedge clk or negedge rst_n) begin
if (a) foo <= 1;
if (a) foo <= 1 + 2;
else if (b) foo <= 2;
else foo <= 3;
end
Expand Down

0 comments on commit c7e8d7e

Please sign in to comment.