Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Comment and String locations #52

Merged
merged 2 commits into from
Aug 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -924,30 +924,30 @@ YY_RULE_SETUP
{
BEGIN(INITIAL);
yylval->str = yyextra->str.c_str();
*yylloc = yyextra->loc;
return yy::GraphQLParserImpl::token::TOK_STRING;
}
YY_BREAK
case 2:
/* rule 2 can match eol */
YY_RULE_SETUP
#line 63 "lexer.lpp"
#line 64 "lexer.lpp"
{
throw make_error(yyextra->loc, "Unterminated string");
}
YY_BREAK
case YY_STATE_EOF(STRING_STATE):
#line 67 "lexer.lpp"
#line 68 "lexer.lpp"
{
throw make_error(yyextra->loc, "Unterminated string at EOF");
}
YY_BREAK
case 3:
YY_RULE_SETUP
#line 71 "lexer.lpp"
#line 72 "lexer.lpp"
{
char *p = yytext;
while (*p) {
yyextra->loc.columns();
yyextra->str.push_back(*p++);
}
}
Expand Down Expand Up @@ -1017,13 +1017,13 @@ case 15:
/* rule 15 can match eol */
YY_RULE_SETUP
#line 100 "lexer.lpp"
{ yyextra->loc.step(); BEGIN(INITIAL); }
{ yyextra->loc.lines(yyleng / 2); yyextra->loc.step(); BEGIN(INITIAL); }
YY_BREAK
case 16:
/* rule 16 can match eol */
YY_RULE_SETUP
#line 101 "lexer.lpp"
{ yyextra->loc.step(); BEGIN(INITIAL); }
{ yyextra->loc.lines(yyleng); yyextra->loc.step(); BEGIN(INITIAL); }
YY_BREAK
case 17:
YY_RULE_SETUP
Expand Down
6 changes: 3 additions & 3 deletions lexer.lpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ notnewline [^\n\r]
\" {
BEGIN(INITIAL);
yylval->str = yyextra->str.c_str();
*yylloc = yyextra->loc;
return yy::GraphQLParserImpl::token::TOK_STRING;
}

Expand All @@ -70,7 +71,6 @@ notnewline [^\n\r]
{STRINGCHAR}+ {
char *p = yytext;
while (*p) {
yyextra->loc.columns();
yyextra->str.push_back(*p++);
}
}
Expand All @@ -96,8 +96,8 @@ notnewline [^\n\r]
}

<LINE_COMMENT_STATE>{
{CRLF} { yyextra->loc.step(); BEGIN(INITIAL); }
{newline} { yyextra->loc.step(); BEGIN(INITIAL); }
{CRLF} { yyextra->loc.lines(yyleng / 2); yyextra->loc.step(); BEGIN(INITIAL); }
{newline} { yyextra->loc.lines(yyleng); yyextra->loc.step(); BEGIN(INITIAL); }
{notnewline}+ /* eat comment character */
}

Expand Down
2 changes: 1 addition & 1 deletion test/kitchen-sink.json

Large diffs are not rendered by default.

Loading