Revision: 19861
Author: [email protected]
Date: Wed Mar 12 19:15:17 2014 UTC
Log: Parser / PreParser unification: Add docs.
[email protected], rossberg
BUG=v8:3126
LOG=N
Review URL: https://codereview.chromium.org/196953004
http://code.google.com/p/v8/source/detail?r=19861
Modified:
/branches/bleeding_edge/src/parser.h
/branches/bleeding_edge/src/preparser.h
=======================================
--- /branches/bleeding_edge/src/parser.h Wed Mar 12 14:03:25 2014 UTC
+++ /branches/bleeding_edge/src/parser.h Wed Mar 12 19:15:17 2014 UTC
@@ -408,11 +408,12 @@
class ParserTraits {
public:
struct Type {
+ // TODO(marja): To be removed. The Traits object should contain all
the data
+ // it needs.
typedef v8::internal::Parser* Parser;
- // Types used by FunctionState and BlockState.
+ // Used by FunctionState and BlockState.
typedef v8::internal::Scope Scope;
- typedef AstNodeFactory<AstConstructionVisitor> Factory;
typedef Variable GeneratorVariable;
typedef v8::internal::Zone Zone;
@@ -424,6 +425,9 @@
typedef ObjectLiteral::Property* ObjectLiteralProperty;
typedef ZoneList<v8::internal::Expression*>* ExpressionList;
typedef ZoneList<ObjectLiteral::Property*>* PropertyList;
+
+ // For constructing objects returned by the traversing functions.
+ typedef AstNodeFactory<AstConstructionVisitor> Factory;
};
explicit ParserTraits(Parser* parser) : parser_(parser) {}
=======================================
--- /branches/bleeding_edge/src/preparser.h Wed Mar 12 14:15:13 2014 UTC
+++ /branches/bleeding_edge/src/preparser.h Wed Mar 12 19:15:17 2014 UTC
@@ -38,7 +38,46 @@
namespace v8 {
namespace internal {
-// Common base class shared between parser and pre-parser.
+// Common base class shared between parser and pre-parser. Traits
encapsulate
+// the differences between Parser and PreParser:
+
+// - Return types: For example, Parser functions return Expression* and
+// PreParser functions return PreParserExpression.
+
+// - Creating parse tree nodes: Parser generates an AST during the
recursive
+// descent. PreParser doesn't create a tree. Instead, it passes around
minimal
+// data objects (PreParserExpression, PreParserIdentifier etc.) which
contain
+// just enough data for the upper layer functions. PreParserFactory is
+// responsible for creating these dummy objects. It provides a similar
kind of
+// interface as AstNodeFactory, so ParserBase doesn't need to care which
one is
+// used.
+
+// - Miscellanous other tasks interleaved with the recursive descent. For
+// example, Parser keeps track of which function literals should be marked
as
+// pretenured, and PreParser doesn't care.
+
+// The traits are expected to contain the following typedefs:
+// struct Traits {
+// // In particular...
+// struct Type {
+// // Used by FunctionState and BlockState.
+// typedef Scope;
+// typedef GeneratorVariable;
+// typedef Zone;
+// // Return types for traversing functions.
+// typedef Identifier;
+// typedef Expression;
+// typedef FunctionLiteral;
+// typedef ObjectLiteralProperty;
+// typedef Literal;
+// typedef ExpressionList;
+// typedef PropertyList;
+// // For constructing objects returned by the traversing functions.
+// typedef Factory;
+// };
+// // ...
+// };
+
template <typename Traits>
class ParserBase : public Traits {
public:
@@ -652,11 +691,12 @@
class PreParserTraits {
public:
struct Type {
+ // TODO(marja): To be removed. The Traits object should contain all
the data
+ // it needs.
typedef PreParser* Parser;
- // Types used by FunctionState and BlockState.
+ // Used by FunctionState and BlockState.
typedef PreParserScope Scope;
- typedef PreParserFactory Factory;
// PreParser doesn't need to store generator variables.
typedef void GeneratorVariable;
// No interaction with Zones.
@@ -670,6 +710,9 @@
typedef PreParserExpression Literal;
typedef PreParserExpressionList ExpressionList;
typedef PreParserExpressionList PropertyList;
+
+ // For constructing objects returned by the traversing functions.
+ typedef PreParserFactory Factory;
};
explicit PreParserTraits(PreParser* pre_parser) :
pre_parser_(pre_parser) {}
--
--
v8-dev mailing list
[email protected]
http://groups.google.com/group/v8-dev
---
You received this message because you are subscribed to the Google Groups "v8-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.