~kameliya/rubyex

bafa136622ec3276a81f4d8f0f9ed565e134fd7c — Yuki Izumi 12 years ago 322ed18
adding <<-here style her edocuments
1 files changed, 9 insertions(+), 2 deletions(-)

M parser/ruby.l
M parser/ruby.l => parser/ruby.l +9 -2
@@ 19,6 19,7 @@
%{
  std::string string_buf, here_doc;
  bool doing_symbol = false;
  bool hyphen_here = false;

  typedef struct {
    const char *identifier;


@@ 285,9 286,15 @@ end			{
\|\|		{ return LOGICAL_OR; }
\*\*		{ return EXP; }

\<\<[a-zA-Z_0-9]+$	{ yy_push_state(here_document); here_doc = yytext + 2; string_buf = ""; }
\<\<[a-zA-Z_0-9]+$	{ yy_push_state(here_document); here_doc = yytext + 2; string_buf = ""; hyphen_here = false; }
\<\<-[a-zA-Z_0-9]+$	{ yy_push_state(here_document); here_doc = yytext + 3; string_buf = ""; hyphen_here = true; }
<here_document>^.+$		{
			  if (yytext == here_doc) {
			  const char *yytext_check = yytext;
			  if (hyphen_here) 
			    while (*yytext_check == ' ' || *yytext_check == '\t')
			      ++yytext_check;

			  if (yytext_check == here_doc) {
			    yy_pop_state();
			    yylval.string_literal = new StringLiteralExpr(string_buf);
			    return STRING_LITERAL;