-
Notifications
You must be signed in to change notification settings - Fork 278
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[rubysrc2cpg] Decouple parser and ASTCreator (#3283)
* Fix bug in command line parsing * Decouple parser and ASTCreator * Also log error message * Add missing import --------- Co-authored-by: Fabian Yamaguchi <fabs@joern.io>
- Loading branch information
Showing
3 changed files
with
31 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
16 changes: 16 additions & 0 deletions
16
...i/frontends/rubysrc2cpg/src/main/scala/io/joern/rubysrc2cpg/astcreation/AntlrParser.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
package io.joern.rubysrc2cpg.astcreation | ||
|
||
import io.joern.rubysrc2cpg.parser.{RubyLexer, RubyParser} | ||
import org.antlr.v4.runtime.{CharStreams, CommonTokenStream, ParserRuleContext, Token} | ||
|
||
class AntlrParser { | ||
|
||
def parse(filename: String): RubyParser.ProgramContext = { | ||
val charStream = CharStreams.fromFileName(filename) | ||
val lexer = new RubyLexer(charStream) | ||
val tokenStream = new CommonTokenStream(lexer) | ||
val parser = new RubyParser(tokenStream) | ||
parser.program() | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters