Commit 40df9028 by Zachary Snow

parser production rule for optional assignments

parent ccd09a13
...@@ -443,6 +443,10 @@ Description :: { [Description] } ...@@ -443,6 +443,10 @@ Description :: { [Description] }
| PackageDeclaration { [$1] } | PackageDeclaration { [$1] }
| PackageItem { map PackageItem $1 } | PackageItem { map PackageItem $1 }
OptAsgn :: { Expr }
: {- empty -} { Nil }
| "=" Expr { $2 }
Type :: { Type } Type :: { Type }
: TypeNonIdent { $1 } : TypeNonIdent { $1 }
| TypeAlias { $1 } | TypeAlias { $1 }
...@@ -654,8 +658,7 @@ VariablePortIdentifiers :: { [(Identifier, Expr)] } ...@@ -654,8 +658,7 @@ VariablePortIdentifiers :: { [(Identifier, Expr)] }
: VariablePortIdentifier { [$1] } : VariablePortIdentifier { [$1] }
| VariablePortIdentifiers "," VariablePortIdentifier { $1 ++ [$3] } | VariablePortIdentifiers "," VariablePortIdentifier { $1 ++ [$3] }
VariablePortIdentifier :: { (Identifier, Expr) } VariablePortIdentifier :: { (Identifier, Expr) }
: Identifier { ($1, Nil) } : Identifier OptAsgn { ($1,$2) }
| Identifier "=" Expr { ($1, $3 ) }
Direction :: { Direction } Direction :: { Direction }
: "inout" { Inout } : "inout" { Inout }
...@@ -766,8 +769,7 @@ AttrSpecs :: { [AttrSpec] } ...@@ -766,8 +769,7 @@ AttrSpecs :: { [AttrSpec] }
: AttrSpec { [$1] } : AttrSpec { [$1] }
| AttrSpecs "," AttrSpec { $1 ++ [$3] } | AttrSpecs "," AttrSpec { $1 ++ [$3] }
AttrSpec :: { AttrSpec } AttrSpec :: { AttrSpec }
: Identifier "=" Expr { ($1, $3 ) } : Identifier OptAsgn { ($1, $2) }
| Identifier { ($1, Nil) }
NInputGates :: { [(Expr, Identifier, LHS, [Expr])] } NInputGates :: { [(Expr, Identifier, LHS, [Expr])] }
: NInputGate { [$1] } : NInputGate { [$1] }
...@@ -921,10 +923,7 @@ DeclAsgns :: { [(Identifier, Expr, [Range])] } ...@@ -921,10 +923,7 @@ DeclAsgns :: { [(Identifier, Expr, [Range])] }
: DeclAsgn { [$1] } : DeclAsgn { [$1] }
| DeclAsgns "," DeclAsgn { $1 ++ [$3] } | DeclAsgns "," DeclAsgn { $1 ++ [$3] }
DeclAsgn :: { (Identifier, Expr, [Range]) } DeclAsgn :: { (Identifier, Expr, [Range]) }
: Identifier "=" Expr { ($1, $3, []) } : Identifier Dimensions OptAsgn { ($1, $3, $2) }
| Identifier DimensionsNonEmpty "=" Expr { ($1, $4, $2) }
| Identifier { ($1, Nil, []) }
| Identifier DimensionsNonEmpty { ($1, Nil, $2) }
Range :: { Range } Range :: { Range }
: "[" Expr ":" Expr "]" { ($2, $4) } : "[" Expr ":" Expr "]" { ($2, $4) }
......
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