mirror of
https://github.com/jerryscript-project/jerryscript.git
synced 2025-12-15 16:29:21 +00:00
Fix warnings
This commit is contained in:
parent
74a0f470d2
commit
2d4b325d24
2
Makefile
2
Makefile
@ -27,7 +27,7 @@ UNITTESTS_SRC_DIR = ./tests/unit
|
||||
# Add common-io.c and sensors.c
|
||||
SOURCES = \
|
||||
$(sort \
|
||||
$(wildcard ./src/jerry-libc.c ./src/pretty-printer.c) \
|
||||
$(wildcard ./src/jerry-libc.c ./src/pretty-printer.c ./src/error.c) \
|
||||
$(wildcard ./src/libperipherals/actuators.c) \
|
||||
$(wildcard ./src/libjsparser/*.c) \
|
||||
$(wildcard ./src/libecmaobjects/*.c) \
|
||||
|
||||
11
src/error.h
11
src/error.h
@ -18,16 +18,9 @@
|
||||
|
||||
#include "mappings.h"
|
||||
|
||||
extern void lexer_dump_buffer_state ();
|
||||
extern void lexer_dump_buffer_state (void);
|
||||
|
||||
static inline void
|
||||
fatal (int code)
|
||||
{
|
||||
printf ("FATAL: %d\n", code);
|
||||
lexer_dump_buffer_state ();
|
||||
JERRY_UNREACHABLE ();
|
||||
exit (code);
|
||||
}
|
||||
void fatal (int);
|
||||
|
||||
#define ERR_IO (-1)
|
||||
#define ERR_BUFFER_SIZE (-2)
|
||||
|
||||
@ -46,7 +46,7 @@ gen_bytecode ()
|
||||
}
|
||||
|
||||
void
|
||||
init_int ()
|
||||
init_int (void)
|
||||
{
|
||||
#define INIT_OP_FUNC(name) __opfuncs[ name ] = opfunc_##name ;
|
||||
JERRY_STATIC_ASSERT (sizeof (OPCODE) <= 4);
|
||||
@ -55,7 +55,7 @@ init_int ()
|
||||
}
|
||||
|
||||
void
|
||||
run_int ()
|
||||
run_int (void)
|
||||
{
|
||||
init_int ();
|
||||
|
||||
|
||||
@ -38,6 +38,7 @@ struct __int_data
|
||||
};
|
||||
|
||||
void gen_bytecode (void);
|
||||
void init_int (void);
|
||||
void run_int (void);
|
||||
void run_int_from_pos (struct __int_data *);
|
||||
|
||||
|
||||
@ -102,10 +102,11 @@ static char *token_start;
|
||||
#define BUFFER_SIZE 1024
|
||||
|
||||
static char
|
||||
get_char (int i)
|
||||
get_char (size_t i)
|
||||
{
|
||||
int error;
|
||||
const int tail_size = BUFFER_SIZE - (buffer - buffer_start);
|
||||
size_t error;
|
||||
JERRY_ASSERT (buffer >= buffer_start);
|
||||
const size_t tail_size = BUFFER_SIZE - (size_t) (buffer - buffer_start);
|
||||
|
||||
JERRY_ASSERT (file);
|
||||
|
||||
@ -113,8 +114,6 @@ get_char (int i)
|
||||
{
|
||||
buffer = (char *) malloc (BUFFER_SIZE);
|
||||
error = fread (buffer, 1, BUFFER_SIZE, file);
|
||||
if (error < 0)
|
||||
fatal (ERR_IO);
|
||||
if (error == 0)
|
||||
return '\0';
|
||||
if (error < BUFFER_SIZE)
|
||||
@ -127,7 +126,8 @@ get_char (int i)
|
||||
/* We are almost at the end of the buffer. */
|
||||
if (token_start)
|
||||
{
|
||||
const int token_size = buffer - token_start;
|
||||
JERRY_ASSERT (buffer >= token_start);
|
||||
const size_t token_size = (size_t) (buffer - token_start);
|
||||
/* Whole buffer contains single token. */
|
||||
if (token_start == buffer_start)
|
||||
fatal (ERR_BUFFER_SIZE);
|
||||
@ -138,8 +138,6 @@ get_char (int i)
|
||||
buffer = buffer_start + token_size;
|
||||
/* Read more characters form input file. */
|
||||
error = fread (buffer + tail_size, 1, BUFFER_SIZE - tail_size - token_size, file);
|
||||
if (error < 0)
|
||||
fatal (ERR_IO);
|
||||
if (error == 0)
|
||||
return '\0';
|
||||
if (error < BUFFER_SIZE - tail_size - token_size)
|
||||
@ -151,8 +149,6 @@ get_char (int i)
|
||||
memmove (buffer_start, buffer, tail_size);
|
||||
buffer = buffer_start;
|
||||
error = fread (buffer + tail_size, 1, BUFFER_SIZE - tail_size, file);
|
||||
if (error < 0)
|
||||
fatal (ERR_IO);
|
||||
if (error == 0)
|
||||
return '\0';
|
||||
if (error < BUFFER_SIZE - tail_size)
|
||||
@ -179,7 +175,7 @@ static const char *token_start;
|
||||
if TOKEN represents a Future Reserved Word, return KW_RESERVED,
|
||||
otherwise return KW_NONE. */
|
||||
static token
|
||||
decode_keyword ()
|
||||
decode_keyword (void)
|
||||
{
|
||||
size_t size = sizeof (keyword_tokens) / sizeof (string_and_token);
|
||||
size_t i;
|
||||
@ -194,7 +190,7 @@ decode_keyword ()
|
||||
}
|
||||
|
||||
static token
|
||||
convert_seen_name_to_token ()
|
||||
convert_seen_name_to_token (void)
|
||||
{
|
||||
size_t i;
|
||||
|
||||
@ -216,25 +212,26 @@ add_to_seen_tokens (string_and_token snt)
|
||||
}
|
||||
|
||||
static inline void
|
||||
new_token ()
|
||||
new_token (void)
|
||||
{
|
||||
JERRY_ASSERT (buffer);
|
||||
token_start = buffer;
|
||||
}
|
||||
|
||||
static inline void
|
||||
consume_char ()
|
||||
static void
|
||||
consume_char (void)
|
||||
{
|
||||
JERRY_ASSERT (buffer);
|
||||
buffer++;
|
||||
}
|
||||
|
||||
static inline const char *
|
||||
current_token ()
|
||||
current_token (void)
|
||||
{
|
||||
JERRY_ASSERT (buffer);
|
||||
JERRY_ASSERT (token_start);
|
||||
int length = buffer - token_start;
|
||||
JERRY_ASSERT (token_start > buffer);
|
||||
size_t length = (size_t) (buffer - token_start);
|
||||
char *res = (char *) malloc (length + 1);
|
||||
strncpy (res, token_start, length);
|
||||
res[length] = '\0';
|
||||
@ -278,7 +275,7 @@ current_token ()
|
||||
while (0)
|
||||
|
||||
static token
|
||||
parse_name ()
|
||||
parse_name (void)
|
||||
{
|
||||
char c = LA (0);
|
||||
bool every_char_islower = islower (c);
|
||||
@ -360,13 +357,13 @@ hex_to_int (char hex)
|
||||
/* In this function we cannot use strtol function
|
||||
since there is no octal literals in ECMAscript. */
|
||||
static token
|
||||
parse_number ()
|
||||
parse_number (void)
|
||||
{
|
||||
char c = LA (0);
|
||||
bool is_hex = false;
|
||||
bool is_fp = false;
|
||||
bool is_exp = false;
|
||||
int tok_length = 0;
|
||||
size_t tok_length = 0, i;
|
||||
int res = 0;
|
||||
|
||||
JERRY_ASSERT (isdigit (c) || c == '.');
|
||||
@ -398,9 +395,9 @@ parse_number ()
|
||||
if (isalpha (c) || c == '_' || c == '$')
|
||||
fatal (ERR_INT_LITERAL);
|
||||
|
||||
tok_length = buffer - token_start;
|
||||
tok_length = (size_t) (buffer - token_start);
|
||||
// OK, I know that integer overflow can occur here
|
||||
for (int i = 0; i < tok_length; i++)
|
||||
for (i = 0; i < tok_length; i++)
|
||||
res = (res << 4) + hex_to_int (token_start[i]);
|
||||
|
||||
token_start = NULL;
|
||||
@ -459,8 +456,8 @@ parse_number ()
|
||||
return (token) { .type = TOK_FLOAT, .data.fp_num = res };
|
||||
}
|
||||
|
||||
tok_length = buffer - token_start;
|
||||
for (int i = 0; i < tok_length; i++)
|
||||
tok_length = (size_t) (buffer - token_start);;
|
||||
for (i = 0; i < tok_length; i++)
|
||||
res = res * 10 + hex_to_int (token_start[i]);
|
||||
|
||||
token_start = NULL;
|
||||
@ -487,13 +484,14 @@ escape_char (char c)
|
||||
}
|
||||
|
||||
static token
|
||||
parse_string ()
|
||||
parse_string (void)
|
||||
{
|
||||
char c = LA (0);
|
||||
bool is_double_quoted;
|
||||
char *tok = NULL;
|
||||
char *index = NULL;
|
||||
int length;
|
||||
const char *i;
|
||||
size_t length;
|
||||
token res = empty_token;
|
||||
|
||||
JERRY_ASSERT (c == '\'' || c == '"');
|
||||
@ -532,11 +530,11 @@ parse_string ()
|
||||
consume_char ();
|
||||
}
|
||||
|
||||
length = buffer - token_start;
|
||||
length = (size_t) (buffer - token_start);
|
||||
tok = (char *) malloc (length);
|
||||
index = tok;
|
||||
|
||||
for (const char *i = token_start; i < buffer; i++)
|
||||
for (i = token_start; i < buffer; i++)
|
||||
{
|
||||
if (*i == '\\')
|
||||
{
|
||||
@ -555,7 +553,7 @@ parse_string ()
|
||||
index++;
|
||||
}
|
||||
|
||||
memset (index, '\0', length - (index - tok));
|
||||
memset (index, '\0', length - (size_t) (index - tok));
|
||||
|
||||
token_start = NULL;
|
||||
// Eat up '"'
|
||||
@ -569,7 +567,7 @@ parse_string ()
|
||||
}
|
||||
|
||||
static void
|
||||
grobble_whitespaces ()
|
||||
grobble_whitespaces (void)
|
||||
{
|
||||
char c = LA (0);
|
||||
|
||||
@ -600,7 +598,7 @@ lexer_set_source (const char * source)
|
||||
#endif
|
||||
|
||||
static bool
|
||||
replace_comment_by_newline ()
|
||||
replace_comment_by_newline (void)
|
||||
{
|
||||
char c = LA (0);
|
||||
bool multiline;
|
||||
@ -636,11 +634,12 @@ replace_comment_by_newline ()
|
||||
}
|
||||
}
|
||||
|
||||
token
|
||||
#ifdef JERRY_NDEBUG
|
||||
lexer_next_token_private ()
|
||||
static token
|
||||
lexer_next_token_private (void)
|
||||
#else
|
||||
lexer_next_token ()
|
||||
token
|
||||
lexer_next_token (void)
|
||||
#endif
|
||||
{
|
||||
char c = LA (0);
|
||||
@ -776,7 +775,7 @@ lexer_next_token ()
|
||||
static int i = 0;
|
||||
|
||||
token
|
||||
lexer_next_token ()
|
||||
lexer_next_token (void)
|
||||
{
|
||||
token tok = lexer_next_token_private ();
|
||||
if (tok.type == TOK_NEWLINE)
|
||||
@ -802,7 +801,7 @@ lexer_save_token (token tok)
|
||||
}
|
||||
|
||||
void
|
||||
lexer_dump_buffer_state ()
|
||||
lexer_dump_buffer_state (void)
|
||||
{
|
||||
printf ("%s\n", buffer);
|
||||
}
|
||||
@ -156,7 +156,7 @@ void lexer_set_file (FILE *);
|
||||
#else
|
||||
void lexer_set_source (const char *);
|
||||
#endif
|
||||
token lexer_next_token ();
|
||||
token lexer_next_token (void);
|
||||
void lexer_save_token (token);
|
||||
|
||||
#endif
|
||||
@ -58,7 +58,7 @@ putchar (int c)
|
||||
static inline void
|
||||
exit (int status)
|
||||
{
|
||||
return __exit (status);
|
||||
__exit (status);
|
||||
}
|
||||
|
||||
static inline int
|
||||
|
||||
@ -17,33 +17,82 @@
|
||||
#include "error.h"
|
||||
#include "lexer.h"
|
||||
|
||||
bool
|
||||
is_formal_parameter_list_empty (formal_parameter_list list)
|
||||
{
|
||||
return list.names[0] == NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
is_operand_empty (operand op)
|
||||
{
|
||||
return op.is_literal == false && op.data.none == NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
is_operand_list_empty (operand_list list)
|
||||
{
|
||||
return is_operand_empty (list.ops[0]);
|
||||
}
|
||||
|
||||
bool
|
||||
is_property_empty (property prop)
|
||||
{
|
||||
return is_operand_empty (prop.name) && is_operand_empty (prop.value);
|
||||
}
|
||||
|
||||
bool
|
||||
is_property_list_empty (property_list list)
|
||||
{
|
||||
return is_property_empty (list.props[0]);
|
||||
}
|
||||
|
||||
bool
|
||||
is_expression_empty (assignment_expression expr)
|
||||
{
|
||||
return expr.oper == AO_NONE && expr.type == ET_NONE && expr.data.none == NULL;
|
||||
}
|
||||
|
||||
bool
|
||||
is_variable_declaration_empty (variable_declaration var_decl)
|
||||
{
|
||||
return var_decl.name == NULL && is_expression_empty (var_decl.assign_expr);
|
||||
}
|
||||
|
||||
bool
|
||||
is_statement_null (statement stmt)
|
||||
{
|
||||
return stmt.type == STMT_NULL && stmt.data.none == NULL;
|
||||
}
|
||||
|
||||
|
||||
static token tok;
|
||||
|
||||
#ifdef JERRY_NDEBUG
|
||||
FILE *debug_file;
|
||||
#endif
|
||||
|
||||
static expression parse_expression ();
|
||||
static assignment_expression parse_assigment_expression ();
|
||||
static expression parse_expression (void);
|
||||
static assignment_expression parse_assigment_expression (void);
|
||||
|
||||
typedef enum
|
||||
{
|
||||
SCOPE_GLOBAL = 0,
|
||||
SCOPE_IF = 1 << 0,
|
||||
SCOPE_BLOCK = 1 << 1,
|
||||
SCOPE_DO = 1 << 2,
|
||||
SCOPE_WHILE = 1 << 3,
|
||||
SCOPE_FOR = 1 << 4,
|
||||
SCOPE_IF = 1u << 0,
|
||||
SCOPE_BLOCK = 1u << 1,
|
||||
SCOPE_DO = 1u << 2,
|
||||
SCOPE_WHILE = 1u << 3,
|
||||
SCOPE_FOR = 1u << 4,
|
||||
SCOPE_LOOP = SCOPE_WHILE | SCOPE_FOR | SCOPE_DO,
|
||||
SCOPE_WITH = 1 << 5,
|
||||
SCOPE_SWITCH = 1 << 6,
|
||||
SCOPE_CASE = 1 << 7,
|
||||
SCOPE_ELSE = 1 << 8,
|
||||
SCOPE_TRY = 1 << 9,
|
||||
SCOPE_CATCH = 1 << 10,
|
||||
SCOPE_FINALLY = 1 << 11,
|
||||
SCOPE_FUNCTION = 1 << 12,
|
||||
SCOPE_SUBEXPRESSION = 1 << 13
|
||||
SCOPE_WITH = 1u << 5,
|
||||
SCOPE_SWITCH = 1u << 6,
|
||||
SCOPE_CASE = 1u << 7,
|
||||
SCOPE_ELSE = 1u << 8,
|
||||
SCOPE_TRY = 1u << 9,
|
||||
SCOPE_CATCH = 1u << 10,
|
||||
SCOPE_FINALLY = 1u << 11,
|
||||
SCOPE_FUNCTION = 1u << 12,
|
||||
SCOPE_SUBEXPRESSION = 1u << 13
|
||||
}
|
||||
scope_type;
|
||||
|
||||
@ -58,12 +107,12 @@ scope;
|
||||
|
||||
static scope current_scopes[MAX_SCOPES];
|
||||
|
||||
static int scope_index;
|
||||
static unsigned int scope_index;
|
||||
|
||||
static inline void
|
||||
scope_must_be (int scopes)
|
||||
static void
|
||||
scope_must_be (unsigned int scopes)
|
||||
{
|
||||
int i;
|
||||
size_t i;
|
||||
|
||||
for (i = 0; i < scope_index; i++)
|
||||
{
|
||||
@ -73,8 +122,8 @@ scope_must_be (int scopes)
|
||||
fatal (ERR_PARSER);
|
||||
}
|
||||
|
||||
static inline void
|
||||
current_scope_must_be (int scopes)
|
||||
static void
|
||||
current_scope_must_be (unsigned int scopes)
|
||||
{
|
||||
if (scopes & current_scopes[scope_index - 1].type)
|
||||
return;
|
||||
@ -82,7 +131,7 @@ current_scope_must_be (int scopes)
|
||||
}
|
||||
|
||||
static inline void
|
||||
current_scope_must_be_global ()
|
||||
current_scope_must_be_global (void)
|
||||
{
|
||||
if (scope_index != 0)
|
||||
fatal (ERR_PARSER);
|
||||
@ -98,7 +147,7 @@ push_scope (int type)
|
||||
}
|
||||
|
||||
static void
|
||||
pop_scope ()
|
||||
pop_scope (void)
|
||||
{
|
||||
#ifdef JERRY_NDEBUG
|
||||
fprintf (debug_file, "pop_scope: 0x%x\n", current_scopes[scope_index - 1].type);
|
||||
@ -106,7 +155,7 @@ pop_scope ()
|
||||
scope_index--;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static void
|
||||
assert_keyword (keyword kw)
|
||||
{
|
||||
if (tok.type != TOK_KEYWORD || tok.data.kw != kw)
|
||||
@ -118,13 +167,13 @@ assert_keyword (keyword kw)
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool
|
||||
static bool
|
||||
is_keyword (keyword kw)
|
||||
{
|
||||
return tok.type == TOK_KEYWORD && tok.data.kw == kw;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static void
|
||||
current_token_must_be(token_type tt)
|
||||
{
|
||||
if (tok.type != tt)
|
||||
@ -136,15 +185,15 @@ current_token_must_be(token_type tt)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
skip_newlines ()
|
||||
static void
|
||||
skip_newlines (void)
|
||||
{
|
||||
tok = lexer_next_token ();
|
||||
while (tok.type == TOK_NEWLINE)
|
||||
tok = lexer_next_token ();
|
||||
}
|
||||
|
||||
static inline void
|
||||
static void
|
||||
next_token_must_be (token_type tt)
|
||||
{
|
||||
tok = lexer_next_token ();
|
||||
@ -157,7 +206,7 @@ next_token_must_be (token_type tt)
|
||||
}
|
||||
}
|
||||
|
||||
static inline void
|
||||
static void
|
||||
token_after_newlines_must_be (token_type tt)
|
||||
{
|
||||
skip_newlines ();
|
||||
@ -173,8 +222,8 @@ token_after_newlines_must_be_keyword (keyword kw)
|
||||
fatal (ERR_PARSER);
|
||||
}
|
||||
|
||||
static inline void
|
||||
insert_semicolon ()
|
||||
static void
|
||||
insert_semicolon (void)
|
||||
{
|
||||
tok = lexer_next_token ();
|
||||
if (tok.type != TOK_NEWLINE && tok.type != TOK_SEMICOLON)
|
||||
@ -185,7 +234,7 @@ insert_semicolon ()
|
||||
: LT!* Identifier (LT!* ',' LT!* Identifier)*
|
||||
; */
|
||||
static formal_parameter_list
|
||||
parse_formal_parameter_list ()
|
||||
parse_formal_parameter_list (void)
|
||||
{
|
||||
int i;
|
||||
formal_parameter_list res;
|
||||
@ -217,7 +266,7 @@ parse_formal_parameter_list ()
|
||||
function_body
|
||||
: '{' LT!* sourceElements LT!* '}' */
|
||||
static function_declaration
|
||||
parse_function_declaration ()
|
||||
parse_function_declaration (void)
|
||||
{
|
||||
function_declaration res;
|
||||
|
||||
@ -244,7 +293,7 @@ parse_function_declaration ()
|
||||
: 'function' LT!* Identifier? LT!* '(' formal_parameter_list? LT!* ')' LT!* function_body
|
||||
; */
|
||||
static function_expression
|
||||
parse_function_expression ()
|
||||
parse_function_expression (void)
|
||||
{
|
||||
function_expression res;
|
||||
|
||||
@ -276,7 +325,7 @@ parse_function_expression ()
|
||||
}
|
||||
|
||||
static literal
|
||||
parse_literal ()
|
||||
parse_literal (void)
|
||||
{
|
||||
literal res;
|
||||
|
||||
@ -308,7 +357,7 @@ parse_literal ()
|
||||
}
|
||||
|
||||
static operand
|
||||
parse_operand ()
|
||||
parse_operand (void)
|
||||
{
|
||||
operand res;
|
||||
|
||||
@ -336,7 +385,7 @@ parse_operand ()
|
||||
: operand LT!* ( ',' LT!* operand * LT!* )*
|
||||
;*/
|
||||
static argument_list
|
||||
parse_argument_list ()
|
||||
parse_argument_list (void)
|
||||
{
|
||||
argument_list res;
|
||||
int i;
|
||||
@ -364,7 +413,7 @@ parse_argument_list ()
|
||||
: identifier LT!* '(' LT!* arguments * LT!* ')' LT!*
|
||||
;*/
|
||||
static call_expression
|
||||
parse_call_expression ()
|
||||
parse_call_expression (void)
|
||||
{
|
||||
call_expression res;
|
||||
|
||||
@ -396,7 +445,7 @@ parse_call_expression ()
|
||||
: [ arguments ]
|
||||
; */
|
||||
static array_literal
|
||||
parse_array_literal ()
|
||||
parse_array_literal (void)
|
||||
{
|
||||
array_literal res;
|
||||
|
||||
@ -420,7 +469,7 @@ parse_array_literal ()
|
||||
| NumericLiteral
|
||||
; */
|
||||
static inline property_name
|
||||
parse_property_name ()
|
||||
parse_property_name (void)
|
||||
{
|
||||
switch (tok.type)
|
||||
{
|
||||
@ -438,7 +487,7 @@ parse_property_name ()
|
||||
: property_name LT!* ':' LT!* operand
|
||||
; */
|
||||
static property
|
||||
parse_property ()
|
||||
parse_property (void)
|
||||
{
|
||||
property res;
|
||||
|
||||
@ -455,7 +504,7 @@ parse_property ()
|
||||
: LT!* property (LT!* ',' LT!* property)* LT!*
|
||||
; */
|
||||
static object_literal
|
||||
parse_object_literal ()
|
||||
parse_object_literal (void)
|
||||
{
|
||||
object_literal res;
|
||||
int i;
|
||||
@ -488,7 +537,7 @@ parse_unary_expression (assignment_expression *res, expression_type type)
|
||||
}
|
||||
|
||||
static assignment_expression
|
||||
parse_assigment_expression ()
|
||||
parse_assigment_expression (void)
|
||||
{
|
||||
assignment_expression res;
|
||||
|
||||
@ -780,7 +829,7 @@ parse_operator:
|
||||
;
|
||||
*/
|
||||
static expression
|
||||
parse_expression ()
|
||||
parse_expression (void)
|
||||
{
|
||||
expression res;
|
||||
int i;
|
||||
@ -808,7 +857,7 @@ parse_expression ()
|
||||
: '=' LT!* assignment_expression
|
||||
; */
|
||||
static variable_declaration
|
||||
parse_variable_declaration ()
|
||||
parse_variable_declaration (void)
|
||||
{
|
||||
variable_declaration res;
|
||||
|
||||
@ -835,7 +884,7 @@ parse_variable_declaration ()
|
||||
(LT!* ',' LT!* variable_declaration(_no_in))*
|
||||
; */
|
||||
static variable_declaration_list
|
||||
parse_variable_declaration_list ()
|
||||
parse_variable_declaration_list (void)
|
||||
{
|
||||
variable_declaration_list res;
|
||||
int i;
|
||||
@ -877,7 +926,7 @@ parse_variable_declaration_list ()
|
||||
;*/
|
||||
|
||||
static for_or_for_in_statement
|
||||
parse_for_or_for_in_statement ()
|
||||
parse_for_or_for_in_statement (void)
|
||||
{
|
||||
for_or_for_in_statement res;
|
||||
variable_declaration_list list;
|
||||
@ -985,7 +1034,7 @@ for_in:
|
||||
return res;
|
||||
}
|
||||
|
||||
static inline void
|
||||
static void
|
||||
parse_expression_inside_parens (statement *res)
|
||||
{
|
||||
token_after_newlines_must_be (TOK_OPEN_PAREN);
|
||||
@ -1058,7 +1107,7 @@ parse_expression_inside_parens (statement *res)
|
||||
: 'try' LT!* '{' LT!* statement_list LT!* '}' LT!* (finally_clause | catch_clause (LT!* finally_clause)?)
|
||||
;*/
|
||||
statement
|
||||
parser_parse_statement ()
|
||||
parser_parse_statement (void)
|
||||
{
|
||||
statement res;
|
||||
res.data.none = NULL;
|
||||
@ -1168,7 +1217,7 @@ parser_parse_statement ()
|
||||
res.type = STMT_VARIABLE;
|
||||
|
||||
skip_newlines ();
|
||||
res.data.var_stmt = parse_variable_declaration_list (true);
|
||||
res.data.var_stmt = parse_variable_declaration_list ();
|
||||
return res;
|
||||
}
|
||||
if (tok.type == TOK_SEMICOLON)
|
||||
@ -1231,7 +1280,7 @@ parser_parse_statement ()
|
||||
tok = lexer_next_token ();
|
||||
if (tok.type != TOK_SEMICOLON && tok.type != TOK_NEWLINE)
|
||||
{
|
||||
int current_scope_index = scope_index;
|
||||
unsigned int current_scope_index = scope_index;
|
||||
res.data.expr = parse_expression ();
|
||||
if (current_scope_index == scope_index)
|
||||
insert_semicolon ();
|
||||
@ -1323,7 +1372,7 @@ parser_parse_statement ()
|
||||
}
|
||||
|
||||
void
|
||||
parser_init ()
|
||||
parser_init (void)
|
||||
{
|
||||
scope_index = 0;
|
||||
#ifdef JERRY_NDEBUG
|
||||
|
||||
@ -44,11 +44,7 @@ empty_formal_parameter_list =
|
||||
.names = { [0] = NULL }
|
||||
};
|
||||
|
||||
static inline bool
|
||||
is_formal_parameter_list_empty (formal_parameter_list list)
|
||||
{
|
||||
return list.names[0] == NULL;
|
||||
}
|
||||
bool is_formal_parameter_list_empty (formal_parameter_list);
|
||||
|
||||
/** @function_declaration represents both declaration and expression of a function.
|
||||
After this parser must return a block of statements. */
|
||||
@ -119,11 +115,7 @@ empty_operand =
|
||||
.data.none = NULL
|
||||
};
|
||||
|
||||
static inline bool
|
||||
is_operand_empty (operand op)
|
||||
{
|
||||
return op.is_literal == false && op.data.none == NULL;
|
||||
}
|
||||
bool is_operand_empty (operand);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -143,11 +135,7 @@ empty_operand_list =
|
||||
.ops = { [0] = { .is_literal = false, .data.none = NULL } }
|
||||
};
|
||||
|
||||
static inline bool
|
||||
is_operand_list_empty (operand_list list)
|
||||
{
|
||||
return is_operand_empty (list.ops[0]);
|
||||
}
|
||||
bool is_operand_list_empty (operand_list);
|
||||
|
||||
typedef operand_list array_literal;
|
||||
typedef operand_list argument_list;
|
||||
@ -175,11 +163,7 @@ static const property empty_property =
|
||||
.value = { .is_literal = false, .data.none = NULL }
|
||||
};
|
||||
|
||||
static inline bool
|
||||
is_property_empty (property prop)
|
||||
{
|
||||
return is_operand_empty (prop.name) && is_operand_empty (prop.value);
|
||||
}
|
||||
bool is_property_empty (property);
|
||||
|
||||
/** List of properties. Represents ObjectLiteral. */
|
||||
typedef struct
|
||||
@ -200,11 +184,7 @@ empty_property_list =
|
||||
{ .is_literal = false, .data.none = NULL }}}
|
||||
};
|
||||
|
||||
static inline bool
|
||||
is_property_list_empty (property_list list)
|
||||
{
|
||||
return is_property_empty (list.props[0]);
|
||||
}
|
||||
bool is_property_list_empty (property_list);
|
||||
|
||||
typedef property_list object_literal;
|
||||
|
||||
@ -305,11 +285,7 @@ empty_expression =
|
||||
.data.none = NULL
|
||||
};
|
||||
|
||||
static inline bool
|
||||
is_expression_empty (assignment_expression expr)
|
||||
{
|
||||
return expr.oper == AO_NONE && expr.type == ET_NONE && expr.data.none == NULL;
|
||||
}
|
||||
bool is_expression_empty (assignment_expression);
|
||||
|
||||
/** Represents expression, array literal and list of argument. */
|
||||
typedef struct
|
||||
@ -338,11 +314,7 @@ empty_variable_declaration =
|
||||
.assign_expr = { .oper = AO_NONE, .type = ET_NONE, .data.none = NULL }
|
||||
};
|
||||
|
||||
static inline bool
|
||||
is_variable_declaration_empty (variable_declaration var_decl)
|
||||
{
|
||||
return var_decl.name == NULL && is_expression_empty (var_decl.assign_expr);
|
||||
}
|
||||
bool is_variable_declaration_empty (variable_declaration);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
@ -461,13 +433,9 @@ null_statement =
|
||||
.data.none = NULL
|
||||
};
|
||||
|
||||
static inline bool
|
||||
is_statement_null (statement stmt)
|
||||
{
|
||||
return stmt.type == STMT_NULL && stmt.data.none == NULL;
|
||||
}
|
||||
bool is_statement_null (statement);
|
||||
|
||||
void parser_init ();
|
||||
statement parser_parse_statement ();
|
||||
void parser_init (void);
|
||||
statement parser_parse_statement (void);
|
||||
|
||||
#endif
|
||||
|
||||
@ -28,7 +28,7 @@
|
||||
|
||||
#include "generated.h"
|
||||
|
||||
void fake_exit ();
|
||||
void fake_exit (void);
|
||||
|
||||
void
|
||||
fake_exit (void)
|
||||
|
||||
@ -23,7 +23,7 @@ static bool was_subexpression;
|
||||
static statement_type prev_stmt;
|
||||
|
||||
void
|
||||
pp_reset ()
|
||||
pp_reset (void)
|
||||
{
|
||||
prev_stmt = STMT_EOF;
|
||||
intendation = 0;
|
||||
@ -404,7 +404,7 @@ pp_keyword (keyword kw)
|
||||
}
|
||||
|
||||
static void
|
||||
intend ()
|
||||
intend (void)
|
||||
{
|
||||
for (int i = 0; i < intendation; i++)
|
||||
putchar (' ');
|
||||
@ -1087,7 +1087,7 @@ pp_statement (statement stmt)
|
||||
prev_stmt = stmt.type;
|
||||
}
|
||||
|
||||
void pp_finish ()
|
||||
void pp_finish (void)
|
||||
{
|
||||
if (prev_stmt == STMT_BLOCK_END)
|
||||
putchar ('\n');
|
||||
|
||||
@ -19,8 +19,8 @@
|
||||
#include "lexer.h"
|
||||
#include "parser.h"
|
||||
|
||||
void pp_reset ();
|
||||
void pp_finish ();
|
||||
void pp_reset (void);
|
||||
void pp_finish (void);
|
||||
void pp_token (token);
|
||||
void pp_keyword (keyword);
|
||||
void pp_statement (statement);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user