Skip to content
This repository has been archived by the owner on Apr 1, 2024. It is now read-only.

Commit

Permalink
Fix glitches and stuff
Browse files Browse the repository at this point in the history
Summary:
- abstract elements are now allowed
- fix `element` keyword if no markup appears in the file
- allow <a\nhref="..." />; where \n is an actualy linebreak
- fix certain heredocs

Reviewed By: no one

Test Plan: master_include.php \ test cases from evan

Revert Plan: ok
  • Loading branch information
Marcel Laverdet committed Jun 25, 2009
1 parent 8985908 commit 04879fc
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 6 deletions.
9 changes: 8 additions & 1 deletion ext.cpp
Expand Up @@ -95,7 +95,14 @@ static zend_op_array* xhp_compile_file(zend_file_handle* f, int type TSRMLS_DC)
maybe_xhp = 1;
break;
}
} else if (*ii == '/' && ii[1] == '>') { // <a />
} else if (*ii == '/') { // <a />
if (ii[1] == '>') {
maybe_xhp = 1;
break;
}
} else if (*ii == 'e' && ii[1] == 'l' && ii[2] == 'e' && ii[3] == 'm' && ii[4] == 'e' && ii[5] == 'n' && ii[6] == 't') {
// } else if (memcmp(ii, "element", 7)) {
// why is this faster than memcmp? i'm bad at computers and i don't know.
maybe_xhp = 1;
break;
}
Expand Down
13 changes: 11 additions & 2 deletions xhp_parser.y
Expand Up @@ -971,8 +971,17 @@ xhp_whitespace_hack:

// element declarations
xhp_element_declaration:
t_ELEMENT { yy_push_state(PHP_NO_RESERVED_WORDS); } xhp_label xhp_whitespace_hack xhp_element_extends xhp_element_implements t_LCURLY class_statement_list t_RCURLY {
$$ = cr("class xhp_") + $3 + " " + $5 + " " + $6 + "{" + $8 + cr("}");
xhp_element_entry { yy_push_state(PHP_NO_RESERVED_WORDS); } xhp_label xhp_whitespace_hack xhp_element_extends xhp_element_implements t_LCURLY class_statement_list t_RCURLY {
$$ = $1 + $3 + " " + $5 + " " + $6 + "{" + $8 + cr("}");
}
;

xhp_element_entry:
t_ELEMENT {
$$ = cr("class xhp_");
}
| t_ABSTRACT t_ELEMENT {
$$ = cr("abstract class xhp_");
}
;

Expand Down
6 changes: 3 additions & 3 deletions xhp_scanner.l
Expand Up @@ -314,8 +314,8 @@ B b?
return tok(t_HEREDOC);
} else {
++yylloc->actual_line_offset;
yyextra->heredoc_data_last = yytext + yyleng;
yymore();
BEGIN(HEREDOC_DATA);
}
}
[^\r\n]+ {
Expand All @@ -324,8 +324,8 @@ B b?
}
{NEWLINE} {
++yylloc->actual_line_offset;
yyextra->heredoc_data_last = yytext + yyleng;
yymore();
BEGIN(HEREDOC_LINE_START);
}
}
<HEREDOC_DATA>{
Expand All @@ -348,7 +348,7 @@ B b?
">" return tok(t_XHP_GREATER_THAN);
}
<XHP_LABEL>{
" " {
{WHITESPACE} {
flex_pop_state(yyg);
return tok(t_XHP_WHITESPACE);
}
Expand Down

0 comments on commit 04879fc

Please sign in to comment.