зеркало из https://github.com/mozilla/pjs.git
Added '-t' option for controlling parse tree dump.
This commit is contained in:
Родитель
c651ab3821
Коммит
1ccd3cbcfc
|
@ -115,7 +115,7 @@ static int readEvalPrint(FILE *in)
|
|||
try {
|
||||
Pragma::Flags flags = Pragma::es4;
|
||||
Parser p(world, a, flags, buffer, ConsoleName);
|
||||
if (showTokens) {
|
||||
if (metadata->showTrees) {
|
||||
Lexer &l = p.lexer;
|
||||
while (true) {
|
||||
const Token &t = l.get(true);
|
||||
|
@ -165,9 +165,10 @@ static int readEvalPrint(FILE *in)
|
|||
return result;
|
||||
}
|
||||
|
||||
static bool processArgs(int argc, char **argv, int *result)
|
||||
static bool processArgs(int argc, char **argv, int *result, bool *doTrees)
|
||||
{
|
||||
bool doInteractive = true;
|
||||
*doTrees = false;
|
||||
for (int i = 0; i < argc; i++) {
|
||||
if (argv[i][0] == '-') {
|
||||
switch (argv[i][1]) {
|
||||
|
@ -175,6 +176,9 @@ static bool processArgs(int argc, char **argv, int *result)
|
|||
stdOut << "unrecognized command line switch\n";
|
||||
i = argc;
|
||||
break;
|
||||
case 't':
|
||||
*doTrees = true;
|
||||
break;
|
||||
case 'i':
|
||||
doInteractive = true;
|
||||
break;
|
||||
|
@ -287,7 +291,7 @@ int main(int argc, char **argv)
|
|||
bool doInteractive = true;
|
||||
int result = 0;
|
||||
if (argc > 1) {
|
||||
doInteractive = processArgs(argc - 1, argv + 1, &result);
|
||||
doInteractive = processArgs(argc - 1, argv + 1, &result, &metadata->showTrees);
|
||||
}
|
||||
if (doInteractive)
|
||||
result = readEvalPrint(stdin);
|
||||
|
|
|
@ -71,7 +71,7 @@ namespace MetaData {
|
|||
try {
|
||||
StmtNode *parsedStatements = p.parseProgram();
|
||||
ASSERT(p.lexer.peek(true).hasKind(Token::end));
|
||||
if (true)
|
||||
if (showTrees)
|
||||
{
|
||||
PrettyPrinter f(stdOut, 80);
|
||||
{
|
||||
|
@ -2771,7 +2771,8 @@ doUnary:
|
|||
publicNamespace(new Namespace(engine->public_StringAtom)),
|
||||
bCon(new BytecodeContainer()),
|
||||
glob(new GlobalObject(world)),
|
||||
env(new MetaData::SystemFrame(), glob)
|
||||
env(new MetaData::SystemFrame(), glob),
|
||||
showTrees(false)
|
||||
{
|
||||
engine->meta = this;
|
||||
|
||||
|
|
|
@ -1060,10 +1060,12 @@ public:
|
|||
Environment env;
|
||||
Context cxt;
|
||||
|
||||
TargetList targetList;
|
||||
TargetList targetList; // stack of potential break/continue targets
|
||||
|
||||
void mark();
|
||||
|
||||
bool showTrees; // debug only, causes parse tree dump
|
||||
|
||||
};
|
||||
|
||||
}; // namespace MetaData
|
||||
|
|
Загрузка…
Ссылка в новой задаче