Add missing #line hint for strings

This commit is contained in:
nikic 2011-06-28 14:16:10 +02:00
parent f756d82cd4
commit 033f5c81a0
6 changed files with 50 additions and 46 deletions

View File

@ -520,8 +520,8 @@ state 5
. error
state 6
(24) inner_statement_list : inner_statement_list . inner_statement
(97) while_statement : ':' inner_statement_list . T_ENDWHILE ';'
(24) inner_statement_list : inner_statement_list . inner_statement
T_INCLUDE shift 56
T_INCLUDE_ONCE shift 57
@ -924,8 +924,8 @@ state 9
. error
state 10
(24) inner_statement_list : inner_statement_list . inner_statement
(233) expr : T_FUNCTION optional_ref '(' parameter_list ')' lexical_vars '{' inner_statement_list . '}'
(24) inner_statement_list : inner_statement_list . inner_statement
T_INCLUDE shift 56
T_INCLUDE_ONCE shift 57
@ -1227,8 +1227,8 @@ state 12
. error
state 13
(24) inner_statement_list : inner_statement_list . inner_statement
(136) method_body : '{' inner_statement_list . '}'
(24) inner_statement_list : inner_statement_list . inner_statement
T_INCLUDE shift 56
T_INCLUDE_ONCE shift 57
@ -1530,8 +1530,8 @@ state 15
. reduce (93)
state 16
(24) inner_statement_list : inner_statement_list . inner_statement
(105) new_else_single : T_ELSE ':' inner_statement_list .
(24) inner_statement_list : inner_statement_list . inner_statement
T_INCLUDE shift 56
T_INCLUDE_ONCE shift 57
@ -1730,8 +1730,8 @@ state 17
. reduce (92)
state 18
(24) inner_statement_list : inner_statement_list . inner_statement
(101) new_elseif_list : new_elseif_list T_ELSEIF '(' expr ')' ':' inner_statement_list .
(24) inner_statement_list : inner_statement_list . inner_statement
T_INCLUDE shift 56
T_INCLUDE_ONCE shift 57
@ -10246,7 +10246,6 @@ state 134
. error
state 135
(92) case_list : case_list T_CASE expr . case_separator inner_statement_list
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10274,6 +10273,7 @@ state 135
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(92) case_list : case_list T_CASE expr . case_separator inner_statement_list
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10307,7 +10307,6 @@ state 135
. error
state 136
(47) statement : expr . ';'
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10335,6 +10334,7 @@ state 136
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(47) statement : expr . ';'
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10366,7 +10366,6 @@ state 136
. error
state 137
(38) statement : T_BREAK expr . ';'
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10394,6 +10393,7 @@ state 137
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(38) statement : T_BREAK expr . ';'
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10425,7 +10425,6 @@ state 137
. error
state 138
(40) statement : T_CONTINUE expr . ';'
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10453,6 +10452,7 @@ state 138
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(40) statement : T_CONTINUE expr . ';'
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10484,7 +10484,6 @@ state 138
. error
state 139
(42) statement : T_RETURN expr . ';'
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10512,6 +10511,7 @@ state 139
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(42) statement : T_RETURN expr . ';'
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10543,7 +10543,6 @@ state 139
. error
state 140
(55) statement : T_THROW expr . ';'
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10571,6 +10570,7 @@ state 140
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(55) statement : T_THROW expr . ';'
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10779,8 +10779,6 @@ state 143
. error
state 144
(31) statement : T_IF '(' expr . ')' statement elseif_list else_single
(32) statement : T_IF '(' expr . ')' ':' inner_statement_list new_elseif_list new_else_single T_ENDIF ';'
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10808,6 +10806,8 @@ state 144
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(31) statement : T_IF '(' expr . ')' statement elseif_list else_single
(32) statement : T_IF '(' expr . ')' ':' inner_statement_list new_elseif_list new_else_single T_ENDIF ';'
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10839,7 +10839,6 @@ state 144
. error
state 145
(33) statement : T_WHILE '(' expr . ')' while_statement
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10867,6 +10866,7 @@ state 145
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(33) statement : T_WHILE '(' expr . ')' while_statement
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10898,9 +10898,6 @@ state 145
. error
state 146
(49) statement : T_FOREACH '(' expr . T_AS variable ')' foreach_statement
(50) statement : T_FOREACH '(' expr . T_AS '&' variable ')' foreach_statement
(51) statement : T_FOREACH '(' expr . T_AS variable T_DOUBLE_ARROW optional_ref variable ')' foreach_statement
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10928,6 +10925,9 @@ state 146
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(49) statement : T_FOREACH '(' expr . T_AS variable ')' foreach_statement
(50) statement : T_FOREACH '(' expr . T_AS '&' variable ')' foreach_statement
(51) statement : T_FOREACH '(' expr . T_AS variable T_DOUBLE_ARROW optional_ref variable ')' foreach_statement
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -10959,7 +10959,6 @@ state 146
. error
state 147
(36) statement : T_SWITCH '(' expr . ')' switch_case_list
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -10987,6 +10986,7 @@ state 147
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(36) statement : T_SWITCH '(' expr . ')' switch_case_list
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -11610,7 +11610,6 @@ state 157
. error
state 158
(34) statement : T_DO statement T_WHILE '(' expr . ')' ';'
(181) expr : expr . T_BOOLEAN_OR expr
(182) expr : expr . T_BOOLEAN_AND expr
(183) expr : expr . T_LOGICAL_OR expr
@ -11638,6 +11637,7 @@ state 158
(209) expr : expr . T_INSTANCEOF class_name_reference
(211) expr : expr . '?' expr ':' expr
(212) expr : expr . '?' ':' expr
(34) statement : T_DO statement T_WHILE '(' expr . ')' ';'
T_LOGICAL_OR shift 83
T_LOGICAL_XOR shift 84
@ -14905,8 +14905,8 @@ state 226
. reduce (208)
state 227
(67) class_declaration_statement : T_INTERFACE T_STRING interface_extends_list '{' class_statement_list . '}'
(130) class_statement_list : class_statement_list . class_statement
(67) class_declaration_statement : T_INTERFACE T_STRING interface_extends_list '{' class_statement_list . '}'
(139) method_modifiers : .
T_CONST shift 477
@ -14927,8 +14927,8 @@ state 227
. reduce (139)
state 228
(66) class_declaration_statement : class_entry_type T_STRING extends_from implements_list '{' class_statement_list . '}'
(130) class_statement_list : class_statement_list . class_statement
(66) class_declaration_statement : class_entry_type T_STRING extends_from implements_list '{' class_statement_list . '}'
(139) method_modifiers : .
T_CONST shift 477
@ -15972,10 +15972,10 @@ state 277
. error
state 278
(246) name : T_NAMESPACE . T_NS_SEPARATOR namespace_name
(11) top_statement : T_NAMESPACE . namespace_name ';'
(12) top_statement : T_NAMESPACE . namespace_name '{' top_statement_list '}'
(13) top_statement : T_NAMESPACE . '{' top_statement_list '}'
(246) name : T_NAMESPACE . T_NS_SEPARATOR namespace_name
T_STRING shift 563 and reduce (5)
T_NS_SEPARATOR shift 340
@ -16164,10 +16164,10 @@ state 294
. error
state 295
(49) statement : T_FOREACH '(' expr T_AS variable . ')' foreach_statement
(51) statement : T_FOREACH '(' expr T_AS variable . T_DOUBLE_ARROW optional_ref variable ')' foreach_statement
(302) object_access : variable . T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
(303) object_access_arrayable : variable . T_OBJECT_OPERATOR object_property
(49) statement : T_FOREACH '(' expr T_AS variable . ')' foreach_statement
(51) statement : T_FOREACH '(' expr T_AS variable . T_DOUBLE_ARROW optional_ref variable ')' foreach_statement
T_OBJECT_OPERATOR shift 264
T_DOUBLE_ARROW shift 359
@ -16263,8 +16263,8 @@ state 304
state 305
305: shift/reduce conflict (shift 27, reduce 102) on T_ELSE
305: shift/reduce conflict (shift 483, reduce 102) on T_ELSEIF
(31) statement : T_IF '(' expr ')' statement elseif_list . else_single
(99) elseif_list : elseif_list . T_ELSEIF '(' expr ')' statement
(31) statement : T_IF '(' expr ')' statement elseif_list . else_single
(102) else_single : .
T_ELSEIF shift 483
@ -16273,8 +16273,8 @@ state 305
. reduce (102)
state 306
(32) statement : T_IF '(' expr ')' ':' inner_statement_list new_elseif_list . new_else_single T_ENDIF ';'
(101) new_elseif_list : new_elseif_list . T_ELSEIF '(' expr ')' ':' inner_statement_list
(32) statement : T_IF '(' expr ')' ':' inner_statement_list new_elseif_list . new_else_single T_ENDIF ';'
(104) new_else_single : .
T_ELSEIF shift 493
@ -16325,16 +16325,16 @@ state 311
. reduce (311)
state 312
(45) statement : T_ECHO expr_list . ';'
(155) expr_list : expr_list . ',' expr
(45) statement : T_ECHO expr_list . ';'
',' shift 122
';' shift 600 and reduce (45)
. error
state 313
(65) function_declaration_statement : T_FUNCTION optional_ref . T_STRING '(' parameter_list ')' '{' inner_statement_list '}'
(233) expr : T_FUNCTION optional_ref . '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
(65) function_declaration_statement : T_FUNCTION optional_ref . T_STRING '(' parameter_list ')' '{' inner_statement_list '}'
T_STRING shift 411
'(' shift 256
@ -16349,17 +16349,17 @@ state 314
. error
state 315
(43) statement : T_GLOBAL global_var_list . ';'
(121) global_var_list : global_var_list . ',' global_var
(43) statement : T_GLOBAL global_var_list . ';'
',' shift 303
';' shift 607 and reduce (43)
. error
state 316
(44) statement : T_STATIC static_var_list . ';'
(126) static_var_list : static_var_list . ',' T_VARIABLE
(127) static_var_list : static_var_list . ',' T_VARIABLE '=' static_scalar
(44) statement : T_STATIC static_var_list . ';'
',' shift 415
';' shift 608 and reduce (44)
@ -16428,8 +16428,8 @@ state 323
. error
state 324
(62) variables_list : variables_list . ',' variable
(213) expr : T_ISSET '(' variables_list . ')'
(62) variables_list : variables_list . ',' variable
',' shift 246
')' shift 644 and reduce (213)
@ -16507,9 +16507,9 @@ state 332
. error
state 333
(50) statement : T_FOREACH '(' expr T_AS '&' variable . ')' foreach_statement
(302) object_access : variable . T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
(303) object_access_arrayable : variable . T_OBJECT_OPERATOR object_property
(50) statement : T_FOREACH '(' expr T_AS '&' variable . ')' foreach_statement
T_OBJECT_OPERATOR shift 264
')' shift 22
@ -16533,9 +16533,9 @@ state 335
. error
state 336
(51) statement : T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW optional_ref variable . ')' foreach_statement
(302) object_access : variable . T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
(303) object_access_arrayable : variable . T_OBJECT_OPERATOR object_property
(51) statement : T_FOREACH '(' expr T_AS variable T_DOUBLE_ARROW optional_ref variable . ')' foreach_statement
T_OBJECT_OPERATOR shift 264
')' shift 24
@ -16600,8 +16600,8 @@ state 343
. reduce (257)
state 344
(65) function_declaration_statement : T_FUNCTION . optional_ref T_STRING '(' parameter_list ')' '{' inner_statement_list '}'
(233) expr : T_FUNCTION . optional_ref '(' parameter_list ')' lexical_vars '{' inner_statement_list '}'
(65) function_declaration_statement : T_FUNCTION . optional_ref T_STRING '(' parameter_list ')' '{' inner_statement_list '}'
(63) optional_ref : .
'&' shift 584 and reduce (64)
@ -16609,8 +16609,8 @@ state 344
. reduce (63)
state 345
(44) statement : T_STATIC . static_var_list ';'
(243) class_name : T_STATIC .
(44) statement : T_STATIC . static_var_list ';'
T_VARIABLE shift 401
static_var_list goto 316
@ -17139,9 +17139,9 @@ state 415
. error
state 416
(61) variables_list : variable .
(302) object_access : variable . T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
(303) object_access_arrayable : variable . T_OBJECT_OPERATOR object_property
(61) variables_list : variable .
T_OBJECT_OPERATOR shift 264
. reduce (61)
@ -17537,9 +17537,9 @@ state 464
. error
state 465
(62) variables_list : variables_list ',' variable .
(302) object_access : variable . T_OBJECT_OPERATOR object_property '(' function_call_argument_list ')'
(303) object_access_arrayable : variable . T_OBJECT_OPERATOR object_property
(62) variables_list : variables_list ',' variable .
T_OBJECT_OPERATOR shift 264
. reduce (62)

View File

@ -613,7 +613,7 @@ ctor_arguments:
common_scalar:
T_LNUMBER { $$ = new PHPParser_Node_Scalar_LNumber(array('value' => (int) $1), #line); }
| T_DNUMBER { $$ = new PHPParser_Node_Scalar_DNumber(array('value' => (double) $1), #line); }
| T_CONSTANT_ENCAPSED_STRING { $$ = PHPParser_Node_Scalar_String::create($1); }
| T_CONSTANT_ENCAPSED_STRING { $$ = PHPParser_Node_Scalar_String::create($1, #line); }
| T_LINE { $$ = new PHPParser_Node_Scalar_LineConst(array(), #line); }
| T_FILE { $$ = new PHPParser_Node_Scalar_FileConst(array(), #line); }
| T_DIR { $$ = new PHPParser_Node_Scalar_DirConst(array(), #line); }

View File

@ -613,7 +613,7 @@ ctor_arguments:
common_scalar:
T_LNUMBER { $$ = Scalar_LNumber[value: parseLNumber($1)]; }
| T_DNUMBER { $$ = Scalar_DNumber[value: parseDNumber($1)]; }
| T_CONSTANT_ENCAPSED_STRING { $$ = Scalar_String::create($1); }
| T_CONSTANT_ENCAPSED_STRING { $$ = Scalar_String::create($1, #line); }
| T_LINE { $$ = Scalar_LineConst[]; }
| T_FILE { $$ = Scalar_FileConst[]; }
| T_DIR { $$ = Scalar_DirConst[]; }

View File

@ -13,11 +13,12 @@ class PHPParser_Node_Scalar_String extends PHPParser_Node_Scalar
/**
* Creates a String node from a string token (parses escape sequences).
*
* @param string $s String
* @param string $s String
* @param int $line Line
*
* @return PHPParser_Node_Scalar_String String Node
*/
public static function create($s) {
public static function create($s, $line) {
$isBinary = false;
if ('b' === $s[0]) {
$isBinary = true;
@ -37,9 +38,12 @@ class PHPParser_Node_Scalar_String extends PHPParser_Node_Scalar
$s = self::parseEscapeSequences(substr($s, $isBinary + 1, -1));
}
return new self(array(
'value' => $s, 'isBinary' => $isBinary, 'type' => $type
));
return new self(
array(
'value' => $s, 'isBinary' => $isBinary, 'type' => $type
),
$line
);
}
/**

View File

@ -2075,7 +2075,7 @@ class PHPParser_Parser
}
private function yyn267($line) {
$this->yyval = PHPParser_Node_Scalar_String::create($this->yyastk[$this->yysp-(1-1)]);
$this->yyval = PHPParser_Node_Scalar_String::create($this->yyastk[$this->yysp-(1-1)], $line);
}
private function yyn268($line) {

View File

@ -2474,7 +2474,7 @@ class PHPParser_ParserDebug
}
private function yyn267($line) {
$this->yyval = PHPParser_Node_Scalar_String::create($this->yyastk[$this->yysp-(1-1)]);
$this->yyval = PHPParser_Node_Scalar_String::create($this->yyastk[$this->yysp-(1-1)], $line);
}
private function yyn268($line) {