Commit 9c8b4984 authored by Sergio Costas's avatar Sergio Costas

Now calculates better the line number

Added extra pattern
parent bbef76bb
......@@ -432,6 +432,10 @@ void find_close_parentheses(int init_counter) {
bool inside_quotes = false;
while ((counter != 0) && ((c = input()) != 0)) {
if (c == '\n') {
current_line++;
continue;
}
if (c == '\'') {
c = input();
if (c == '\\') {
......@@ -467,8 +471,11 @@ void find_close_parentheses(int init_counter) {
void comment(void) {
char c, prev = 0;
while ((c = input()) != 0) /* (EOF maps to 0) */
{
while ((c = input()) != 0) { /* (EOF maps to 0) */
if (c == '\n') {
current_line++;
continue;
}
if (c == '/' && prev == '*')
return;
prev = c;
......
......@@ -141,18 +141,31 @@ postfix_expression
show_debug(__LINE__, $$, "posftix_expression");
free_tree($2);
free_tree($4); }
| postfix_expression '.' IDENTIFIER { $$ = $1;show_debug(__LINE__, $$, "posftix_expression");
| postfix_expression '.' IDENTIFIER { $$ = $1; show_debug(__LINE__, $$, "posftix_expression");
append_right($$,$2);
$2->child1 = $3; }
| postfix_expression PTR_OP IDENTIFIER { $$ = $1;show_debug(__LINE__, $$, "posftix_expression");
| postfix_expression PTR_OP IDENTIFIER { $$ = $1; show_debug(__LINE__, $$, "posftix_expression");
append_right($$,$2);
$2->child1 = $3; }
| postfix_expression INC_OP { $$ = $2;show_debug(__LINE__, $$, "posftix_expression");
| postfix_expression INC_OP { $$ = $2; show_debug(__LINE__, $$, "posftix_expression");
$$->child1 = $1; }
| postfix_expression DEC_OP { $$ = $2;show_debug(__LINE__, $$, "posftix_expression");
| postfix_expression DEC_OP { $$ = $2; show_debug(__LINE__, $$, "posftix_expression");
$$->child1 = $1; }
| '(' type_name ')' '{' initializer_list '}' { $$ = $1; show_error(__LINE__, $$); }
| '(' type_name ')' '{' initializer_list ',' '}' { $$ = $1; show_error(__LINE__, $$); }
| '(' type_name ')' '{' initializer_list '}' { $$ = $5; show_debug(__LINE__, $$, "posftix_expression");
mix_ast_leaves($5, $2);
free_tree($1);
free_tree($2);
free_tree($3);
free_tree($4);
free_tree($6); }
| '(' type_name ')' '{' initializer_list ',' '}' { $$ = $5; show_debug(__LINE__, $$, "posftix_expression");
mix_ast_leaves($5, $2);
free_tree($1);
free_tree($2);
free_tree($3);
free_tree($4);
free_tree($6);
free_tree($7); }
;
argument_expression_list
......@@ -375,13 +388,11 @@ declaration_specifiers
// inline definition
free_tree($1); }
| T_TYPEOF '(' declaration_specifiers ')' { $$ = $3; show_debug(__LINE__, $$, "declaration_specifiers");
printf("Tipo 1 %s\n",$3->data);
free_tree($1);
free_tree($2);
free_tree($4); }
| T_TYPEOF '(' declaration_specifiers pointer ')' { $$ = $3; show_debug(__LINE__, $$, "declaration_specifiers");
$3->pointer += $4->pointer;
printf("Tipo 2 %s\n",$3->data);
free_tree($1);
free_tree($2);
free_tree($4);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment