graphql-c_parser 1.1.0 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e8584a3c42587debe82aa29273fef1dffd1e3624c3d03368b37cbd36dbe8e290
4
- data.tar.gz: 6775ad51cb2544d67b9bf8e0460d6decc1b14034db4cb8148653ae6835987a41
3
+ metadata.gz: 9ce3db30ea33e3358c671556d5a3d4d8338e578da71948bd0dcd924a24b8fa23
4
+ data.tar.gz: d80041b89bdadc5a83a60e352a68b4ace5b18de7eb34dabec09a6f180d13989d
5
5
  SHA512:
6
- metadata.gz: 33036841a9ef8f1c44fb297781272d2645428eb6d1252582692af832704ad8a8e861cecbc081829be2a15d4271045876c524331978f14608436594cf34c99377
7
- data.tar.gz: f46a068023df63a03c2b970e05c8e14784d9686de2147f1b4dbf2b866271093dbb6b4e9d019fed62c2854deffc27df24071fcfc93a3fde5563967323220584c3
6
+ metadata.gz: 7f85e41f5361db1ca4d9025ea239069127b3535c20ac2f2afde1c79a89b019bf953a221eafe65739d2ebd9bf8f479aa37ab3ef520d1e3df0c30c0401291a0e92
7
+ data.tar.gz: c1f171a7ca8f49304a58e4b0fb4acab15ce51e9f51c39ff5817df31e385478488e87a854915cc666bc672b5741d6ecaf9916a8e02c4c059fae186c4a30960bc1
@@ -1,7 +1,7 @@
1
1
  #include "graphql_c_parser_ext.h"
2
2
 
3
- VALUE GraphQL_CParser_Lexer_tokenize_with_c_internal(VALUE self, VALUE query_string, VALUE fstring_identifiers) {
4
- return tokenize(query_string, RTEST(fstring_identifiers));
3
+ VALUE GraphQL_CParser_Lexer_tokenize_with_c_internal(VALUE self, VALUE query_string, VALUE fstring_identifiers, VALUE reject_numbers_followed_by_names, VALUE max_tokens) {
4
+ return tokenize(query_string, RTEST(fstring_identifiers), RTEST(reject_numbers_followed_by_names), FIX2INT(max_tokens));
5
5
  }
6
6
 
7
7
  VALUE GraphQL_CParser_Parser_c_parse(VALUE self) {
@@ -13,7 +13,7 @@ void Init_graphql_c_parser_ext() {
13
13
  VALUE GraphQL = rb_define_module("GraphQL");
14
14
  VALUE CParser = rb_define_module_under(GraphQL, "CParser");
15
15
  VALUE Lexer = rb_define_module_under(CParser, "Lexer");
16
- rb_define_singleton_method(Lexer, "tokenize_with_c_internal", GraphQL_CParser_Lexer_tokenize_with_c_internal, 2);
16
+ rb_define_singleton_method(Lexer, "tokenize_with_c_internal", GraphQL_CParser_Lexer_tokenize_with_c_internal, 4);
17
17
  setup_static_token_variables();
18
18
 
19
19
  VALUE Parser = rb_define_class_under(CParser, "Parser", rb_cObject);
@@ -1,6 +1,6 @@
1
1
  #line 1 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
2
2
 
3
- #line 102 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
3
+ #line 106 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
4
4
 
5
5
 
6
6
 
@@ -682,7 +682,7 @@ static const int graphql_c_lexer_error = -1;
682
682
  static const int graphql_c_lexer_en_main = 21;
683
683
 
684
684
 
685
- #line 104 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
685
+ #line 108 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
686
686
 
687
687
 
688
688
  #include <ruby.h>
@@ -778,6 +778,10 @@ typedef struct Meta {
778
778
  VALUE tokens;
779
779
  VALUE previous_token;
780
780
  int dedup_identifiers;
781
+ int reject_numbers_followed_by_names;
782
+ int preceeded_by_number;
783
+ int max_tokens;
784
+ int tokens_count;
781
785
  } Meta;
782
786
 
783
787
  #define STATIC_VALUE_TOKEN(token_type, content_str) \
@@ -793,11 +797,25 @@ token_content = rb_utf8_str_new(ts, te - ts); \
793
797
  break;
794
798
 
795
799
  void emit(TokenType tt, char *ts, char *te, Meta *meta) {
800
+ meta->tokens_count++;
801
+ // -1 indicates that there is no limit:
802
+ if (meta->max_tokens > 0 && meta->tokens_count > meta->max_tokens) {
803
+ VALUE mGraphQL = rb_const_get_at(rb_cObject, rb_intern("GraphQL"));
804
+ VALUE cParseError = rb_const_get_at(mGraphQL, rb_intern("ParseError"));
805
+ VALUE exception = rb_funcall(
806
+ cParseError, rb_intern("new"), 4,
807
+ rb_str_new_cstr("This query is too large to execute."),
808
+ LONG2NUM(meta->line),
809
+ LONG2NUM(meta->col),
810
+ rb_str_new_cstr(meta->query_cstr)
811
+ );
812
+ rb_exc_raise(exception);
813
+ }
796
814
  int quotes_length = 0; // set by string tokens below
797
815
  int line_incr = 0;
798
816
  VALUE token_sym = Qnil;
799
817
  VALUE token_content = Qnil;
800
-
818
+ int this_token_is_number = 0;
801
819
  switch(tt) {
802
820
  STATIC_VALUE_TOKEN(ON, "on")
803
821
  STATIC_VALUE_TOKEN(FRAGMENT, "fragment")
@@ -846,6 +864,19 @@ void emit(TokenType tt, char *ts, char *te, Meta *meta) {
846
864
  token_content = GraphQL_null_str;
847
865
  break;
848
866
  case IDENTIFIER:
867
+ if (meta->reject_numbers_followed_by_names && meta->preceeded_by_number) {
868
+ VALUE mGraphQL = rb_const_get_at(rb_cObject, rb_intern("GraphQL"));
869
+ VALUE mCParser = rb_const_get_at(mGraphQL, rb_intern("CParser"));
870
+ VALUE exception = rb_funcall(
871
+ mCParser, rb_intern("prepare_number_name_parse_error"), 5,
872
+ LONG2NUM(meta->line),
873
+ LONG2NUM(meta->col),
874
+ rb_str_new_cstr(meta->query_cstr),
875
+ rb_ary_entry(meta->previous_token, 3),
876
+ rb_utf8_str_new(ts, te - ts)
877
+ );
878
+ rb_exc_raise(exception);
879
+ }
849
880
  token_sym = ID2SYM(rb_intern("IDENTIFIER"));
850
881
  if (meta->dedup_identifiers) {
851
882
  token_content = rb_enc_interned_str(ts, te - ts, rb_utf8_encoding());
@@ -853,8 +884,19 @@ void emit(TokenType tt, char *ts, char *te, Meta *meta) {
853
884
  token_content = rb_utf8_str_new(ts, te - ts);
854
885
  }
855
886
  break;
856
- DYNAMIC_VALUE_TOKEN(INT)
857
- DYNAMIC_VALUE_TOKEN(FLOAT)
887
+ // Can't use these while we're in backwards-compat mode:
888
+ // DYNAMIC_VALUE_TOKEN(INT)
889
+ // DYNAMIC_VALUE_TOKEN(FLOAT)
890
+ case INT:
891
+ token_sym = ID2SYM(rb_intern("INT"));
892
+ token_content = rb_utf8_str_new(ts, te - ts);
893
+ this_token_is_number = 1;
894
+ break;
895
+ case FLOAT:
896
+ token_sym = ID2SYM(rb_intern("FLOAT"));
897
+ token_content = rb_utf8_str_new(ts, te - ts);
898
+ this_token_is_number = 1;
899
+ break;
858
900
  DYNAMIC_VALUE_TOKEN(COMMENT)
859
901
  case UNKNOWN_CHAR:
860
902
  if (ts[0] == '\0') {
@@ -922,6 +964,7 @@ void emit(TokenType tt, char *ts, char *te, Meta *meta) {
922
964
  if (tt != COMMENT) {
923
965
  rb_ary_push(meta->tokens, token);
924
966
  }
967
+ meta->preceeded_by_number = this_token_is_number;
925
968
  meta->previous_token = token;
926
969
  }
927
970
  // Bump the column counter for the next token
@@ -929,7 +972,7 @@ void emit(TokenType tt, char *ts, char *te, Meta *meta) {
929
972
  meta->line += line_incr;
930
973
  }
931
974
 
932
- VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
975
+ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers, int reject_numbers_followed_by_names, int max_tokens) {
933
976
  int cs = 0;
934
977
  int act = 0;
935
978
  char *p = StringValueCStr(query_rbstr);
@@ -938,11 +981,11 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
938
981
  char *ts = 0;
939
982
  char *te = 0;
940
983
  VALUE tokens = rb_ary_new();
941
- struct Meta meta_s = {1, 1, p, pe, tokens, Qnil, fstring_identifiers};
984
+ struct Meta meta_s = {1, 1, p, pe, tokens, Qnil, fstring_identifiers, reject_numbers_followed_by_names, 0, max_tokens, 0};
942
985
  Meta *meta = &meta_s;
943
986
 
944
987
 
945
- #line 946 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
988
+ #line 989 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
946
989
  {
947
990
  cs = (int)graphql_c_lexer_start;
948
991
  ts = 0;
@@ -950,10 +993,10 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
950
993
  act = 0;
951
994
  }
952
995
 
953
- #line 362 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
996
+ #line 409 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
954
997
 
955
998
 
956
- #line 957 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
999
+ #line 1000 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
957
1000
  {
958
1001
  unsigned int _trans = 0;
959
1002
  const char * _keys;
@@ -968,7 +1011,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
968
1011
  #line 1 "NONE"
969
1012
  {ts = p;}}
970
1013
 
971
- #line 972 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1014
+ #line 1015 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
972
1015
 
973
1016
 
974
1017
  break;
@@ -1006,7 +1049,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1006
1049
  #line 1 "NONE"
1007
1050
  {te = p+1;}}
1008
1051
 
1009
- #line 1010 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1052
+ #line 1053 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1010
1053
 
1011
1054
 
1012
1055
  break;
@@ -1019,7 +1062,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1019
1062
  emit(RCURLY, ts, te, meta); }
1020
1063
  }}
1021
1064
 
1022
- #line 1023 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1065
+ #line 1066 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1023
1066
 
1024
1067
 
1025
1068
  break;
@@ -1032,7 +1075,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1032
1075
  emit(LCURLY, ts, te, meta); }
1033
1076
  }}
1034
1077
 
1035
- #line 1036 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1078
+ #line 1079 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1036
1079
 
1037
1080
 
1038
1081
  break;
@@ -1045,7 +1088,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1045
1088
  emit(RPAREN, ts, te, meta); }
1046
1089
  }}
1047
1090
 
1048
- #line 1049 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1091
+ #line 1092 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1049
1092
 
1050
1093
 
1051
1094
  break;
@@ -1058,7 +1101,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1058
1101
  emit(LPAREN, ts, te, meta); }
1059
1102
  }}
1060
1103
 
1061
- #line 1062 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1104
+ #line 1105 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1062
1105
 
1063
1106
 
1064
1107
  break;
@@ -1071,7 +1114,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1071
1114
  emit(RBRACKET, ts, te, meta); }
1072
1115
  }}
1073
1116
 
1074
- #line 1075 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1117
+ #line 1118 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1075
1118
 
1076
1119
 
1077
1120
  break;
@@ -1084,7 +1127,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1084
1127
  emit(LBRACKET, ts, te, meta); }
1085
1128
  }}
1086
1129
 
1087
- #line 1088 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1130
+ #line 1131 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1088
1131
 
1089
1132
 
1090
1133
  break;
@@ -1097,7 +1140,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1097
1140
  emit(COLON, ts, te, meta); }
1098
1141
  }}
1099
1142
 
1100
- #line 1101 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1143
+ #line 1144 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1101
1144
 
1102
1145
 
1103
1146
  break;
@@ -1110,7 +1153,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1110
1153
  emit(BLOCK_STRING, ts, te, meta); }
1111
1154
  }}
1112
1155
 
1113
- #line 1114 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1156
+ #line 1157 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1114
1157
 
1115
1158
 
1116
1159
  break;
@@ -1123,7 +1166,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1123
1166
  emit(QUOTED_STRING, ts, te, meta); }
1124
1167
  }}
1125
1168
 
1126
- #line 1127 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1169
+ #line 1170 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1127
1170
 
1128
1171
 
1129
1172
  break;
@@ -1136,7 +1179,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1136
1179
  emit(VAR_SIGN, ts, te, meta); }
1137
1180
  }}
1138
1181
 
1139
- #line 1140 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1182
+ #line 1183 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1140
1183
 
1141
1184
 
1142
1185
  break;
@@ -1149,7 +1192,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1149
1192
  emit(DIR_SIGN, ts, te, meta); }
1150
1193
  }}
1151
1194
 
1152
- #line 1153 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1195
+ #line 1196 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1153
1196
 
1154
1197
 
1155
1198
  break;
@@ -1162,7 +1205,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1162
1205
  emit(ELLIPSIS, ts, te, meta); }
1163
1206
  }}
1164
1207
 
1165
- #line 1166 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1208
+ #line 1209 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1166
1209
 
1167
1210
 
1168
1211
  break;
@@ -1175,7 +1218,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1175
1218
  emit(EQUALS, ts, te, meta); }
1176
1219
  }}
1177
1220
 
1178
- #line 1179 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1221
+ #line 1222 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1179
1222
 
1180
1223
 
1181
1224
  break;
@@ -1188,7 +1231,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1188
1231
  emit(BANG, ts, te, meta); }
1189
1232
  }}
1190
1233
 
1191
- #line 1192 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1234
+ #line 1235 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1192
1235
 
1193
1236
 
1194
1237
  break;
@@ -1201,7 +1244,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1201
1244
  emit(PIPE, ts, te, meta); }
1202
1245
  }}
1203
1246
 
1204
- #line 1205 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1247
+ #line 1248 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1205
1248
 
1206
1249
 
1207
1250
  break;
@@ -1214,7 +1257,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1214
1257
  emit(AMP, ts, te, meta); }
1215
1258
  }}
1216
1259
 
1217
- #line 1218 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1260
+ #line 1261 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1218
1261
 
1219
1262
 
1220
1263
  break;
@@ -1227,23 +1270,24 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1227
1270
 
1228
1271
  meta->line += 1;
1229
1272
  meta->col = 1;
1273
+ meta->preceeded_by_number = 0;
1230
1274
  }
1231
1275
  }}
1232
1276
 
1233
- #line 1234 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1277
+ #line 1278 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1234
1278
 
1235
1279
 
1236
1280
  break;
1237
1281
  }
1238
1282
  case 11: {
1239
1283
  {
1240
- #line 100 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1284
+ #line 104 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1241
1285
  {te = p+1;{
1242
- #line 100 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1286
+ #line 104 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1243
1287
  emit(UNKNOWN_CHAR, ts, te, meta); }
1244
1288
  }}
1245
1289
 
1246
- #line 1247 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1290
+ #line 1291 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1247
1291
 
1248
1292
 
1249
1293
  break;
@@ -1256,7 +1300,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1256
1300
  emit(INT, ts, te, meta); }
1257
1301
  }}
1258
1302
 
1259
- #line 1260 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1303
+ #line 1304 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1260
1304
 
1261
1305
 
1262
1306
  break;
@@ -1269,7 +1313,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1269
1313
  emit(FLOAT, ts, te, meta); }
1270
1314
  }}
1271
1315
 
1272
- #line 1273 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1316
+ #line 1317 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1273
1317
 
1274
1318
 
1275
1319
  break;
@@ -1282,7 +1326,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1282
1326
  emit(BLOCK_STRING, ts, te, meta); }
1283
1327
  }}
1284
1328
 
1285
- #line 1286 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1329
+ #line 1330 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1286
1330
 
1287
1331
 
1288
1332
  break;
@@ -1295,7 +1339,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1295
1339
  emit(QUOTED_STRING, ts, te, meta); }
1296
1340
  }}
1297
1341
 
1298
- #line 1299 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1342
+ #line 1343 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1299
1343
 
1300
1344
 
1301
1345
  break;
@@ -1308,7 +1352,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1308
1352
  emit(IDENTIFIER, ts, te, meta); }
1309
1353
  }}
1310
1354
 
1311
- #line 1312 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1355
+ #line 1356 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1312
1356
 
1313
1357
 
1314
1358
  break;
@@ -1321,33 +1365,36 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1321
1365
  emit(COMMENT, ts, te, meta); }
1322
1366
  }}
1323
1367
 
1324
- #line 1325 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1368
+ #line 1369 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1325
1369
 
1326
1370
 
1327
1371
  break;
1328
1372
  }
1329
1373
  case 27: {
1330
1374
  {
1331
- #line 98 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1375
+ #line 99 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1332
1376
  {te = p;p = p - 1;{
1333
- #line 98 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1334
- meta->col += te - ts; }
1377
+ #line 99 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1378
+
1379
+ meta->col += te - ts;
1380
+ meta->preceeded_by_number = 0;
1381
+ }
1335
1382
  }}
1336
1383
 
1337
- #line 1338 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1384
+ #line 1385 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1338
1385
 
1339
1386
 
1340
1387
  break;
1341
1388
  }
1342
1389
  case 28: {
1343
1390
  {
1344
- #line 100 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1391
+ #line 104 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1345
1392
  {te = p;p = p - 1;{
1346
- #line 100 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1393
+ #line 104 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1347
1394
  emit(UNKNOWN_CHAR, ts, te, meta); }
1348
1395
  }}
1349
1396
 
1350
- #line 1351 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1397
+ #line 1398 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1351
1398
 
1352
1399
 
1353
1400
  break;
@@ -1361,7 +1408,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1361
1408
  emit(INT, ts, te, meta); }
1362
1409
  }}
1363
1410
 
1364
- #line 1365 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1411
+ #line 1412 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1365
1412
 
1366
1413
 
1367
1414
  break;
@@ -1375,21 +1422,21 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1375
1422
  emit(FLOAT, ts, te, meta); }
1376
1423
  }}
1377
1424
 
1378
- #line 1379 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1425
+ #line 1426 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1379
1426
 
1380
1427
 
1381
1428
  break;
1382
1429
  }
1383
1430
  case 1: {
1384
1431
  {
1385
- #line 100 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1432
+ #line 104 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1386
1433
  {p = ((te))-1;
1387
1434
  {
1388
- #line 100 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1435
+ #line 104 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1389
1436
  emit(UNKNOWN_CHAR, ts, te, meta); }
1390
1437
  }}
1391
1438
 
1392
- #line 1393 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1439
+ #line 1440 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1393
1440
 
1394
1441
 
1395
1442
  break;
@@ -1555,7 +1602,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1555
1602
  }}
1556
1603
  }
1557
1604
 
1558
- #line 1559 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1605
+ #line 1606 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1559
1606
 
1560
1607
 
1561
1608
  break;
@@ -1565,13 +1612,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1565
1612
  #line 1 "NONE"
1566
1613
  {te = p+1;}}
1567
1614
 
1568
- #line 1569 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1615
+ #line 1616 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1569
1616
 
1570
1617
  {
1571
1618
  #line 56 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1572
1619
  {act = 3;}}
1573
1620
 
1574
- #line 1575 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1621
+ #line 1622 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1575
1622
 
1576
1623
 
1577
1624
  break;
@@ -1581,13 +1628,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1581
1628
  #line 1 "NONE"
1582
1629
  {te = p+1;}}
1583
1630
 
1584
- #line 1585 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1631
+ #line 1632 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1585
1632
 
1586
1633
  {
1587
1634
  #line 57 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1588
1635
  {act = 4;}}
1589
1636
 
1590
- #line 1591 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1637
+ #line 1638 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1591
1638
 
1592
1639
 
1593
1640
  break;
@@ -1597,13 +1644,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1597
1644
  #line 1 "NONE"
1598
1645
  {te = p+1;}}
1599
1646
 
1600
- #line 1601 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1647
+ #line 1648 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1601
1648
 
1602
1649
  {
1603
1650
  #line 58 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1604
1651
  {act = 5;}}
1605
1652
 
1606
- #line 1607 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1653
+ #line 1654 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1607
1654
 
1608
1655
 
1609
1656
  break;
@@ -1613,13 +1660,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1613
1660
  #line 1 "NONE"
1614
1661
  {te = p+1;}}
1615
1662
 
1616
- #line 1617 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1663
+ #line 1664 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1617
1664
 
1618
1665
  {
1619
1666
  #line 59 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1620
1667
  {act = 6;}}
1621
1668
 
1622
- #line 1623 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1669
+ #line 1670 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1623
1670
 
1624
1671
 
1625
1672
  break;
@@ -1629,13 +1676,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1629
1676
  #line 1 "NONE"
1630
1677
  {te = p+1;}}
1631
1678
 
1632
- #line 1633 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1679
+ #line 1680 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1633
1680
 
1634
1681
  {
1635
1682
  #line 60 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1636
1683
  {act = 7;}}
1637
1684
 
1638
- #line 1639 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1685
+ #line 1686 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1639
1686
 
1640
1687
 
1641
1688
  break;
@@ -1645,13 +1692,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1645
1692
  #line 1 "NONE"
1646
1693
  {te = p+1;}}
1647
1694
 
1648
- #line 1649 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1695
+ #line 1696 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1649
1696
 
1650
1697
  {
1651
1698
  #line 61 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1652
1699
  {act = 8;}}
1653
1700
 
1654
- #line 1655 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1701
+ #line 1702 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1655
1702
 
1656
1703
 
1657
1704
  break;
@@ -1661,13 +1708,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1661
1708
  #line 1 "NONE"
1662
1709
  {te = p+1;}}
1663
1710
 
1664
- #line 1665 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1711
+ #line 1712 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1665
1712
 
1666
1713
  {
1667
1714
  #line 62 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1668
1715
  {act = 9;}}
1669
1716
 
1670
- #line 1671 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1717
+ #line 1718 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1671
1718
 
1672
1719
 
1673
1720
  break;
@@ -1677,13 +1724,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1677
1724
  #line 1 "NONE"
1678
1725
  {te = p+1;}}
1679
1726
 
1680
- #line 1681 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1727
+ #line 1728 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1681
1728
 
1682
1729
  {
1683
1730
  #line 63 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1684
1731
  {act = 10;}}
1685
1732
 
1686
- #line 1687 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1733
+ #line 1734 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1687
1734
 
1688
1735
 
1689
1736
  break;
@@ -1693,13 +1740,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1693
1740
  #line 1 "NONE"
1694
1741
  {te = p+1;}}
1695
1742
 
1696
- #line 1697 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1743
+ #line 1744 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1697
1744
 
1698
1745
  {
1699
1746
  #line 64 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1700
1747
  {act = 11;}}
1701
1748
 
1702
- #line 1703 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1749
+ #line 1750 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1703
1750
 
1704
1751
 
1705
1752
  break;
@@ -1709,13 +1756,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1709
1756
  #line 1 "NONE"
1710
1757
  {te = p+1;}}
1711
1758
 
1712
- #line 1713 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1759
+ #line 1760 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1713
1760
 
1714
1761
  {
1715
1762
  #line 65 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1716
1763
  {act = 12;}}
1717
1764
 
1718
- #line 1719 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1765
+ #line 1766 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1719
1766
 
1720
1767
 
1721
1768
  break;
@@ -1725,13 +1772,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1725
1772
  #line 1 "NONE"
1726
1773
  {te = p+1;}}
1727
1774
 
1728
- #line 1729 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1775
+ #line 1776 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1729
1776
 
1730
1777
  {
1731
1778
  #line 66 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1732
1779
  {act = 13;}}
1733
1780
 
1734
- #line 1735 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1781
+ #line 1782 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1735
1782
 
1736
1783
 
1737
1784
  break;
@@ -1741,13 +1788,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1741
1788
  #line 1 "NONE"
1742
1789
  {te = p+1;}}
1743
1790
 
1744
- #line 1745 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1791
+ #line 1792 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1745
1792
 
1746
1793
  {
1747
1794
  #line 67 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1748
1795
  {act = 14;}}
1749
1796
 
1750
- #line 1751 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1797
+ #line 1798 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1751
1798
 
1752
1799
 
1753
1800
  break;
@@ -1757,13 +1804,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1757
1804
  #line 1 "NONE"
1758
1805
  {te = p+1;}}
1759
1806
 
1760
- #line 1761 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1807
+ #line 1808 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1761
1808
 
1762
1809
  {
1763
1810
  #line 68 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1764
1811
  {act = 15;}}
1765
1812
 
1766
- #line 1767 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1813
+ #line 1814 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1767
1814
 
1768
1815
 
1769
1816
  break;
@@ -1773,13 +1820,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1773
1820
  #line 1 "NONE"
1774
1821
  {te = p+1;}}
1775
1822
 
1776
- #line 1777 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1823
+ #line 1824 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1777
1824
 
1778
1825
  {
1779
1826
  #line 69 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1780
1827
  {act = 16;}}
1781
1828
 
1782
- #line 1783 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1829
+ #line 1830 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1783
1830
 
1784
1831
 
1785
1832
  break;
@@ -1789,13 +1836,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1789
1836
  #line 1 "NONE"
1790
1837
  {te = p+1;}}
1791
1838
 
1792
- #line 1793 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1839
+ #line 1840 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1793
1840
 
1794
1841
  {
1795
1842
  #line 70 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1796
1843
  {act = 17;}}
1797
1844
 
1798
- #line 1799 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1845
+ #line 1846 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1799
1846
 
1800
1847
 
1801
1848
  break;
@@ -1805,13 +1852,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1805
1852
  #line 1 "NONE"
1806
1853
  {te = p+1;}}
1807
1854
 
1808
- #line 1809 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1855
+ #line 1856 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1809
1856
 
1810
1857
  {
1811
1858
  #line 71 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1812
1859
  {act = 18;}}
1813
1860
 
1814
- #line 1815 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1861
+ #line 1862 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1815
1862
 
1816
1863
 
1817
1864
  break;
@@ -1821,13 +1868,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1821
1868
  #line 1 "NONE"
1822
1869
  {te = p+1;}}
1823
1870
 
1824
- #line 1825 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1871
+ #line 1872 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1825
1872
 
1826
1873
  {
1827
1874
  #line 72 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1828
1875
  {act = 19;}}
1829
1876
 
1830
- #line 1831 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1877
+ #line 1878 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1831
1878
 
1832
1879
 
1833
1880
  break;
@@ -1837,13 +1884,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1837
1884
  #line 1 "NONE"
1838
1885
  {te = p+1;}}
1839
1886
 
1840
- #line 1841 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1887
+ #line 1888 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1841
1888
 
1842
1889
  {
1843
1890
  #line 73 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1844
1891
  {act = 20;}}
1845
1892
 
1846
- #line 1847 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1893
+ #line 1894 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1847
1894
 
1848
1895
 
1849
1896
  break;
@@ -1853,13 +1900,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1853
1900
  #line 1 "NONE"
1854
1901
  {te = p+1;}}
1855
1902
 
1856
- #line 1857 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1903
+ #line 1904 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1857
1904
 
1858
1905
  {
1859
1906
  #line 74 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1860
1907
  {act = 21;}}
1861
1908
 
1862
- #line 1863 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1909
+ #line 1910 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1863
1910
 
1864
1911
 
1865
1912
  break;
@@ -1869,13 +1916,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1869
1916
  #line 1 "NONE"
1870
1917
  {te = p+1;}}
1871
1918
 
1872
- #line 1873 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1919
+ #line 1920 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1873
1920
 
1874
1921
  {
1875
1922
  #line 82 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1876
1923
  {act = 29;}}
1877
1924
 
1878
- #line 1879 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1925
+ #line 1926 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1879
1926
 
1880
1927
 
1881
1928
  break;
@@ -1885,13 +1932,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1885
1932
  #line 1 "NONE"
1886
1933
  {te = p+1;}}
1887
1934
 
1888
- #line 1889 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1935
+ #line 1936 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1889
1936
 
1890
1937
  {
1891
1938
  #line 83 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1892
1939
  {act = 30;}}
1893
1940
 
1894
- #line 1895 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1941
+ #line 1942 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1895
1942
 
1896
1943
 
1897
1944
  break;
@@ -1901,13 +1948,13 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1901
1948
  #line 1 "NONE"
1902
1949
  {te = p+1;}}
1903
1950
 
1904
- #line 1905 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1951
+ #line 1952 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1905
1952
 
1906
1953
  {
1907
1954
  #line 91 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1908
1955
  {act = 38;}}
1909
1956
 
1910
- #line 1911 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1957
+ #line 1958 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1911
1958
 
1912
1959
 
1913
1960
  break;
@@ -1927,7 +1974,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1927
1974
  #line 1 "NONE"
1928
1975
  {ts = 0;}}
1929
1976
 
1930
- #line 1931 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1977
+ #line 1978 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.c"
1931
1978
 
1932
1979
 
1933
1980
  break;
@@ -1940,7 +1987,7 @@ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers) {
1940
1987
  _out: {}
1941
1988
  }
1942
1989
 
1943
- #line 363 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1990
+ #line 410 "graphql-c_parser/ext/graphql_c_parser_ext/lexer.rl"
1944
1991
 
1945
1992
 
1946
1993
  return tokens;
@@ -1,6 +1,6 @@
1
1
  #ifndef Graphql_lexer_h
2
2
  #define Graphql_lexer_h
3
3
  #include <ruby.h>
4
- VALUE tokenize(VALUE query_rbstr, int fstring_identifiers);
4
+ VALUE tokenize(VALUE query_rbstr, int fstring_identifiers, int reject_numbers_followed_by_names, int max_tokens);
5
5
  void setup_static_token_variables();
6
6
  #endif
@@ -2,6 +2,6 @@
2
2
 
3
3
  module GraphQL
4
4
  module CParser
5
- VERSION = "1.1.0"
5
+ VERSION = "1.1.1"
6
6
  end
7
7
  end
@@ -6,8 +6,8 @@ require "graphql/graphql_c_parser_ext"
6
6
 
7
7
  module GraphQL
8
8
  module CParser
9
- def self.parse(query_str, filename: nil, trace: GraphQL::Tracing::NullTrace)
10
- Parser.parse(query_str, filename: filename, trace: trace)
9
+ def self.parse(query_str, filename: nil, trace: GraphQL::Tracing::NullTrace, max_tokens: nil)
10
+ Parser.parse(query_str, filename: filename, trace: trace, max_tokens: max_tokens)
11
11
  end
12
12
 
13
13
  def self.parse_file(filename)
@@ -16,12 +16,15 @@ module GraphQL
16
16
  end
17
17
 
18
18
  def self.tokenize_with_c(str)
19
- tokenize_with_c_internal(str, false)
19
+ reject_numbers_followed_by_names = GraphQL.respond_to?(:reject_numbers_followed_by_names) && GraphQL.reject_numbers_followed_by_names
20
+ tokenize_with_c_internal(str, false, reject_numbers_followed_by_names)
20
21
  end
21
22
 
22
23
  def self.prepare_parse_error(message, parser)
24
+ query_str = parser.query_string
25
+ filename = parser.filename
23
26
  if message.start_with?("memory exhausted")
24
- return GraphQL::ParseError.new("This query is too large to execute.", nil, nil, parser.query_string, filename: parser.filename)
27
+ return GraphQL::ParseError.new("This query is too large to execute.", nil, nil, query_str, filename: filename)
25
28
  end
26
29
  token = parser.tokens[parser.next_token_index - 1]
27
30
  if token
@@ -40,7 +43,11 @@ module GraphQL
40
43
  end
41
44
  end
42
45
 
43
- GraphQL::ParseError.new(message, line, col, parser.query_string, filename: parser.filename)
46
+ GraphQL::ParseError.new(message, line, col, query_str, filename: filename)
47
+ end
48
+
49
+ def self.prepare_number_name_parse_error(line, col, query_str, number_part, name_part)
50
+ raise GraphQL::ParseError.new("Name after number is not allowed (in `#{number_part}#{name_part}`)", line, col, query_str)
44
51
  end
45
52
 
46
53
  def self.prepare_bad_unicode_error(parser)
@@ -57,7 +64,7 @@ module GraphQL
57
64
  end
58
65
 
59
66
  module Lexer
60
- def self.tokenize(graphql_string, intern_identifiers: false)
67
+ def self.tokenize(graphql_string, intern_identifiers: false, max_tokens: nil)
61
68
  if !(graphql_string.encoding == Encoding::UTF_8 || graphql_string.ascii_only?)
62
69
  graphql_string = graphql_string.dup.force_encoding(Encoding::UTF_8)
63
70
  end
@@ -73,13 +80,16 @@ module GraphQL
73
80
  ]
74
81
  ]
75
82
  end
76
- tokenize_with_c_internal(graphql_string, intern_identifiers)
83
+ reject_numbers_followed_by_names = GraphQL.respond_to?(:reject_numbers_followed_by_names) && GraphQL.reject_numbers_followed_by_names
84
+ # -1 indicates that there is no limit
85
+ lexer_max_tokens = max_tokens.nil? ? -1 : max_tokens
86
+ tokenize_with_c_internal(graphql_string, intern_identifiers, reject_numbers_followed_by_names, lexer_max_tokens)
77
87
  end
78
88
  end
79
89
 
80
90
  class Parser
81
- def self.parse(query_str, filename: nil, trace: GraphQL::Tracing::NullTrace)
82
- self.new(query_str, filename, trace).result
91
+ def self.parse(query_str, filename: nil, trace: GraphQL::Tracing::NullTrace, max_tokens: nil)
92
+ self.new(query_str, filename, trace, max_tokens).result
83
93
  end
84
94
 
85
95
  def self.parse_file(filename)
@@ -87,7 +97,7 @@ module GraphQL
87
97
  parse(contents, filename: filename)
88
98
  end
89
99
 
90
- def initialize(query_string, filename, trace)
100
+ def initialize(query_string, filename, trace, max_tokens)
91
101
  if query_string.nil?
92
102
  raise GraphQL::ParseError.new("No query string was present", nil, nil, query_string)
93
103
  end
@@ -98,12 +108,13 @@ module GraphQL
98
108
  @result = nil
99
109
  @trace = trace
100
110
  @intern_identifiers = false
111
+ @max_tokens = max_tokens
101
112
  end
102
113
 
103
114
  def result
104
115
  if @result.nil?
105
116
  @tokens = @trace.lex(query_string: @query_string) do
106
- GraphQL::CParser::Lexer.tokenize(@query_string, intern_identifiers: @intern_identifiers)
117
+ GraphQL::CParser::Lexer.tokenize(@query_string, intern_identifiers: @intern_identifiers, max_tokens: @max_tokens)
107
118
  end
108
119
  @trace.parse(query_string: @query_string) do
109
120
  c_parse
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: graphql-c_parser
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.0
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Robert Mosolgo
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-04-15 00:00:00.000000000 Z
11
+ date: 2024-04-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: graphql