Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AssemblySwitch to grammar #36

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions solidity.pegjs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ Keyword
/ ContractToken
/ InterfaceToken
/ DeleteToken
/ DefaultToken
/ DoToken
/ ElseToken
/ ForToken
Expand All @@ -230,6 +231,7 @@ Keyword
/ PragmaToken
/ ReturnToken
/ ReturnsToken
/ SwitchToken
/ ThisToken
/ ThrowToken
/ VarToken
Expand Down Expand Up @@ -492,7 +494,9 @@ ConstantToken = "constant" !IdentifierPart
ContinueToken = "continue" !IdentifierPart
ContractToken = "contract" !IdentifierPart
ConstructorToken = "constructor" !IdentifierPart
CaseToken = "case" !IdentifierPart
DaysToken = "days" !IdentifierPart
DefaultToken = "default" !IdentifierPart
DeleteToken = "delete" !IdentifierPart
DoToken = "do" !IdentifierPart
ElseToken = "else" !IdentifierPart
Expand Down Expand Up @@ -531,6 +535,7 @@ SolidityToken = "solidity" !IdentifierPart
StorageToken = "storage" !IdentifierPart
StructToken = "struct" !IdentifierPart
SuperToken = "super" !IdentifierPart
SwitchToken = "switch" !IdentifierPart
SzaboToken = "szabo" !IdentifierPart
ThisToken = "this" !IdentifierPart
ThrowToken = "throw" !IdentifierPart
Expand Down Expand Up @@ -1774,7 +1779,9 @@ AssemblyItem
/ AssemblyAssignment
/ AssemblyLabel
/ AssemblyIf
/ AssemblySwitch
/ AssemblyFor
/ AssemblyBreakContinue
/ NumericLiteral
/ StringLiteral
/ HexStringLiteral
Expand Down Expand Up @@ -1875,6 +1882,42 @@ AssemblyIf
}
}

AssemblySwitch
= SwitchToken __ test:AssemblyExpression __ body:AssemblySwitchStatement {
return {
type: "AssemblySwitch",
test: test,
body: body,
start: location().start.offset,
end: location().end.offset
}
}

AssemblySwitchStatement
= AssemblyCase+ __ AssemblyDefault?
/ AssemblyDefault

AssemblyCase
= CaseToken __ value:Literal __ body:InlineAssemblyBlock {
return {
type: "AssemblyCase",
value: value,
body: body,
start: location().start.offset,
end: location().end.offset
}
}

AssemblyDefault
= DefaultToken __ body:InlineAssemblyBlock {
return {
type: "AssemblyDefault",
body: body,
start: location().start.offset,
end: location().end.offset
}
}

AssemblyFor
= ForToken __
init:(InlineAssemblyBlock / FunctionalAssemblyInstruction) __
Expand All @@ -1892,3 +1935,7 @@ AssemblyFor
end: location().end.offset
};
}

AssemblyBreakContinue
= BreakToken
/ ContinueToken