Rewrite parser_boolean_t to bool

And `PARSER_{TRUE,FALSE}` to `{true,false}`.

JerryScript-DCO-1.0-Signed-off-by: Akos Kiss akiss@inf.u-szeged.hu
This commit is contained in:
Akos Kiss
2016-08-07 00:58:56 +02:00
parent ff21777950
commit 2eb2b22c49
7 changed files with 149 additions and 158 deletions
+47 -47
View File
@@ -106,7 +106,7 @@ skip_spaces (parser_context_t *context_p) /**< context */
context_p->token.was_newline = 0;
while (PARSER_TRUE)
while (true)
{
if (context_p->source_p >= source_end_p)
{
@@ -419,7 +419,7 @@ static const keyword_string_t * const keyword_string_list[9] =
*/
static void
lexer_parse_identifier (parser_context_t *context_p, /**< context */
int check_keywords) /**< check keywords */
bool check_keywords) /**< check keywords */
{
/* Only very few identifiers contains \u escape sequences. */
const uint8_t *source_p = context_p->source_p;
@@ -430,9 +430,9 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
size_t length = 0;
context_p->token.type = LEXER_LITERAL;
context_p->token.literal_is_reserved = PARSER_FALSE;
context_p->token.literal_is_reserved = false;
context_p->token.lit_location.type = LEXER_IDENT_LITERAL;
context_p->token.lit_location.has_escape = PARSER_FALSE;
context_p->token.lit_location.has_escape = false;
do
{
@@ -440,7 +440,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
{
uint16_t character;
context_p->token.lit_location.has_escape = PARSER_TRUE;
context_p->token.lit_location.has_escape = true;
context_p->source_p = source_p;
context_p->token.column = column;
@@ -520,7 +520,7 @@ lexer_parse_identifier (parser_context_t *context_p, /**< context */
parser_raise_error (context_p, PARSER_ERR_STRICT_IDENT_NOT_ALLOWED);
}
context_p->token.literal_is_reserved = PARSER_TRUE;
context_p->token.literal_is_reserved = true;
break;
}
@@ -558,9 +558,9 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
parser_line_counter_t original_line = line;
parser_line_counter_t original_column = column;
size_t length = 0;
uint8_t has_escape = PARSER_FALSE;
uint8_t has_escape = false;
while (PARSER_TRUE)
while (true)
{
if (source_p >= source_end_p)
{
@@ -584,7 +584,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
continue;
}
has_escape = PARSER_TRUE;
has_escape = true;
/* Newline is ignored. */
if (*source_p == LIT_CHAR_CR
@@ -697,7 +697,7 @@ lexer_parse_string (parser_context_t *context_p) /**< context */
* after a backslash). Always converted to two 3 byte
* long sequence. */
length += 2 * 3;
has_escape = PARSER_TRUE;
has_escape = true;
source_p += 4;
column++;
continue;
@@ -755,15 +755,15 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
{
const uint8_t *source_p = context_p->source_p;
const uint8_t *source_end_p = context_p->source_end_p;
int can_be_float = PARSER_FALSE;
bool can_be_float = false;
size_t length;
context_p->token.type = LEXER_LITERAL;
context_p->token.literal_is_reserved = PARSER_FALSE;
context_p->token.literal_is_reserved = false;
context_p->token.extra_value = LEXER_NUMBER_DECIMAL;
context_p->token.lit_location.char_p = source_p;
context_p->token.lit_location.type = LEXER_NUMBER_LITERAL;
context_p->token.lit_location.has_escape = PARSER_FALSE;
context_p->token.lit_location.has_escape = false;
if (source_p[0] == LIT_CHAR_0
&& source_p + 1 < source_end_p)
@@ -818,7 +818,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
}
else
{
can_be_float = PARSER_TRUE;
can_be_float = true;
source_p++;
}
}
@@ -832,7 +832,7 @@ lexer_parse_number (parser_context_t *context_p) /**< context */
&& source_p[0] >= LIT_CHAR_0
&& source_p[0] <= LIT_CHAR_9);
can_be_float = PARSER_TRUE;
can_be_float = true;
}
if (can_be_float)
@@ -987,7 +987,7 @@ lexer_next_token (parser_context_t *context_p) /**< context */
if (lit_char_is_identifier_start (context_p->source_p)
|| context_p->source_p[0] == LIT_CHAR_BACKSLASH)
{
lexer_parse_identifier (context_p, PARSER_TRUE);
lexer_parse_identifier (context_p, true);
return;
}
@@ -1160,7 +1160,7 @@ lexer_process_char_literal (parser_context_t *context_p, /**< context */
const uint8_t *char_p, /**< characters */
size_t length, /**< length of string */
uint8_t literal_type, /**< final literal type */
uint8_t has_escape) /**< has escape sequences */
bool has_escape) /**< has escape sequences */
{
parser_list_iterator_t literal_iterator;
lexer_literal_t *literal_p;
@@ -1282,7 +1282,7 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
{
uint8_t str_end_character = source_p[-1];
while (PARSER_TRUE)
while (true)
{
if (*source_p == str_end_character)
{
@@ -1514,12 +1514,12 @@ lexer_construct_literal_object (parser_context_t *context_p, /**< context */
/**
* Construct a number object.
*
* @return PARSER_TRUE if number is small number
* @return true if number is small number
*/
int
bool
lexer_construct_number_object (parser_context_t *context_p, /**< context */
int push_number_allowed, /**< push number support is allowed */
int is_negative_number) /**< sign is negative */
bool push_number_allowed, /**< push number support is allowed */
bool is_negative_number) /**< sign is negative */
{
parser_list_iterator_t literal_iterator;
lexer_literal_t *literal_p;
@@ -1556,7 +1556,7 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
&& (int_num != 0 || !is_negative_number))
{
context_p->lit_object.index = (uint16_t) int_num;
return PARSER_TRUE;
return true;
}
}
}
@@ -1576,7 +1576,7 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
{
context_p->lit_object.literal_p = literal_p;
context_p->lit_object.index = (uint16_t) literal_index;
return PARSER_FALSE;
return false;
}
literal_index++;
@@ -1603,7 +1603,7 @@ lexer_construct_number_object (parser_context_t *context_p, /**< context */
context_p->lit_object.index = (uint16_t) literal_index;
context_p->lit_object.type = LEXER_LITERAL_OBJECT_ANY;
return PARSER_FALSE;
return false;
} /* lexer_construct_number_object */
/**
@@ -1647,7 +1647,7 @@ lexer_construct_function_object (parser_context_t *context_p, /**< context */
*/
void
lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
int parse_only) /**< parse only */
bool parse_only) /**< parse only */
{
#ifndef CONFIG_DISABLE_REGEXP_BUILTIN
const uint8_t *source_p = context_p->source_p;
@@ -1656,7 +1656,7 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
const uint8_t *source_end_p = context_p->source_end_p;
parser_line_counter_t column = context_p->column;
lexer_literal_t *literal_p;
int in_class = PARSER_FALSE;
bool in_class = false;
uint16_t current_flags;
lit_utf8_size_t length;
@@ -1668,7 +1668,7 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
regex_start_p--;
}
while (PARSER_TRUE)
while (true)
{
if (source_p >= source_end_p)
{
@@ -1705,12 +1705,12 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
}
case LIT_CHAR_LEFT_SQUARE:
{
in_class = PARSER_TRUE;
in_class = true;
break;
}
case LIT_CHAR_RIGHT_SQUARE:
{
in_class = PARSER_FALSE;
in_class = false;
break;
}
case LIT_CHAR_BACKSLASH:
@@ -1829,7 +1829,7 @@ lexer_construct_regexp_object (parser_context_t *context_p, /**< context */
literal_p->u.bytecode_p = (ecma_compiled_code_t *) re_bytecode_p;
context_p->token.type = LEXER_LITERAL;
context_p->token.literal_is_reserved = PARSER_FALSE;
context_p->token.literal_is_reserved = false;
context_p->token.lit_location.type = LEXER_REGEXP_LITERAL;
context_p->lit_object.literal_p = literal_p;
@@ -1895,12 +1895,12 @@ lexer_expect_identifier (parser_context_t *context_p, /**< context */
static const lexer_lit_location_t lexer_get_literal =
{
(const uint8_t *) "get", 3, LEXER_IDENT_LITERAL, PARSER_FALSE
(const uint8_t *) "get", 3, LEXER_IDENT_LITERAL, false
};
static const lexer_lit_location_t lexer_set_literal =
{
(const uint8_t *) "set", 3, LEXER_IDENT_LITERAL, PARSER_FALSE
(const uint8_t *) "set", 3, LEXER_IDENT_LITERAL, false
};
/**
@@ -1908,7 +1908,7 @@ static const lexer_lit_location_t lexer_set_literal =
*/
void
lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
int must_be_identifier) /**< only identifiers are accepted */
bool must_be_identifier) /**< only identifiers are accepted */
{
skip_spaces (context_p);
@@ -1917,11 +1917,11 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
if (context_p->source_p < context_p->source_end_p)
{
int create_literal_object = PARSER_FALSE;
bool create_literal_object = false;
if (lit_char_is_identifier_start (context_p->source_p) || context_p->source_p[0] == LIT_CHAR_BACKSLASH)
{
lexer_parse_identifier (context_p, PARSER_FALSE);
lexer_parse_identifier (context_p, false);
if (!must_be_identifier
&& context_p->token.lit_location.length == 3)
@@ -1944,13 +1944,13 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
}
}
create_literal_object = PARSER_TRUE;
create_literal_object = true;
}
else if (context_p->source_p[0] == LIT_CHAR_DOUBLE_QUOTE
|| context_p->source_p[0] == LIT_CHAR_SINGLE_QUOTE)
{
lexer_parse_string (context_p);
create_literal_object = PARSER_TRUE;
create_literal_object = true;
}
else if (!must_be_identifier && context_p->source_p[0] == LIT_CHAR_RIGHT_BRACE)
{
@@ -1973,7 +1973,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
&& char_p[0] <= LIT_CHAR_9)
{
lexer_parse_number (context_p);
lexer_construct_number_object (context_p, PARSER_FALSE, PARSER_FALSE);
lexer_construct_number_object (context_p, false, false);
return;
}
}
@@ -1995,7 +1995,7 @@ lexer_expect_object_literal_id (parser_context_t *context_p, /**< context */
*/
void
lexer_scan_identifier (parser_context_t *context_p, /**< context */
int propety_name) /**< property name */
bool propety_name) /**< property name */
{
skip_spaces (context_p);
context_p->token.line = context_p->line;
@@ -2004,7 +2004,7 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
if (context_p->source_p < context_p->source_end_p
&& (lit_char_is_identifier_start (context_p->source_p) || context_p->source_p[0] == LIT_CHAR_BACKSLASH))
{
lexer_parse_identifier (context_p, PARSER_FALSE);
lexer_parse_identifier (context_p, false);
if (propety_name && context_p->token.lit_location.length == 3)
{
@@ -2044,9 +2044,9 @@ lexer_scan_identifier (parser_context_t *context_p, /**< context */
* Compares the given identifier to that which is the current token
* in the parser context.
*
* @return non-zero if the input identifiers are the same
* @return true if the input identifiers are the same
*/
int
bool
lexer_compare_identifier_to_current (parser_context_t *context_p, /**< context */
const lexer_lit_location_t *right) /**< identifier */
{
@@ -2081,7 +2081,7 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< co
{
if (*left_p++ != *right_p++)
{
return PARSER_FALSE;
return false;
}
count--;
continue;
@@ -2093,7 +2093,7 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< co
if (left_chr != lexer_hex_to_character (context_p, right_p, 6))
{
return PARSER_FALSE;
return false;
}
left_p += 6;
@@ -2120,7 +2120,7 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< co
{
if (utf8_buf[offset] != *right_p++)
{
return PARSER_FALSE;
return false;
}
offset++;
}
@@ -2130,7 +2130,7 @@ lexer_compare_identifier_to_current (parser_context_t *context_p, /**< co
}
while (count > 0);
return PARSER_TRUE;
return true;
} /* lexer_compare_identifier_to_current */
/**