Skip to content

Commit

Permalink
change loc nesting on import directive
Browse files Browse the repository at this point in the history
  • Loading branch information
rkrasiuk committed Jan 8, 2022
1 parent 3fbe864 commit 5acf8f5
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions solang-parser/src/solidity.lalrpop
Original file line number Diff line number Diff line change
Expand Up @@ -29,20 +29,20 @@ SourceUnitPart: SourceUnitPart = {
}

ImportDirective: SourceUnitPart = {
<doc:DocComments> <l:@L> "import" <s:StringLiteral> ";" <r:@L> => SourceUnitPart::ImportDirective(doc, Import::Plain(s), Loc(file_no, l, r)),
<doc:DocComments> <l:@L> "import" <s:StringLiteral> "as" <id:Identifier> ";" <r:@L> => SourceUnitPart::ImportDirective(doc, Import::GlobalSymbol(s, id), Loc(file_no, l, r)),
<doc:DocComments> <l:@L> "import" <s:StringLiteral> ";" <r:@L> => SourceUnitPart::ImportDirective(doc, Import::Plain(s, Loc(file_no, l, r))),
<doc:DocComments> <l:@L> "import" <s:StringLiteral> "as" <id:Identifier> ";" <r:@L> => SourceUnitPart::ImportDirective(doc, Import::GlobalSymbol(s, id, Loc(file_no, l, r))),
<doc:DocComments> <l:@L> "import" "*" "as" <id:Identifier> <from:Identifier> <s:StringLiteral> ";" <r:@L> =>? {
if from.name != "from" {
Err(ParseError::User { error: LexicalError::ExpectedFrom(from.loc.0, from.loc.1, from.name)})
} else {
Ok(SourceUnitPart::ImportDirective(doc, Import::GlobalSymbol(s, id), Loc(file_no, l, r)))
Ok(SourceUnitPart::ImportDirective(doc, Import::GlobalSymbol(s, id, Loc(file_no, l, r))))
}
},
<doc:DocComments> <l:@L> "import" "{" <rename:CommaOne<ImportRename>> "}" <from:Identifier> <s:StringLiteral> ";" <r:@L> =>? {
if from.name != "from" {
Err(ParseError::User { error:LexicalError::ExpectedFrom(from.loc.0, from.loc.1, from.name)})
} else {
Ok(SourceUnitPart::ImportDirective(doc, Import::Rename(s, rename), Loc(file_no, l, r)))
Ok(SourceUnitPart::ImportDirective(doc, Import::Rename(s, rename, Loc(file_no, l, r))))
}
}
}
Expand Down

0 comments on commit 5acf8f5

Please sign in to comment.