Skip to content

Commit

Permalink
Readding block and adapt Frontend to handle new grammar
Browse files Browse the repository at this point in the history
  • Loading branch information
konradweiss committed Dec 1, 2023
1 parent 62c192a commit f1b2c6e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
1 change: 1 addition & 0 deletions cpg-solidity/src/main/antlr/Solidity.g4
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ sourceUnit
| usingForDeclaration
// additional parts found in snippets
| expressionStatement
| block
| statement
)* EOF ;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ class DeclarationHandler(lang: SolidityLanguageFrontend) : Handler<Declaration,
declaration?.let { frontend.scopeManager.addDeclaration(declaration) }
}

if(unit.block() != null || unit.statement() != null){
if(unit.block() != null && unit.block().isNotEmpty() || unit.statement() != null && unit.statement().isNotEmpty()){
frontend.scopeManager.addDeclaration(handleMissingFunctionDefinition(filename, unit))
}

Expand Down Expand Up @@ -348,9 +348,10 @@ class DeclarationHandler(lang: SolidityLanguageFrontend) : Handler<Declaration,

method.receiver = receiver

if(unit.block()!= null){
method.body = frontend.statementHandler.handle(unit.block())
}else if(unit.statement() != null){
if(unit.block()!= null && unit.block().isNotEmpty()){
method.body = frontend.statementHandler.handle(unit.block()[0])
}else
if(unit.statement() != null && unit.statement().isNotEmpty()){
method.body = frontend.statementHandler.handleMissingBlock(unit)
}

Expand Down

0 comments on commit f1b2c6e

Please sign in to comment.