Skip to content

Commit 41c6d19

Browse files
authored
Merge pull request #52 from schloerke/location
Comment and String locations
2 parents 86550f2 + a418a88 commit 41c6d19

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

lexer.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -924,30 +924,30 @@ YY_RULE_SETUP
924924
{
925925
BEGIN(INITIAL);
926926
yylval->str = yyextra->str.c_str();
927+
*yylloc = yyextra->loc;
927928
return yy::GraphQLParserImpl::token::TOK_STRING;
928929
}
929930
YY_BREAK
930931
case 2:
931932
/* rule 2 can match eol */
932933
YY_RULE_SETUP
933-
#line 63 "lexer.lpp"
934+
#line 64 "lexer.lpp"
934935
{
935936
throw make_error(yyextra->loc, "Unterminated string");
936937
}
937938
YY_BREAK
938939
case YY_STATE_EOF(STRING_STATE):
939-
#line 67 "lexer.lpp"
940+
#line 68 "lexer.lpp"
940941
{
941942
throw make_error(yyextra->loc, "Unterminated string at EOF");
942943
}
943944
YY_BREAK
944945
case 3:
945946
YY_RULE_SETUP
946-
#line 71 "lexer.lpp"
947+
#line 72 "lexer.lpp"
947948
{
948949
char *p = yytext;
949950
while (*p) {
950-
yyextra->loc.columns();
951951
yyextra->str.push_back(*p++);
952952
}
953953
}
@@ -1017,13 +1017,13 @@ case 15:
10171017
/* rule 15 can match eol */
10181018
YY_RULE_SETUP
10191019
#line 100 "lexer.lpp"
1020-
{ yyextra->loc.step(); BEGIN(INITIAL); }
1020+
{ yyextra->loc.lines(yyleng / 2); yyextra->loc.step(); BEGIN(INITIAL); }
10211021
YY_BREAK
10221022
case 16:
10231023
/* rule 16 can match eol */
10241024
YY_RULE_SETUP
10251025
#line 101 "lexer.lpp"
1026-
{ yyextra->loc.step(); BEGIN(INITIAL); }
1026+
{ yyextra->loc.lines(yyleng); yyextra->loc.step(); BEGIN(INITIAL); }
10271027
YY_BREAK
10281028
case 17:
10291029
YY_RULE_SETUP

lexer.lpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@ notnewline [^\n\r]
5656
\" {
5757
BEGIN(INITIAL);
5858
yylval->str = yyextra->str.c_str();
59+
*yylloc = yyextra->loc;
5960
return yy::GraphQLParserImpl::token::TOK_STRING;
6061
}
6162

@@ -70,7 +71,6 @@ notnewline [^\n\r]
7071
{STRINGCHAR}+ {
7172
char *p = yytext;
7273
while (*p) {
73-
yyextra->loc.columns();
7474
yyextra->str.push_back(*p++);
7575
}
7676
}
@@ -96,8 +96,8 @@ notnewline [^\n\r]
9696
}
9797

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

test/kitchen-sink.json

Lines changed: 1 addition & 1 deletion
Large diffs are not rendered by default.

0 commit comments

Comments
 (0)