as2js: as2js::Parser Class Reference

#include <parser.h>

Public Types typedef std::shared_ptr< Parserpointer_t   Public Member Functions  Parser (Input::pointer_t input, Options::pointer_t options)   Node::pointer_t parse ()   Private Member Functions void additive_expression (Node::pointer_t &node)   void assignment_expression (Node::pointer_t &node)   void attributes (Node::pointer_t &attr_list)   void bitwise_and_expression (Node::pointer_t &node)   void bitwise_or_expression (Node::pointer_t &node)   void bitwise_xor_expression (Node::pointer_t &node)   void block (Node::pointer_t &node)   void break_continue (Node::pointer_t &node, Node::node_t type)  Read a break or continue statement. More...
  void case_directive (Node::pointer_t &node)   void catch_directive (Node::pointer_t &node)   void class_declaration (Node::pointer_t &node, Node::node_t type)   void conditional_expression (Node::pointer_t &node, bool assignment)   void contract_declaration (Node::pointer_t &node, Node::node_t type)   void debugger (Node::pointer_t &node)   void default_directive (Node::pointer_t &node)   void directive (Node::pointer_t &node)   void directive_list (Node::pointer_t &node)   void do_directive (Node::pointer_t &node)   void enum_declaration (Node::pointer_t &node)   void equality_expression (Node::pointer_t &node)   void expression (Node::pointer_t &node)   void for_directive (Node::pointer_t &node)   void forced_block (Node::pointer_t &node, Node::pointer_t statement)   void function (Node::pointer_t &node, bool const expression)   void get_token ()   void goto_directive (Node::pointer_t &node)   bool has_option_set (Options::option_t option) const  Check whether a given option is set. More...
  void if_directive (Node::pointer_t &node)   void import (Node::pointer_t &node)   void list_expression (Node::pointer_t &node, bool rest, bool empty)   void logical_and_expression (Node::pointer_t &node)   void logical_or_expression (Node::pointer_t &node)   void logical_xor_expression (Node::pointer_t &node)   void match_expression (Node::pointer_t &node)   void min_max_expression (Node::pointer_t &node)   void multiplicative_expression (Node::pointer_t &node)   void namespace_block (Node::pointer_t &node, Node::pointer_t &attr_list)   void numeric_type (Node::pointer_t &numeric_type_node, Node::pointer_t &name)   void object_literal_expression (Node::pointer_t &node)   void package (Node::pointer_t &node)   void parameter_list (Node::pointer_t &node, bool &has_out)   void postfix_expression (Node::pointer_t &node)   void power_expression (Node::pointer_t &node)   void pragma ()   void pragma_option (Options::option_t option, bool prima, Node::pointer_t &argument, Options::option_value_t value)   void primary_expression (Node::pointer_t &node)   void program (Node::pointer_t &node)   void relational_expression (Node::pointer_t &node)   void return_directive (Node::pointer_t &node)   void shift_expression (Node::pointer_t &node)   void switch_directive (Node::pointer_t &node)   void synchronized (Node::pointer_t &node)   void throw_directive (Node::pointer_t &node)   void try_finally (Node::pointer_t &node, Node::node_t const type)   void unary_expression (Node::pointer_t &node)   void unget_token (Node::pointer_t &data)   void use_namespace (Node::pointer_t &node)   void variable (Node::pointer_t &node, Node::node_t const type)  Parse a variable definition. More...
  void with_while (Node::pointer_t &node, Node::node_t const type)   void yield (Node::pointer_t &node)   Private Attributes Lexer::pointer_t f_lexer = Lexer::pointer_t()   Node::pointer_t f_node = Node::pointer_t()   Options::pointer_t f_options = Options::pointer_t()   Node::pointer_t f_root = Node::pointer_t()   Node::vector_of_pointers_t f_unget = Node::vector_of_pointers_t()   Detailed Description

Definition at line 66 of file parser.h.

Member Typedef Documentation
typedef std::shared_ptr<Parser> as2js::Parser::pointer_t

Definition at line 69 of file parser.h.

Constructor & Destructor Documentation
as2js::Parser::Parser ( Input::pointer_t  input, Options::pointer_t  options  )

Definition at line 49 of file parser.cpp.

Member Function Documentation
void as2js::Parser::additive_expression ( Node::pointer_tnode) private
void as2js::Parser::bitwise_and_expression ( Node::pointer_tnode) private
void as2js::Parser::bitwise_or_expression ( Node::pointer_tnode) private
void as2js::Parser::bitwise_xor_expression ( Node::pointer_tnode) private
void as2js::Parser::break_continue ( Node::pointer_tnode, Node::node_t  type  ) private

The statement is a break or continue optionally followed by a label (an identifier) or the default keyword (a special label meaning use the default behavior.)

Then we expect a semi-colon.

The label is saved in the break or continue statement as the string of the break or continue node.

// A break by itself or the default break
break;
break default;
// A break with a label
break label;
Parameters
[out]nodeThe node to be created. [in]typeThe type of node (break or continue).

Definition at line 139 of file parser_statement.cpp.

References as2js::AS_ERR_INVALID_LABEL, f_lexer, f_node, get_token(), as2js::MESSAGE_LEVEL_ERROR, as2js::Node::NODE_DEFAULT, as2js::Node::NODE_IDENTIFIER, and as2js::Node::NODE_SEMICOLON.

Referenced by directive().

void as2js::Parser::debugger ( Node::pointer_tnode) private

Definition at line 313 of file parser_statement.cpp.

References f_lexer, and as2js::Node::NODE_DEBUGGER.

Referenced by directive().

void as2js::Parser::default_directive ( Node::pointer_tnode) private
void as2js::Parser::directive ( Node::pointer_tnode) private

Definition at line 133 of file parser_directive.cpp.

References as2js::AS_ERR_INTERNAL_ERROR, as2js::AS_ERR_INVALID_ATTRIBUTES, as2js::AS_ERR_INVALID_KEYWORD, as2js::AS_ERR_INVALID_OPERATOR, as2js::AS_ERR_SEMICOLON_EXPECTED, as2js::AS_ERR_UNEXPECTED_EOF, attributes(), block(), break_continue(), case_directive(), catch_directive(), class_declaration(), contract_declaration(), debugger(), default_directive(), do_directive(), enum_declaration(), expression(), f_lexer, f_node, for_directive(), get_token(), goto_directive(), if_directive(), as2js::MESSAGE_LEVEL_ERROR, as2js::MESSAGE_LEVEL_FATAL, namespace_block(), as2js::Node::NODE_ABSTRACT, as2js::Node::NODE_ADD, as2js::Node::NODE_ARRAY, as2js::Node::NODE_ARRAY_LITERAL, as2js::Node::NODE_AS, as2js::Node::NODE_ASSIGNMENT, as2js::Node::NODE_ASSIGNMENT_ADD, as2js::Node::NODE_ASSIGNMENT_BITWISE_AND, as2js::Node::NODE_ASSIGNMENT_BITWISE_OR, as2js::Node::NODE_ASSIGNMENT_BITWISE_XOR, as2js::Node::NODE_ASSIGNMENT_DIVIDE, as2js::Node::NODE_ASSIGNMENT_LOGICAL_AND, as2js::Node::NODE_ASSIGNMENT_LOGICAL_OR, as2js::Node::NODE_ASSIGNMENT_LOGICAL_XOR, as2js::Node::NODE_ASSIGNMENT_MAXIMUM, as2js::Node::NODE_ASSIGNMENT_MINIMUM, as2js::Node::NODE_ASSIGNMENT_MODULO, as2js::Node::NODE_ASSIGNMENT_MULTIPLY, as2js::Node::NODE_ASSIGNMENT_POWER, as2js::Node::NODE_ASSIGNMENT_ROTATE_LEFT, as2js::Node::NODE_ASSIGNMENT_ROTATE_RIGHT, as2js::Node::NODE_ASSIGNMENT_SHIFT_LEFT, as2js::Node::NODE_ASSIGNMENT_SHIFT_RIGHT, as2js::Node::NODE_ASSIGNMENT_SHIFT_RIGHT_UNSIGNED, as2js::Node::NODE_ASSIGNMENT_SUBTRACT, as2js::Node::NODE_ATTRIBUTES, as2js::Node::NODE_AUTO, as2js::Node::NODE_BITWISE_AND, as2js::Node::NODE_BITWISE_NOT, as2js::Node::NODE_BITWISE_OR, as2js::Node::NODE_BITWISE_XOR, as2js::Node::NODE_BOOLEAN, as2js::Node::NODE_BREAK, as2js::Node::NODE_BYTE, as2js::Node::NODE_CALL, as2js::Node::NODE_CASE, as2js::Node::NODE_CATCH, as2js::Node::NODE_CHAR, as2js::Node::NODE_CLASS, as2js::Node::NODE_CLOSE_CURVLY_BRACKET, as2js::Node::NODE_CLOSE_PARENTHESIS, as2js::Node::NODE_CLOSE_SQUARE_BRACKET, as2js::Node::NODE_COLON, as2js::Node::NODE_COMMA, as2js::Node::NODE_COMPARE, as2js::Node::NODE_CONDITIONAL, as2js::Node::NODE_CONST, as2js::Node::NODE_CONTINUE, as2js::Node::NODE_DEBUGGER, as2js::Node::NODE_DECREMENT, as2js::Node::NODE_DEFAULT, as2js::Node::NODE_DELETE, as2js::Node::NODE_DIRECTIVE_LIST, as2js::Node::NODE_DIVIDE, as2js::Node::NODE_DO, as2js::Node::NODE_DOUBLE, as2js::Node::NODE_ELSE, as2js::Node::NODE_EMPTY, as2js::Node::NODE_ENSURE, as2js::Node::NODE_ENUM, as2js::Node::NODE_EOF, as2js::Node::NODE_EQUAL, as2js::Node::NODE_EXCLUDE, as2js::Node::NODE_EXPORT, as2js::Node::NODE_EXTENDS, as2js::Node::NODE_FALSE, as2js::Node::NODE_FINAL, as2js::Node::NODE_FINALLY, as2js::Node::NODE_FLOAT, as2js::Node::NODE_FLOAT64, as2js::Node::NODE_FOR, as2js::Node::NODE_FUNCTION, as2js::Node::NODE_GOTO, as2js::Node::NODE_GREATER, as2js::Node::NODE_GREATER_EQUAL, as2js::Node::NODE_IDENTIFIER, as2js::Node::NODE_IF, as2js::Node::NODE_IMPLEMENTS, as2js::Node::NODE_IMPORT, as2js::Node::NODE_IN, as2js::Node::NODE_INCLUDE, as2js::Node::NODE_INCREMENT, as2js::Node::NODE_INLINE, as2js::Node::NODE_INSTANCEOF, as2js::Node::NODE_INT64, as2js::Node::NODE_INTERFACE, as2js::Node::NODE_INVARIANT, as2js::Node::NODE_IS, as2js::Node::NODE_LABEL, as2js::Node::NODE_LESS, as2js::Node::NODE_LESS_EQUAL, as2js::Node::NODE_LIST, as2js::Node::NODE_LOGICAL_AND, as2js::Node::NODE_LOGICAL_NOT, as2js::Node::NODE_LOGICAL_OR, as2js::Node::NODE_LOGICAL_XOR, as2js::Node::NODE_LONG, as2js::Node::NODE_MATCH, as2js::Node::NODE_max, as2js::Node::NODE_MAXIMUM, as2js::Node::NODE_MEMBER, as2js::Node::NODE_MINIMUM, as2js::Node::NODE_MODULO, as2js::Node::NODE_MULTIPLY, as2js::Node::NODE_NAME, as2js::Node::NODE_NAMESPACE, as2js::Node::NODE_NATIVE, as2js::Node::NODE_NEW, as2js::Node::NODE_NOT_EQUAL, as2js::Node::NODE_NOT_MATCH, as2js::Node::NODE_NULL, as2js::Node::NODE_OBJECT_LITERAL, as2js::Node::NODE_OPEN_CURVLY_BRACKET, as2js::Node::NODE_OPEN_PARENTHESIS, as2js::Node::NODE_OPEN_SQUARE_BRACKET, as2js::Node::NODE_other, as2js::Node::NODE_PACKAGE, as2js::Node::NODE_PARAM, as2js::Node::NODE_PARAM_MATCH, as2js::Node::NODE_PARAMETERS, as2js::Node::NODE_POST_DECREMENT, as2js::Node::NODE_POST_INCREMENT, as2js::Node::NODE_POWER, as2js::Node::NODE_PRIVATE, as2js::Node::NODE_PROGRAM, as2js::Node::NODE_PROTECTED, as2js::Node::NODE_PUBLIC, as2js::Node::NODE_RANGE, as2js::Node::NODE_REGULAR_EXPRESSION, as2js::Node::NODE_REQUIRE, as2js::Node::NODE_REST, as2js::Node::NODE_RETURN, as2js::Node::NODE_ROOT, as2js::Node::NODE_ROTATE_LEFT, as2js::Node::NODE_ROTATE_RIGHT, as2js::Node::NODE_SCOPE, as2js::Node::NODE_SEMICOLON, as2js::Node::NODE_SET, as2js::Node::NODE_SHIFT_LEFT, as2js::Node::NODE_SHIFT_RIGHT, as2js::Node::NODE_SHIFT_RIGHT_UNSIGNED, as2js::Node::NODE_SHORT, as2js::Node::NODE_SMART_MATCH, as2js::Node::NODE_STATIC, as2js::Node::NODE_STRICTLY_EQUAL, as2js::Node::NODE_STRICTLY_NOT_EQUAL, as2js::Node::NODE_STRING, as2js::Node::NODE_SUBTRACT, as2js::Node::NODE_SUPER, as2js::Node::NODE_SWITCH, as2js::Node::NODE_SYNCHRONIZED, as2js::Node::NODE_THEN, as2js::Node::NODE_THIS, as2js::Node::NODE_THROW, as2js::Node::NODE_THROWS, as2js::Node::NODE_TRANSIENT, as2js::Node::NODE_TRUE, as2js::Node::NODE_TRY, as2js::Node::NODE_TYPE, as2js::Node::NODE_TYPEOF, as2js::Node::NODE_UNDEFINED, as2js::Node::NODE_UNKNOWN, as2js::Node::NODE_USE, as2js::Node::NODE_VAR, as2js::Node::NODE_VAR_ATTRIBUTES, as2js::Node::NODE_VARIABLE, as2js::Node::NODE_VIDENTIFIER, as2js::Node::NODE_VOID, as2js::Node::NODE_VOLATILE, as2js::Node::NODE_WHILE, as2js::Node::NODE_WITH, as2js::Node::NODE_YIELD, numeric_type(), package(), pragma(), return_directive(), switch_directive(), throw_directive(), try_finally(), as2js::Node::type_to_string(), unget_token(), use_namespace(), variable(), with_while(), and yield().

Referenced by directive_list(), and forced_block().

void as2js::Parser::function ( Node::pointer_tnode, bool const  expression  ) private

Definition at line 255 of file parser_function.cpp.

References as2js::AS_ERR_CURVLY_BRACKETS_EXPECTED, as2js::AS_ERR_INVALID_FUNCTION, as2js::AS_ERR_NOT_ALLOWED, as2js::AS_ERR_PARENTHESIS_EXPECTED, conditional_expression(), contract_declaration(), directive_list(), f_lexer, f_node, get_token(), has_option_set(), as2js::MESSAGE_LEVEL_ERROR, as2js::Node::NODE_ADD, as2js::Node::NODE_ASSIGNMENT, as2js::Node::NODE_ASSIGNMENT_ADD, as2js::Node::NODE_ASSIGNMENT_BITWISE_AND, as2js::Node::NODE_ASSIGNMENT_BITWISE_OR, as2js::Node::NODE_ASSIGNMENT_BITWISE_XOR, as2js::Node::NODE_ASSIGNMENT_DIVIDE, as2js::Node::NODE_ASSIGNMENT_LOGICAL_AND, as2js::Node::NODE_ASSIGNMENT_LOGICAL_OR, as2js::Node::NODE_ASSIGNMENT_LOGICAL_XOR, as2js::Node::NODE_ASSIGNMENT_MAXIMUM, as2js::Node::NODE_ASSIGNMENT_MINIMUM, as2js::Node::NODE_ASSIGNMENT_MODULO, as2js::Node::NODE_ASSIGNMENT_MULTIPLY, as2js::Node::NODE_ASSIGNMENT_POWER, as2js::Node::NODE_ASSIGNMENT_ROTATE_LEFT, as2js::Node::NODE_ASSIGNMENT_ROTATE_RIGHT, as2js::Node::NODE_ASSIGNMENT_SHIFT_LEFT, as2js::Node::NODE_ASSIGNMENT_SHIFT_RIGHT, as2js::Node::NODE_ASSIGNMENT_SHIFT_RIGHT_UNSIGNED, as2js::Node::NODE_ASSIGNMENT_SUBTRACT, as2js::Node::NODE_ATTR_ENSURE_THEN, as2js::Node::NODE_ATTR_REQUIRE_ELSE, as2js::Node::NODE_BITWISE_AND, as2js::Node::NODE_BITWISE_NOT, as2js::Node::NODE_BITWISE_OR, as2js::Node::NODE_BITWISE_XOR, as2js::Node::NODE_CLOSE_CURVLY_BRACKET, as2js::Node::NODE_CLOSE_PARENTHESIS, as2js::Node::NODE_COLON, as2js::Node::NODE_COMMA, as2js::Node::NODE_COMPARE, as2js::Node::NODE_DECREMENT, as2js::Node::NODE_DIVIDE, as2js::Node::NODE_ELSE, as2js::Node::NODE_ENSURE, as2js::Node::NODE_EQUAL, as2js::Node::NODE_FUNCTION, as2js::Node::NODE_FUNCTION_FLAG_GETTER, as2js::Node::NODE_FUNCTION_FLAG_NEVER, as2js::Node::NODE_FUNCTION_FLAG_NOPARAMS, as2js::Node::NODE_FUNCTION_FLAG_OPERATOR, as2js::Node::NODE_FUNCTION_FLAG_OUT, as2js::Node::NODE_FUNCTION_FLAG_SETTER, as2js::Node::NODE_FUNCTION_FLAG_VOID, as2js::Node::NODE_GREATER, as2js::Node::NODE_GREATER_EQUAL, as2js::Node::NODE_IDENTIFIER, as2js::Node::NODE_INCREMENT, as2js::Node::NODE_LESS, as2js::Node::NODE_LESS_EQUAL, as2js::Node::NODE_LOGICAL_AND, as2js::Node::NODE_LOGICAL_NOT, as2js::Node::NODE_LOGICAL_OR, as2js::Node::NODE_LOGICAL_XOR, as2js::Node::NODE_MATCH, as2js::Node::NODE_MAXIMUM, as2js::Node::NODE_MINIMUM, as2js::Node::NODE_MODULO, as2js::Node::NODE_MULTIPLY, as2js::Node::NODE_NOT_EQUAL, as2js::Node::NODE_NOT_MATCH, as2js::Node::NODE_OPEN_CURVLY_BRACKET, as2js::Node::NODE_OPEN_PARENTHESIS, as2js::Node::NODE_POST_DECREMENT, as2js::Node::NODE_POST_INCREMENT, as2js::Node::NODE_POWER, as2js::Node::NODE_REQUIRE, as2js::Node::NODE_ROTATE_LEFT, as2js::Node::NODE_ROTATE_RIGHT, as2js::Node::NODE_SHIFT_LEFT, as2js::Node::NODE_SHIFT_RIGHT, as2js::Node::NODE_SHIFT_RIGHT_UNSIGNED, as2js::Node::NODE_SMART_MATCH, as2js::Node::NODE_STRICTLY_EQUAL, as2js::Node::NODE_STRICTLY_NOT_EQUAL, as2js::Node::NODE_STRING, as2js::Node::NODE_SUBTRACT, as2js::Node::NODE_THEN, as2js::Node::NODE_THROWS, as2js::Node::NODE_TYPE, as2js::Node::NODE_UNKNOWN, as2js::Node::NODE_VOID, as2js::Node::operator_to_string(), as2js::Options::OPTION_EXTENDED_OPERATORS, parameter_list(), as2js::Node::string_to_operator(), and unget_token().

void as2js::Parser::goto_directive ( Node::pointer_tnode) private
bool as2js::Parser::has_option_set ( Options::option_t  option) const private

Because the parser checks options in many places, it makes use of this helper function just in case we wanted to handle various special cases. (I had two before, but both have been removed at this point.)

This function checks whether the specified option is set. If so, then it returns true, otherwise it returns false.

Parameters
[in]optionThe option to check.
Returns
true if the option was set, false otherwise.

Definition at line 110 of file parser.cpp.

References f_options.

Referenced by assignment_expression(), case_directive(), equality_expression(), function(), logical_xor_expression(), match_expression(), min_max_expression(), object_literal_expression(), postfix_expression(), power_expression(), primary_expression(), relational_expression(), shift_expression(), switch_directive(), and with_while().

void as2js::Parser::logical_and_expression ( Node::pointer_tnode) private
void as2js::Parser::logical_or_expression ( Node::pointer_tnode) private
void as2js::Parser::multiplicative_expression ( Node::pointer_tnode) private
Node::pointer_t as2js::Parser::parse ( )

Definition at line 59 of file parser.cpp.

References f_root, get_token(), and program().

void as2js::Parser::return_directive ( Node::pointer_tnode) private
void as2js::Parser::throw_directive ( Node::pointer_tnode) private
void as2js::Parser::try_finally ( Node::pointer_tnode, Node::node_t const  type  ) private
void as2js::Parser::unget_token ( Node::pointer_tdata) private

Definition at line 90 of file parser.cpp.

References f_unget.

Referenced by directive(), function(), and list_expression().

void as2js::Parser::use_namespace ( Node::pointer_tnode) private

Definition at line 347 of file parser_package.cpp.

References expression(), f_lexer, and as2js::Node::NODE_USE.

Referenced by directive().

void as2js::Parser::variable ( Node::pointer_tnode, Node::node_t const  variable_type  ) private

Variables can be introduce with the VAR keyword:

VAR name;
VAR name = expression;

Variables can also be marked constant with the CONST keyword, in that case the VAR keyword is optional. In this case, the value of the variable must be defined:

CONST VAR name = expression;
CONST name = expression;

Variables can also be marked final with the FINAL keyword, in that case the VAR keyword is optional. A final variable can be initialized once only, but it does not need to happen at the time the variable is declared:

FINAL VAR name;
FINAL VAR name = expresion;
FINAL name;
FINAL name = expression;
Parameters
[out]nodeThe node where the variable (NODE_VAR) is saved. [in]variable_typeThe type of variable (NODE_VAR, NODE_CONST, or NODE_FINAL).

Definition at line 81 of file parser_variable.cpp.

References as2js::AS_ERR_INVALID_VARIABLE, conditional_expression(), f_lexer, f_node, get_token(), as2js::MESSAGE_LEVEL_ERROR, as2js::Node::NODE_ASSIGNMENT, as2js::Node::NODE_CLOSE_CURVLY_BRACKET, as2js::Node::NODE_CLOSE_PARENTHESIS, as2js::Node::NODE_COLON, as2js::Node::NODE_COMMA, as2js::Node::NODE_CONST, as2js::Node::NODE_FINAL, as2js::Node::NODE_IDENTIFIER, as2js::Node::NODE_OPEN_CURVLY_BRACKET, as2js::Node::NODE_SEMICOLON, as2js::Node::NODE_SET, as2js::Node::NODE_TYPE, as2js::Node::NODE_VAR, as2js::Node::NODE_VARIABLE, as2js::Node::NODE_VARIABLE_FLAG_CONST, and as2js::Node::NODE_VARIABLE_FLAG_FINAL.

Referenced by directive(), and for_directive().

void as2js::Parser::yield ( Node::pointer_tnode) private
Member Data Documentation
Options::pointer_t as2js::Parser::f_options = Options::pointer_t() private

Definition at line 139 of file parser.h.

Referenced by forced_block(), has_option_set(), and pragma_option().

Node::pointer_t as2js::Parser::f_root = Node::pointer_t() private

Definition at line 140 of file parser.h.

Referenced by parse().

Node::vector_of_pointers_t as2js::Parser::f_unget = Node::vector_of_pointers_t() private

Definition at line 142 of file parser.h.

Referenced by get_token(), and unget_token().


The documentation for this class was generated from the following files:

This document is part of the Snap! Websites Project.

Copyright by Made to Order Software Corp.

Syndicate content

Snap! Websites
An Open Source CMS System in C++

Contact Us Directly