示例#1
0
/**
 * Initialize lexer to start parsing of a new source
 */
void
lexer_init (const jerry_api_char_t *source, /**< script source */
            size_t source_size, /**< script source size in bytes */
            bool is_print_source_code) /**< flag indicating whether to dump
                                        *   processed source code */
{
  empty_token.type = TOK_EMPTY;
  empty_token.uid = 0;
  empty_token.loc = LIT_ITERATOR_POS_ZERO;

  saved_token = prev_token = sent_token = prev_non_lf_token = empty_token;

  if (!lit_is_utf8_string_valid (source, (lit_utf8_size_t) source_size))
  {
    PARSE_ERROR (JSP_EARLY_ERROR_SYNTAX, "Invalid source encoding", LIT_ITERATOR_POS_ZERO);
  }

  src_iter = lit_utf8_iterator_create (source, (lit_utf8_size_t) source_size);

  buffer_size = source_size;
  buffer_start = source;
  is_token_parse_in_progress = false;

  lexer_set_strict_mode (false);

#ifndef JERRY_NDEBUG
  allow_dump_lines = is_print_source_code;
#else /* JERRY_NDEBUG */
  (void) is_print_source_code;
  allow_dump_lines = false;
#endif /* JERRY_NDEBUG */
} /* lexer_init */
示例#2
0
/**
 * Initialize lexer to start parsing of a new source
 */
void
lexer_init (const jerry_api_char_t *source, /**< script source */
            size_t source_size, /**< script source size in bytes */
            bool show_opcodes) /**< flag indicating if to dump opcodes */
{
  empty_token.type = TOK_EMPTY;
  empty_token.uid = 0;
  empty_token.loc = 0;

  saved_token = prev_token = sent_token = empty_token;

  buffer_size = source_size;
  lexer_set_source (source);
  lexer_set_strict_mode (false);

#ifndef JERRY_NDEBUG
  allow_dump_lines = show_opcodes;
#else /* JERRY_NDEBUG */
  (void) show_opcodes;
  allow_dump_lines = false;
#endif /* JERRY_NDEBUG */
} /* lexer_init */