Skip to content
Merged
Show file tree
Hide file tree
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
2 changes: 1 addition & 1 deletion .completion
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ _esmeta_completions() {
compileOpt="-compile:log -compile:log-with-loc -compile:opt"
buildcfgOpt="-build-cfg:log -build-cfg:dot -build-cfg:pdf"
tycheckOpt="-tycheck:target -tycheck:repl -tycheck:repl-continue -tycheck:ignore -tycheck:update-ignore -tycheck:log -tycheck:detail-log -tycheck:type-sens -tycheck:infer-guard"
parseOpt="-parse:debug"
parseOpt="-parse:debug -parse:goal"
evalOpt="-eval:timeout -eval:multiple -eval:tycheck -eval:log -eval:detail-log"
webOpt="-web:host -web:port"
test262testOpt="-test262-test:target -test262-test:features -test262-test:tycheck -test262-test:progress -test262-test:coverage -test262-test:k-fs -test262-test:cp -test262-test:all-tests -test262-test:timeout -test262-test:with-yet -test262-test:log -test262-test:detail-log -test262-test:concurrent"
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/esmeta/Command.scala
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ case object CmdParse extends Command("parse", CmdExtract >> Parse) {
"esmeta parse a.js # parse a.js file.",
"esmeta parse a.js -extract:target=es2025 # parse with es2025 spec.",
"esmeta parse a.js -parse:debug # parse in the debugging mode.",
"esmeta parse a.js -parse:goal=Module # parse as an ECMAScript module.",
)
override val targetName = "<js>+"
}
Expand Down
1 change: 1 addition & 0 deletions src/main/scala/esmeta/cfg/CFG.scala
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ case class CFG(
/** an ECMAScript parser */
lazy val esParser: ESParser = program.esParser
lazy val scriptParser: AstFrom = esParser("Script")
lazy val moduleParser: AstFrom = esParser("Module")

/** initializer for initial states */
lazy val init: Initialize = new Initialize(this)
Expand Down
8 changes: 7 additions & 1 deletion src/main/scala/esmeta/phase/Parse.scala
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,22 @@ case object Parse extends Phase[Spec, Ast] {
config: Config,
): Ast =
val filename = getFirstFilename(cmdConfig, name)
ESParser(spec.grammar, config.debug)("Script").fromFile(filename)
ESParser(spec.grammar, config.debug)(config.goal).fromFile(filename)
def defaultConfig: Config = Config()
val options: List[PhaseOption[Config]] = List(
(
"debug",
BoolOption(_.debug = _),
"turn on debugging mode.",
),
(
"goal",
StrOption(_.goal = _),
"parsing goal: Script or Module (default: Script).",
),
)
case class Config(
var debug: Boolean = false,
var goal: String = "Script",
)
}
1 change: 1 addition & 0 deletions src/main/scala/esmeta/spec/Spec.scala
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ case class Spec(
/** ECMAScript parser */
lazy val esParser: ESParser = ESParser(grammar)
lazy val scriptParser: AstFrom = esParser("Script")
lazy val moduleParser: AstFrom = esParser("Module")

/** get incomplete algorithms */
lazy val incompleteAlgorithms: List[Algorithm] =
Expand Down
Loading