Skip to content
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