Skip to content

Commit

Permalink
Merge pull request #52 from schloerke/location
Browse files Browse the repository at this point in the history
Comment and String locations
  • Loading branch information
swolchok authored Aug 25, 2017
2 parents 86550f2 + a418a88 commit 41c6d19
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
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

0 comments on commit 41c6d19

Please sign in to comment.