Ignore:
Timestamp:
Nov 15, 2007, 10:54:09 PM (18 years ago)
Author:
[email protected]
Message:

Reviewed by Eric Seidel.

Another round of grammar / parsing cleanup.


  1. Created distinct parser calls for parsing function bodies vs programs. This will help later with optimizing global variable access.


  1. Turned Parser into a singleton. Cleaned up Lexer's singleton interface.


  1. Modified Lexer to free a little more memory when done lexing. (Added FIXMEs for similar issues that I didn't fix.)


  1. Changed Lexer::makeIdentifier and Lexer::makeUString to start respecting the arguments passed to them. (No behavior change, but this problem could have caused serious problems for an unsuspecting user of these functions.)


  1. Removed KJS_DEBUG_MEM because it was bit-rotted.


  1. Removed Parser::prettyPrint because the same work was simpler to do at the call site.


  1. Some renames:


"Parser::accept" => "Parser::didFinishParsing"
"Parser::sid" => "Parser::m_sourceID"
"Lexer::doneParsing" => "Lexer::clear"
"sid" => "sourceId"
"lineno" => "lineNo"


  • JavaScriptCore.exp:
  • kjs/Parser.cpp: (KJS::Parser::Parser): (KJS::Parser::parseProgram): (KJS::Parser::parseFunctionBody): (KJS::Parser::parse): (KJS::Parser::didFinishParsing): (KJS::parser):
  • kjs/Parser.h: (KJS::Parser::sourceId):
  • kjs/function.cpp: (KJS::GlobalFuncImp::callAsFunction):
  • kjs/function_object.cpp: (FunctionObjectImp::construct):
  • kjs/grammar.y:
  • kjs/interpreter.cpp: (KJS::Interpreter::checkSyntax): (KJS::Interpreter::evaluate):
  • kjs/interpreter.h:
  • kjs/lexer.cpp: (kjsyylex): (KJS::lexer): (KJS::Lexer::Lexer): (KJS::Lexer::~Lexer): (KJS::Lexer::scanRegExp): (KJS::Lexer::doneParsing): (KJS::Lexer::makeIdentifier): (KJS::Lexer::makeUString):
  • kjs/lexer.h: (KJS::Lexer::pattern): (KJS::Lexer::flags): (KJS::Lexer::sawError):
  • kjs/nodes.cpp: (KJS::Node::Node): (KJS::FunctionBodyNode::FunctionBodyNode):
  • kjs/nodes.h:
  • kjs/testkjs.cpp: (prettyPrintScript): (kjsmain):
  • kjs/ustring.cpp:
  • kjs/ustring.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/kjs/testkjs.cpp

    r27031 r27842  
    2424#include "config.h"
    2525
     26#include "JSGlobalObject.h"
    2627#include "JSLock.h"
    2728#include "Parser.h"
    2829#include "collector.h"
    29 #include "JSGlobalObject.h"
     30#include "nodes.h"
    3031#include "object.h"
    3132#include "protect.h"
     
    246247  int errLine = 0;
    247248  UString errMsg;
    248   UString s = Parser::prettyPrint(script.data(), &errLine, &errMsg);
    249   if (s.isNull()) {
     249  UString scriptUString(script.data());
     250  RefPtr<ProgramNode> programNode = parser().parseProgram(fileName, 0, scriptUString.data(), scriptUString.size(), 0, &errLine, &errMsg);
     251  if (!programNode) {
    250252    fprintf(stderr, "%s:%d: %s.\n", fileName.UTF8String().c_str(), errLine, errMsg.UTF8String().c_str());
    251253    return false;
    252254  }
    253255 
    254   printf("%s\n", s.UTF8String().c_str());
     256  printf("%s\n", programNode->toString().UTF8String().c_str());
    255257  return true;
    256258}
     
    314316#endif
    315317
    316 #ifdef KJS_DEBUG_MEM
    317   Interpreter::finalCheck();
    318 #endif
    319318  return success ? 0 : 3;
    320319}
Note: See TracChangeset for help on using the changeset viewer.