rails-graphql 0.2.0 → 1.0.0.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (297) hide show
  1. checksums.yaml +4 -4
  2. data/ext/console.rb +18 -0
  3. data/ext/extconf.h +3 -0
  4. data/ext/extconf.rb +1 -54
  5. data/ext/gql_parser.c +646 -0
  6. data/ext/shared.c +482 -0
  7. data/ext/shared.h +177 -0
  8. data/lib/gql_parser.so +0 -0
  9. data/lib/rails/graphql/adapters/mysql_adapter.rb +59 -0
  10. data/lib/rails/graphql/adapters/pg_adapter.rb +25 -22
  11. data/lib/rails/graphql/adapters/sqlite_adapter.rb +17 -14
  12. data/lib/rails/graphql/alternative/field_set.rb +36 -0
  13. data/lib/rails/graphql/alternative/mutation.rb +17 -0
  14. data/lib/rails/graphql/alternative/query.rb +93 -0
  15. data/lib/rails/graphql/alternative/subscription.rb +17 -0
  16. data/lib/rails/graphql/alternative.rb +20 -0
  17. data/lib/rails/graphql/argument.rb +21 -24
  18. data/lib/rails/graphql/callback.rb +24 -9
  19. data/lib/rails/graphql/collectors/hash_collector.rb +14 -6
  20. data/lib/rails/graphql/collectors/idented_collector.rb +10 -7
  21. data/lib/rails/graphql/collectors/json_collector.rb +22 -17
  22. data/lib/rails/graphql/collectors.rb +4 -4
  23. data/lib/rails/graphql/config.rb +130 -15
  24. data/lib/rails/graphql/directive/cached_directive.rb +33 -0
  25. data/lib/rails/graphql/directive/deprecated_directive.rb +10 -10
  26. data/lib/rails/graphql/directive/include_directive.rb +5 -4
  27. data/lib/rails/graphql/directive/skip_directive.rb +5 -4
  28. data/lib/rails/graphql/directive.rb +118 -63
  29. data/lib/rails/graphql/errors.rb +33 -4
  30. data/lib/rails/graphql/event.rb +16 -5
  31. data/lib/rails/graphql/field/authorized_field.rb +19 -3
  32. data/lib/rails/graphql/field/input_field.rb +11 -10
  33. data/lib/rails/graphql/field/mutation_field.rb +42 -7
  34. data/lib/rails/graphql/field/output_field.rb +102 -13
  35. data/lib/rails/graphql/field/proxied_field.rb +31 -22
  36. data/lib/rails/graphql/field/resolved_field.rb +26 -24
  37. data/lib/rails/graphql/field/scoped_config.rb +10 -4
  38. data/lib/rails/graphql/field/subscription_field.rb +140 -0
  39. data/lib/rails/graphql/field/typed_field.rb +43 -22
  40. data/lib/rails/graphql/field.rb +70 -56
  41. data/lib/rails/graphql/global_id.rb +85 -0
  42. data/lib/rails/graphql/helpers/attribute_delegator.rb +5 -5
  43. data/lib/rails/graphql/helpers/inherited_collection/array.rb +50 -0
  44. data/lib/rails/graphql/helpers/inherited_collection/base.rb +43 -0
  45. data/lib/rails/graphql/helpers/inherited_collection/hash.rb +87 -0
  46. data/lib/rails/graphql/helpers/inherited_collection.rb +25 -76
  47. data/lib/rails/graphql/helpers/instantiable.rb +15 -0
  48. data/lib/rails/graphql/helpers/leaf_from_ar.rb +7 -7
  49. data/lib/rails/graphql/helpers/registerable.rb +44 -62
  50. data/lib/rails/graphql/helpers/unregisterable.rb +16 -0
  51. data/lib/rails/graphql/helpers/with_arguments.rb +31 -27
  52. data/lib/rails/graphql/helpers/with_assignment.rb +10 -8
  53. data/lib/rails/graphql/helpers/with_callbacks.rb +25 -8
  54. data/lib/rails/graphql/helpers/with_description.rb +71 -0
  55. data/lib/rails/graphql/helpers/with_directives.rb +54 -30
  56. data/lib/rails/graphql/helpers/with_events.rb +21 -23
  57. data/lib/rails/graphql/helpers/with_fields.rb +76 -22
  58. data/lib/rails/graphql/helpers/with_global_id.rb +22 -0
  59. data/lib/rails/graphql/helpers/with_name.rb +43 -0
  60. data/lib/rails/graphql/helpers/with_namespace.rb +7 -4
  61. data/lib/rails/graphql/helpers/with_owner.rb +8 -7
  62. data/lib/rails/graphql/helpers/with_schema_fields.rb +137 -55
  63. data/lib/rails/graphql/helpers/with_validator.rb +9 -9
  64. data/lib/rails/graphql/helpers.rb +10 -3
  65. data/lib/rails/graphql/introspection.rb +43 -36
  66. data/lib/rails/graphql/railtie.rb +88 -33
  67. data/lib/rails/graphql/railties/base_generator.rb +3 -9
  68. data/lib/rails/graphql/railties/channel.rb +157 -0
  69. data/lib/rails/graphql/railties/controller.rb +62 -17
  70. data/lib/rails/graphql/railties/controller_runtime.rb +5 -5
  71. data/lib/rails/graphql/railties/log_subscriber.rb +81 -14
  72. data/lib/rails/graphql/request/arguments.rb +24 -49
  73. data/lib/rails/graphql/request/backtrace.rb +191 -0
  74. data/lib/rails/graphql/request/component/field.rb +86 -65
  75. data/lib/rails/graphql/request/component/fragment.rb +72 -24
  76. data/lib/rails/graphql/request/component/operation/subscription.rb +164 -4
  77. data/lib/rails/graphql/request/component/operation.rb +63 -31
  78. data/lib/rails/graphql/request/component/spread.rb +68 -25
  79. data/lib/rails/graphql/request/component/typename.rb +27 -12
  80. data/lib/rails/graphql/request/component.rb +75 -36
  81. data/lib/rails/graphql/request/context.rb +18 -8
  82. data/lib/rails/graphql/request/errors.rb +16 -6
  83. data/lib/rails/graphql/request/event.rb +19 -8
  84. data/lib/rails/graphql/request/helpers/directives.rb +68 -27
  85. data/lib/rails/graphql/request/helpers/selection_set.rb +51 -25
  86. data/lib/rails/graphql/request/helpers/value_writers.rb +18 -16
  87. data/lib/rails/graphql/request/prepared_data.rb +98 -0
  88. data/lib/rails/graphql/request/steps/authorizable.rb +24 -14
  89. data/lib/rails/graphql/request/steps/organizable.rb +110 -48
  90. data/lib/rails/graphql/request/steps/{prepareable.rb → preparable.rb} +20 -7
  91. data/lib/rails/graphql/request/steps/{resolveable.rb → resolvable.rb} +15 -6
  92. data/lib/rails/graphql/request/strategy/cached_strategy.rb +64 -0
  93. data/lib/rails/graphql/request/strategy/dynamic_instance.rb +6 -6
  94. data/lib/rails/graphql/request/strategy/multi_query_strategy.rb +6 -13
  95. data/lib/rails/graphql/request/strategy/sequenced_strategy.rb +9 -9
  96. data/lib/rails/graphql/request/strategy.rb +131 -75
  97. data/lib/rails/graphql/request/subscription.rb +80 -0
  98. data/lib/rails/graphql/request.rb +305 -86
  99. data/lib/rails/graphql/schema.rb +240 -48
  100. data/lib/rails/graphql/shortcuts.rb +22 -3
  101. data/lib/rails/graphql/source/active_record/builders.rb +50 -36
  102. data/lib/rails/graphql/source/active_record_source.rb +70 -54
  103. data/lib/rails/graphql/source/base.rb +111 -0
  104. data/lib/rails/graphql/source/builder.rb +128 -0
  105. data/lib/rails/graphql/source/scoped_arguments.rb +31 -19
  106. data/lib/rails/graphql/source.rb +89 -213
  107. data/lib/rails/graphql/subscription/provider/action_cable.rb +112 -0
  108. data/lib/rails/graphql/subscription/provider/base.rb +191 -0
  109. data/lib/rails/graphql/subscription/provider.rb +18 -0
  110. data/lib/rails/graphql/subscription/store/base.rb +145 -0
  111. data/lib/rails/graphql/subscription/store/memory.rb +127 -0
  112. data/lib/rails/graphql/subscription/store.rb +19 -0
  113. data/lib/rails/graphql/subscription.rb +17 -0
  114. data/lib/rails/graphql/to_gql.rb +29 -32
  115. data/lib/rails/graphql/type/enum/directive_location_enum.rb +11 -11
  116. data/lib/rails/graphql/type/enum/type_kind_enum.rb +3 -3
  117. data/lib/rails/graphql/type/enum.rb +34 -48
  118. data/lib/rails/graphql/type/input.rb +74 -23
  119. data/lib/rails/graphql/type/interface.rb +16 -26
  120. data/lib/rails/graphql/type/object/directive_object.rb +4 -4
  121. data/lib/rails/graphql/type/object/enum_value_object.rb +3 -3
  122. data/lib/rails/graphql/type/object/field_object.rb +24 -6
  123. data/lib/rails/graphql/type/object/input_value_object.rb +3 -3
  124. data/lib/rails/graphql/type/object/schema_object.rb +5 -8
  125. data/lib/rails/graphql/type/object/type_object.rb +29 -19
  126. data/lib/rails/graphql/type/object.rb +26 -23
  127. data/lib/rails/graphql/type/scalar/any_scalar.rb +30 -0
  128. data/lib/rails/graphql/type/scalar/bigint_scalar.rb +5 -5
  129. data/lib/rails/graphql/type/scalar/binary_scalar.rb +3 -3
  130. data/lib/rails/graphql/type/scalar/boolean_scalar.rb +8 -8
  131. data/lib/rails/graphql/type/scalar/date_scalar.rb +3 -3
  132. data/lib/rails/graphql/type/scalar/date_time_scalar.rb +3 -3
  133. data/lib/rails/graphql/type/scalar/decimal_scalar.rb +3 -3
  134. data/lib/rails/graphql/type/scalar/float_scalar.rb +5 -5
  135. data/lib/rails/graphql/type/scalar/id_scalar.rb +6 -5
  136. data/lib/rails/graphql/type/scalar/int_scalar.rb +6 -5
  137. data/lib/rails/graphql/type/scalar/json_scalar.rb +39 -0
  138. data/lib/rails/graphql/type/scalar/string_scalar.rb +18 -4
  139. data/lib/rails/graphql/type/scalar/time_scalar.rb +5 -5
  140. data/lib/rails/graphql/type/scalar.rb +25 -22
  141. data/lib/rails/graphql/type/union.rb +14 -16
  142. data/lib/rails/graphql/type.rb +34 -25
  143. data/lib/rails/graphql/type_map.rb +257 -165
  144. data/lib/rails/graphql/uri.rb +166 -0
  145. data/lib/rails/graphql/version.rb +15 -3
  146. data/lib/rails/graphql.rake +3 -0
  147. data/lib/rails/graphql.rb +85 -52
  148. data/lib/rails-graphql.rb +1 -1
  149. data/test/assets/en.yml +29 -0
  150. data/test/assets/introspection-mem.txt +1 -1
  151. data/test/assets/mem.gql +18 -45
  152. data/test/assets/mysql.gql +392 -0
  153. data/test/assets/sqlite.gql +21 -12
  154. data/test/assets/translate.gql +335 -0
  155. data/test/config.rb +18 -8
  156. data/test/graphql/schema_test.rb +12 -19
  157. data/test/graphql/source_test.rb +8 -75
  158. data/test/graphql/type/enum_test.rb +207 -203
  159. data/test/graphql/type/input_test.rb +14 -9
  160. data/test/graphql/type/interface_test.rb +4 -4
  161. data/test/graphql/type/scalar/any_scalar_test.rb +38 -0
  162. data/test/graphql/type/scalar/boolean_scalar_test.rb +6 -3
  163. data/test/graphql/type/scalar/json_scalar_test.rb +23 -0
  164. data/test/graphql/type_map_test.rb +51 -66
  165. data/test/graphql/type_test.rb +0 -19
  166. data/test/graphql_test.rb +1 -1
  167. data/test/integration/{authorization/authorization_test.rb → authorization_test.rb} +40 -14
  168. data/test/integration/config.rb +36 -3
  169. data/test/integration/customization_test.rb +39 -0
  170. data/test/integration/global_id_test.rb +99 -0
  171. data/test/integration/memory/star_wars_introspection_test.rb +24 -16
  172. data/test/integration/memory/star_wars_query_test.rb +54 -3
  173. data/test/integration/memory/star_wars_validation_test.rb +1 -1
  174. data/test/integration/mysql/star_wars_introspection_test.rb +25 -0
  175. data/test/integration/persisted_query_test.rb +87 -0
  176. data/test/integration/resolver_precedence_test.rb +154 -0
  177. data/test/integration/schemas/memory.rb +22 -7
  178. data/test/integration/schemas/mysql.rb +62 -0
  179. data/test/integration/schemas/sqlite.rb +21 -12
  180. data/test/integration/sqlite/star_wars_global_id_test.rb +83 -0
  181. data/test/integration/sqlite/star_wars_introspection_test.rb +10 -0
  182. data/test/integration/sqlite/star_wars_query_test.rb +14 -1
  183. data/test/integration/translate_test.rb +61 -0
  184. data/test/test_ext.rb +16 -13
  185. metadata +108 -157
  186. data/ext/depend +0 -3
  187. data/ext/graphqlparser/Ast.cpp +0 -346
  188. data/ext/graphqlparser/Ast.h +0 -1214
  189. data/ext/graphqlparser/AstNode.h +0 -36
  190. data/ext/graphqlparser/AstVisitor.h +0 -137
  191. data/ext/graphqlparser/GraphQLParser.cpp +0 -76
  192. data/ext/graphqlparser/GraphQLParser.h +0 -55
  193. data/ext/graphqlparser/JsonVisitor.cpp +0 -161
  194. data/ext/graphqlparser/JsonVisitor.cpp.inc +0 -456
  195. data/ext/graphqlparser/JsonVisitor.h +0 -121
  196. data/ext/graphqlparser/JsonVisitor.h.inc +0 -110
  197. data/ext/graphqlparser/VERSION +0 -1
  198. data/ext/graphqlparser/c/GraphQLAst.cpp +0 -324
  199. data/ext/graphqlparser/c/GraphQLAst.h +0 -180
  200. data/ext/graphqlparser/c/GraphQLAstForEachConcreteType.h +0 -44
  201. data/ext/graphqlparser/c/GraphQLAstNode.cpp +0 -25
  202. data/ext/graphqlparser/c/GraphQLAstNode.h +0 -33
  203. data/ext/graphqlparser/c/GraphQLAstToJSON.cpp +0 -21
  204. data/ext/graphqlparser/c/GraphQLAstToJSON.h +0 -24
  205. data/ext/graphqlparser/c/GraphQLAstVisitor.cpp +0 -55
  206. data/ext/graphqlparser/c/GraphQLAstVisitor.h +0 -53
  207. data/ext/graphqlparser/c/GraphQLParser.cpp +0 -35
  208. data/ext/graphqlparser/c/GraphQLParser.h +0 -54
  209. data/ext/graphqlparser/dump_json_ast.cpp +0 -48
  210. data/ext/graphqlparser/lexer.lpp +0 -324
  211. data/ext/graphqlparser/parser.ypp +0 -693
  212. data/ext/graphqlparser/parsergen/lexer.cpp +0 -2633
  213. data/ext/graphqlparser/parsergen/lexer.h +0 -528
  214. data/ext/graphqlparser/parsergen/location.hh +0 -189
  215. data/ext/graphqlparser/parsergen/parser.tab.cpp +0 -3300
  216. data/ext/graphqlparser/parsergen/parser.tab.hpp +0 -646
  217. data/ext/graphqlparser/parsergen/position.hh +0 -179
  218. data/ext/graphqlparser/parsergen/stack.hh +0 -156
  219. data/ext/graphqlparser/syntaxdefs.h +0 -19
  220. data/ext/libgraphqlparser/AstNode.h +0 -36
  221. data/ext/libgraphqlparser/CMakeLists.txt +0 -148
  222. data/ext/libgraphqlparser/CONTRIBUTING.md +0 -23
  223. data/ext/libgraphqlparser/GraphQLParser.cpp +0 -76
  224. data/ext/libgraphqlparser/GraphQLParser.h +0 -55
  225. data/ext/libgraphqlparser/JsonVisitor.cpp +0 -161
  226. data/ext/libgraphqlparser/JsonVisitor.h +0 -121
  227. data/ext/libgraphqlparser/LICENSE +0 -22
  228. data/ext/libgraphqlparser/README.clang-tidy +0 -7
  229. data/ext/libgraphqlparser/README.md +0 -84
  230. data/ext/libgraphqlparser/ast/ast.ast +0 -203
  231. data/ext/libgraphqlparser/ast/ast.py +0 -61
  232. data/ext/libgraphqlparser/ast/c.py +0 -100
  233. data/ext/libgraphqlparser/ast/c.pyc +0 -0
  234. data/ext/libgraphqlparser/ast/c_impl.py +0 -61
  235. data/ext/libgraphqlparser/ast/c_impl.pyc +0 -0
  236. data/ext/libgraphqlparser/ast/c_visitor_impl.py +0 -39
  237. data/ext/libgraphqlparser/ast/c_visitor_impl.pyc +0 -0
  238. data/ext/libgraphqlparser/ast/casing.py +0 -26
  239. data/ext/libgraphqlparser/ast/casing.pyc +0 -0
  240. data/ext/libgraphqlparser/ast/cxx.py +0 -197
  241. data/ext/libgraphqlparser/ast/cxx.pyc +0 -0
  242. data/ext/libgraphqlparser/ast/cxx_impl.py +0 -61
  243. data/ext/libgraphqlparser/ast/cxx_impl.pyc +0 -0
  244. data/ext/libgraphqlparser/ast/cxx_json_visitor_header.py +0 -42
  245. data/ext/libgraphqlparser/ast/cxx_json_visitor_header.pyc +0 -0
  246. data/ext/libgraphqlparser/ast/cxx_json_visitor_impl.py +0 -80
  247. data/ext/libgraphqlparser/ast/cxx_json_visitor_impl.pyc +0 -0
  248. data/ext/libgraphqlparser/ast/cxx_visitor.py +0 -64
  249. data/ext/libgraphqlparser/ast/cxx_visitor.pyc +0 -0
  250. data/ext/libgraphqlparser/ast/js.py +0 -65
  251. data/ext/libgraphqlparser/ast/license.py +0 -10
  252. data/ext/libgraphqlparser/ast/license.pyc +0 -0
  253. data/ext/libgraphqlparser/c/GraphQLAstNode.cpp +0 -25
  254. data/ext/libgraphqlparser/c/GraphQLAstNode.h +0 -33
  255. data/ext/libgraphqlparser/c/GraphQLAstToJSON.cpp +0 -21
  256. data/ext/libgraphqlparser/c/GraphQLAstToJSON.h +0 -24
  257. data/ext/libgraphqlparser/c/GraphQLAstVisitor.cpp +0 -55
  258. data/ext/libgraphqlparser/c/GraphQLAstVisitor.h +0 -53
  259. data/ext/libgraphqlparser/c/GraphQLParser.cpp +0 -35
  260. data/ext/libgraphqlparser/c/GraphQLParser.h +0 -54
  261. data/ext/libgraphqlparser/clang-tidy-all.sh +0 -3
  262. data/ext/libgraphqlparser/cmake/version.cmake +0 -16
  263. data/ext/libgraphqlparser/dump_json_ast.cpp +0 -48
  264. data/ext/libgraphqlparser/go/README.md +0 -20
  265. data/ext/libgraphqlparser/go/callbacks.go +0 -18
  266. data/ext/libgraphqlparser/go/gotest.go +0 -64
  267. data/ext/libgraphqlparser/lexer.lpp +0 -324
  268. data/ext/libgraphqlparser/libgraphqlparser.pc.in +0 -11
  269. data/ext/libgraphqlparser/parser.ypp +0 -693
  270. data/ext/libgraphqlparser/parsergen/lexer.cpp +0 -2633
  271. data/ext/libgraphqlparser/parsergen/lexer.h +0 -528
  272. data/ext/libgraphqlparser/parsergen/location.hh +0 -189
  273. data/ext/libgraphqlparser/parsergen/parser.tab.cpp +0 -3300
  274. data/ext/libgraphqlparser/parsergen/parser.tab.hpp +0 -646
  275. data/ext/libgraphqlparser/parsergen/position.hh +0 -179
  276. data/ext/libgraphqlparser/parsergen/stack.hh +0 -156
  277. data/ext/libgraphqlparser/python/CMakeLists.txt +0 -14
  278. data/ext/libgraphqlparser/python/README.md +0 -5
  279. data/ext/libgraphqlparser/python/example.py +0 -31
  280. data/ext/libgraphqlparser/syntaxdefs.h +0 -19
  281. data/ext/libgraphqlparser/test/BuildCAPI.c +0 -5
  282. data/ext/libgraphqlparser/test/CMakeLists.txt +0 -25
  283. data/ext/libgraphqlparser/test/JsonVisitorTests.cpp +0 -28
  284. data/ext/libgraphqlparser/test/ParserTests.cpp +0 -352
  285. data/ext/libgraphqlparser/test/kitchen-sink.graphql +0 -59
  286. data/ext/libgraphqlparser/test/kitchen-sink.json +0 -1
  287. data/ext/libgraphqlparser/test/schema-kitchen-sink.graphql +0 -78
  288. data/ext/libgraphqlparser/test/schema-kitchen-sink.json +0 -1
  289. data/ext/libgraphqlparser/test/valgrind.supp +0 -33
  290. data/ext/version.cpp +0 -21
  291. data/lib/graphqlparser.so +0 -0
  292. data/lib/rails/graphql/native/functions.rb +0 -38
  293. data/lib/rails/graphql/native/location.rb +0 -41
  294. data/lib/rails/graphql/native/pointers.rb +0 -23
  295. data/lib/rails/graphql/native/visitor.rb +0 -349
  296. data/lib/rails/graphql/native.rb +0 -56
  297. data/test/integration/schemas/authorization.rb +0 -12
@@ -1,2633 +0,0 @@
1
- #line 1 "lexer.cpp"
2
-
3
- #line 3 "lexer.cpp"
4
-
5
- #define YY_INT_ALIGNED short int
6
-
7
- /* A lexical scanner generated by flex */
8
-
9
- #define FLEX_SCANNER
10
- #define YY_FLEX_MAJOR_VERSION 2
11
- #define YY_FLEX_MINOR_VERSION 6
12
- #define YY_FLEX_SUBMINOR_VERSION 4
13
- #if YY_FLEX_SUBMINOR_VERSION > 0
14
- #define FLEX_BETA
15
- #endif
16
-
17
- #ifdef yyget_lval
18
- #define yyget_lval_ALREADY_DEFINED
19
- #else
20
- #define yyget_lval yyget_lval
21
- #endif
22
-
23
- #ifdef yyset_lval
24
- #define yyset_lval_ALREADY_DEFINED
25
- #else
26
- #define yyset_lval yyset_lval
27
- #endif
28
-
29
- #ifdef yyget_lloc
30
- #define yyget_lloc_ALREADY_DEFINED
31
- #else
32
- #define yyget_lloc yyget_lloc
33
- #endif
34
-
35
- #ifdef yyset_lloc
36
- #define yyset_lloc_ALREADY_DEFINED
37
- #else
38
- #define yyset_lloc yyset_lloc
39
- #endif
40
-
41
- /* First, we deal with platform-specific or compiler-specific issues. */
42
-
43
- /* begin standard C headers. */
44
- #include <stdio.h>
45
- #include <string.h>
46
- #include <errno.h>
47
- #include <stdlib.h>
48
-
49
- /* end standard C headers. */
50
-
51
- /* flex integer type definitions */
52
-
53
- #ifndef FLEXINT_H
54
- #define FLEXINT_H
55
-
56
- /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
57
-
58
- #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
59
-
60
- /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
61
- * if you want the limit (max/min) macros for int types.
62
- */
63
- #ifndef __STDC_LIMIT_MACROS
64
- #define __STDC_LIMIT_MACROS 1
65
- #endif
66
-
67
- #include <inttypes.h>
68
- typedef int8_t flex_int8_t;
69
- typedef uint8_t flex_uint8_t;
70
- typedef int16_t flex_int16_t;
71
- typedef uint16_t flex_uint16_t;
72
- typedef int32_t flex_int32_t;
73
- typedef uint32_t flex_uint32_t;
74
- #else
75
- typedef signed char flex_int8_t;
76
- typedef short int flex_int16_t;
77
- typedef int flex_int32_t;
78
- typedef unsigned char flex_uint8_t;
79
- typedef unsigned short int flex_uint16_t;
80
- typedef unsigned int flex_uint32_t;
81
-
82
- /* Limits of integral types. */
83
- #ifndef INT8_MIN
84
- #define INT8_MIN (-128)
85
- #endif
86
- #ifndef INT16_MIN
87
- #define INT16_MIN (-32767-1)
88
- #endif
89
- #ifndef INT32_MIN
90
- #define INT32_MIN (-2147483647-1)
91
- #endif
92
- #ifndef INT8_MAX
93
- #define INT8_MAX (127)
94
- #endif
95
- #ifndef INT16_MAX
96
- #define INT16_MAX (32767)
97
- #endif
98
- #ifndef INT32_MAX
99
- #define INT32_MAX (2147483647)
100
- #endif
101
- #ifndef UINT8_MAX
102
- #define UINT8_MAX (255U)
103
- #endif
104
- #ifndef UINT16_MAX
105
- #define UINT16_MAX (65535U)
106
- #endif
107
- #ifndef UINT32_MAX
108
- #define UINT32_MAX (4294967295U)
109
- #endif
110
-
111
- #ifndef SIZE_MAX
112
- #define SIZE_MAX (~(size_t)0)
113
- #endif
114
-
115
- #endif /* ! C99 */
116
-
117
- #endif /* ! FLEXINT_H */
118
-
119
- /* begin standard C++ headers. */
120
-
121
- /* TODO: this is always defined, so inline it */
122
- #define yyconst const
123
-
124
- #if defined(__GNUC__) && __GNUC__ >= 3
125
- #define yynoreturn __attribute__((__noreturn__))
126
- #else
127
- #define yynoreturn
128
- #endif
129
-
130
- /* Returned upon end-of-file. */
131
- #define YY_NULL 0
132
-
133
- /* Promotes a possibly negative, possibly signed char to an
134
- * integer in range [0..255] for use as an array index.
135
- */
136
- #define YY_SC_TO_UI(c) ((YY_CHAR) (c))
137
-
138
- /* An opaque pointer. */
139
- #ifndef YY_TYPEDEF_YY_SCANNER_T
140
- #define YY_TYPEDEF_YY_SCANNER_T
141
- typedef void* yyscan_t;
142
- #endif
143
-
144
- /* For convenience, these vars (plus the bison vars far below)
145
- are macros in the reentrant scanner. */
146
- #define yyin yyg->yyin_r
147
- #define yyout yyg->yyout_r
148
- #define yyextra yyg->yyextra_r
149
- #define yyleng yyg->yyleng_r
150
- #define yytext yyg->yytext_r
151
- #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
152
- #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
153
- #define yy_flex_debug yyg->yy_flex_debug_r
154
-
155
- /* Enter a start condition. This macro really ought to take a parameter,
156
- * but we do it the disgusting crufty way forced on us by the ()-less
157
- * definition of BEGIN.
158
- */
159
- #define BEGIN yyg->yy_start = 1 + 2 *
160
- /* Translate the current start state into a value that can be later handed
161
- * to BEGIN to return to the state. The YYSTATE alias is for lex
162
- * compatibility.
163
- */
164
- #define YY_START ((yyg->yy_start - 1) / 2)
165
- #define YYSTATE YY_START
166
- /* Action number for EOF rule of a given start state. */
167
- #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
168
- /* Special action meaning "start processing a new file". */
169
- #define YY_NEW_FILE yyrestart( yyin , yyscanner )
170
- #define YY_END_OF_BUFFER_CHAR 0
171
-
172
- /* Size of default input buffer. */
173
- #ifndef YY_BUF_SIZE
174
- #ifdef __ia64__
175
- /* On IA-64, the buffer size is 16k, not 8k.
176
- * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
177
- * Ditto for the __ia64__ case accordingly.
178
- */
179
- #define YY_BUF_SIZE 32768
180
- #else
181
- #define YY_BUF_SIZE 16384
182
- #endif /* __ia64__ */
183
- #endif
184
-
185
- /* The state buf must be large enough to hold one state per character in the main buffer.
186
- */
187
- #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
188
-
189
- #ifndef YY_TYPEDEF_YY_BUFFER_STATE
190
- #define YY_TYPEDEF_YY_BUFFER_STATE
191
- typedef struct yy_buffer_state *YY_BUFFER_STATE;
192
- #endif
193
-
194
- #ifndef YY_TYPEDEF_YY_SIZE_T
195
- #define YY_TYPEDEF_YY_SIZE_T
196
- typedef size_t yy_size_t;
197
- #endif
198
-
199
- #define EOB_ACT_CONTINUE_SCAN 0
200
- #define EOB_ACT_END_OF_FILE 1
201
- #define EOB_ACT_LAST_MATCH 2
202
-
203
- #define YY_LESS_LINENO(n)
204
- #define YY_LINENO_REWIND_TO(ptr)
205
-
206
- /* Return all but the first "n" matched characters back to the input stream. */
207
- #define yyless(n) \
208
- do \
209
- { \
210
- /* Undo effects of setting up yytext. */ \
211
- int yyless_macro_arg = (n); \
212
- YY_LESS_LINENO(yyless_macro_arg);\
213
- *yy_cp = yyg->yy_hold_char; \
214
- YY_RESTORE_YY_MORE_OFFSET \
215
- yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
216
- YY_DO_BEFORE_ACTION; /* set up yytext again */ \
217
- } \
218
- while ( 0 )
219
- #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
220
-
221
- #ifndef YY_STRUCT_YY_BUFFER_STATE
222
- #define YY_STRUCT_YY_BUFFER_STATE
223
- struct yy_buffer_state
224
- {
225
- FILE *yy_input_file;
226
-
227
- char *yy_ch_buf; /* input buffer */
228
- char *yy_buf_pos; /* current position in input buffer */
229
-
230
- /* Size of input buffer in bytes, not including room for EOB
231
- * characters.
232
- */
233
- int yy_buf_size;
234
-
235
- /* Number of characters read into yy_ch_buf, not including EOB
236
- * characters.
237
- */
238
- int yy_n_chars;
239
-
240
- /* Whether we "own" the buffer - i.e., we know we created it,
241
- * and can realloc() it to grow it, and should free() it to
242
- * delete it.
243
- */
244
- int yy_is_our_buffer;
245
-
246
- /* Whether this is an "interactive" input source; if so, and
247
- * if we're using stdio for input, then we want to use getc()
248
- * instead of fread(), to make sure we stop fetching input after
249
- * each newline.
250
- */
251
- int yy_is_interactive;
252
-
253
- /* Whether we're considered to be at the beginning of a line.
254
- * If so, '^' rules will be active on the next match, otherwise
255
- * not.
256
- */
257
- int yy_at_bol;
258
-
259
- int yy_bs_lineno; /**< The line count. */
260
- int yy_bs_column; /**< The column count. */
261
-
262
- /* Whether to try to fill the input buffer when we reach the
263
- * end of it.
264
- */
265
- int yy_fill_buffer;
266
-
267
- int yy_buffer_status;
268
-
269
- #define YY_BUFFER_NEW 0
270
- #define YY_BUFFER_NORMAL 1
271
- /* When an EOF's been seen but there's still some text to process
272
- * then we mark the buffer as YY_EOF_PENDING, to indicate that we
273
- * shouldn't try reading from the input source any more. We might
274
- * still have a bunch of tokens to match, though, because of
275
- * possible backing-up.
276
- *
277
- * When we actually see the EOF, we change the status to "new"
278
- * (via yyrestart()), so that the user can continue scanning by
279
- * just pointing yyin at a new input file.
280
- */
281
- #define YY_BUFFER_EOF_PENDING 2
282
-
283
- };
284
- #endif /* !YY_STRUCT_YY_BUFFER_STATE */
285
-
286
- /* We provide macros for accessing buffer states in case in the
287
- * future we want to put the buffer states in a more general
288
- * "scanner state".
289
- *
290
- * Returns the top of the stack, or NULL.
291
- */
292
- #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
293
- ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
294
- : NULL)
295
- /* Same as previous macro, but useful when we know that the buffer stack is not
296
- * NULL or when we need an lvalue. For internal use only.
297
- */
298
- #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
299
-
300
- void yyrestart ( FILE *input_file , yyscan_t yyscanner );
301
- void yy_switch_to_buffer ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
302
- YY_BUFFER_STATE yy_create_buffer ( FILE *file, int size , yyscan_t yyscanner );
303
- void yy_delete_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
304
- void yy_flush_buffer ( YY_BUFFER_STATE b , yyscan_t yyscanner );
305
- void yypush_buffer_state ( YY_BUFFER_STATE new_buffer , yyscan_t yyscanner );
306
- void yypop_buffer_state ( yyscan_t yyscanner );
307
-
308
- static void yyensure_buffer_stack ( yyscan_t yyscanner );
309
- static void yy_load_buffer_state ( yyscan_t yyscanner );
310
- static void yy_init_buffer ( YY_BUFFER_STATE b, FILE *file , yyscan_t yyscanner );
311
- #define YY_FLUSH_BUFFER yy_flush_buffer( YY_CURRENT_BUFFER , yyscanner)
312
-
313
- YY_BUFFER_STATE yy_scan_buffer ( char *base, yy_size_t size , yyscan_t yyscanner );
314
- YY_BUFFER_STATE yy_scan_string ( const char *yy_str , yyscan_t yyscanner );
315
- YY_BUFFER_STATE yy_scan_bytes ( const char *bytes, int len , yyscan_t yyscanner );
316
-
317
- void *yyalloc ( yy_size_t , yyscan_t yyscanner );
318
- void *yyrealloc ( void *, yy_size_t , yyscan_t yyscanner );
319
- void yyfree ( void * , yyscan_t yyscanner );
320
-
321
- #define yy_new_buffer yy_create_buffer
322
- #define yy_set_interactive(is_interactive) \
323
- { \
324
- if ( ! YY_CURRENT_BUFFER ){ \
325
- yyensure_buffer_stack (yyscanner); \
326
- YY_CURRENT_BUFFER_LVALUE = \
327
- yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
328
- } \
329
- YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
330
- }
331
- #define yy_set_bol(at_bol) \
332
- { \
333
- if ( ! YY_CURRENT_BUFFER ){\
334
- yyensure_buffer_stack (yyscanner); \
335
- YY_CURRENT_BUFFER_LVALUE = \
336
- yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner); \
337
- } \
338
- YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
339
- }
340
- #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
341
-
342
- /* Begin user sect3 */
343
-
344
- #define yywrap(yyscanner) (/*CONSTCOND*/1)
345
- #define YY_SKIP_YYWRAP
346
- typedef flex_uint8_t YY_CHAR;
347
-
348
- typedef int yy_state_type;
349
-
350
- #define yytext_ptr yytext_r
351
-
352
- static yy_state_type yy_get_previous_state ( yyscan_t yyscanner );
353
- static yy_state_type yy_try_NUL_trans ( yy_state_type current_state , yyscan_t yyscanner);
354
- static int yy_get_next_buffer ( yyscan_t yyscanner );
355
- static void yynoreturn yy_fatal_error ( const char* msg , yyscan_t yyscanner );
356
-
357
- /* Done after the current pattern has been matched and before the
358
- * corresponding action - sets up yytext.
359
- */
360
- #define YY_DO_BEFORE_ACTION \
361
- yyg->yytext_ptr = yy_bp; \
362
- yyleng = (int) (yy_cp - yy_bp); \
363
- yyg->yy_hold_char = *yy_cp; \
364
- *yy_cp = '\0'; \
365
- yyg->yy_c_buf_p = yy_cp;
366
- #define YY_NUM_RULES 64
367
- #define YY_END_OF_BUFFER 65
368
- /* This struct is not used in this scanner,
369
- but its presence is necessary. */
370
- struct yy_trans_info
371
- {
372
- flex_int32_t yy_verify;
373
- flex_int32_t yy_nxt;
374
- };
375
- static const flex_int16_t yy_accept[196] =
376
- { 0,
377
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
378
- 65, 63, 22, 25, 25, 49, 62, 26, 63, 50,
379
- 51, 63, 63, 45, 45, 53, 54, 55, 47, 56,
380
- 57, 47, 47, 47, 47, 47, 47, 47, 47, 47,
381
- 47, 47, 58, 59, 60, 63, 2, 2, 3, 1,
382
- 63, 15, 16, 16, 16, 64, 21, 20, 20, 22,
383
- 25, 24, 0, 48, 45, 45, 0, 0, 0, 45,
384
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
385
- 37, 47, 47, 47, 47, 47, 47, 0, 3, 14,
386
- 4, 6, 5, 10, 11, 7, 9, 8, 13, 0,
387
-
388
- 0, 21, 19, 25, 61, 52, 46, 0, 46, 47,
389
- 47, 47, 47, 47, 47, 47, 47, 47, 47, 47,
390
- 47, 47, 47, 47, 47, 47, 23, 0, 18, 0,
391
- 47, 28, 47, 47, 47, 47, 47, 47, 47, 36,
392
- 47, 47, 47, 47, 42, 43, 47, 0, 0, 17,
393
- 47, 47, 30, 47, 47, 33, 47, 47, 38, 47,
394
- 47, 47, 44, 0, 47, 29, 47, 47, 47, 47,
395
- 39, 40, 47, 12, 47, 47, 47, 47, 47, 47,
396
- 47, 31, 47, 47, 35, 47, 27, 47, 34, 47,
397
- 32, 47, 47, 41, 0
398
-
399
- } ;
400
-
401
- static const YY_CHAR yy_ec[256] =
402
- { 0,
403
- 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
404
- 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
405
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406
- 1, 5, 6, 7, 8, 9, 10, 10, 10, 11,
407
- 12, 10, 13, 5, 14, 15, 16, 17, 18, 18,
408
- 18, 18, 18, 18, 18, 18, 18, 19, 10, 10,
409
- 20, 10, 10, 21, 22, 22, 22, 22, 23, 22,
410
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
411
- 24, 24, 24, 24, 24, 24, 24, 24, 24, 24,
412
- 25, 26, 27, 10, 24, 10, 28, 29, 30, 31,
413
-
414
- 32, 33, 34, 35, 36, 24, 24, 37, 38, 39,
415
- 40, 41, 42, 43, 44, 45, 46, 47, 24, 48,
416
- 49, 24, 50, 51, 52, 10, 10, 10, 10, 10,
417
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
418
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
419
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
420
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
421
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
422
- 10, 10, 10, 10, 10, 10, 53, 10, 10, 10,
423
- 54, 10, 10, 10, 10, 10, 10, 10, 10, 10,
424
-
425
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
426
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
427
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
428
- 10, 10, 10, 10, 10, 10, 10, 10, 55, 10,
429
- 10, 10, 10, 10, 10, 10, 10, 10, 10, 10,
430
- 10, 10, 10, 10, 10
431
- } ;
432
-
433
- static const YY_CHAR yy_meta[56] =
434
- { 0,
435
- 1, 1, 2, 3, 4, 4, 1, 4, 4, 4,
436
- 4, 4, 4, 4, 4, 4, 5, 5, 4, 4,
437
- 4, 5, 5, 6, 4, 1, 4, 5, 5, 5,
438
- 5, 5, 5, 6, 6, 6, 6, 6, 6, 6,
439
- 6, 6, 6, 6, 6, 6, 6, 6, 6, 4,
440
- 4, 4, 4, 4, 4
441
- } ;
442
-
443
- static const flex_int16_t yy_base[209] =
444
- { 0,
445
- 0, 0, 55, 62, 60, 67, 0, 0, 67, 69,
446
- 288, 289, 73, 73, 76, 289, 280, 289, 0, 289,
447
- 289, 65, 271, 69, 72, 289, 289, 289, 0, 289,
448
- 289, 249, 46, 63, 58, 238, 237, 243, 235, 68,
449
- 56, 241, 289, 289, 289, 226, 289, 289, 0, 289,
450
- 108, 289, 289, 271, 270, 289, 0, 289, 273, 98,
451
- 104, 106, 268, 0, 96, 103, 259, 95, 125, 140,
452
- 0, 230, 226, 226, 233, 241, 227, 82, 222, 229,
453
- 0, 233, 94, 235, 217, 221, 225, 206, 0, 289,
454
- 289, 289, 289, 289, 289, 289, 289, 289, 0, 252,
455
-
456
- 251, 0, 289, 113, 289, 289, 113, 115, 131, 225,
457
- 218, 223, 210, 219, 215, 205, 218, 221, 211, 204,
458
- 209, 213, 200, 211, 210, 201, 185, 0, 289, 232,
459
- 208, 0, 198, 204, 197, 202, 188, 189, 186, 0,
460
- 181, 201, 190, 197, 0, 0, 187, 172, 0, 289,
461
- 179, 192, 0, 190, 183, 0, 187, 183, 0, 175,
462
- 189, 173, 0, 0, 176, 0, 172, 173, 143, 130,
463
- 0, 0, 133, 289, 121, 122, 127, 135, 125, 121,
464
- 129, 0, 115, 127, 0, 111, 0, 108, 0, 114,
465
- 0, 106, 105, 0, 289, 172, 178, 184, 190, 192,
466
-
467
- 194, 197, 203, 209, 135, 120, 97, 55
468
- } ;
469
-
470
- static const flex_int16_t yy_def[209] =
471
- { 0,
472
- 195, 1, 196, 196, 197, 197, 198, 198, 199, 199,
473
- 195, 195, 195, 195, 195, 195, 195, 195, 200, 195,
474
- 195, 195, 195, 195, 195, 195, 195, 195, 201, 195,
475
- 195, 201, 201, 201, 201, 201, 201, 201, 201, 201,
476
- 201, 201, 195, 195, 195, 195, 195, 195, 202, 195,
477
- 203, 195, 195, 195, 195, 195, 204, 195, 195, 195,
478
- 195, 195, 195, 200, 195, 195, 195, 195, 195, 195,
479
- 201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
480
- 201, 201, 201, 201, 201, 201, 201, 195, 202, 195,
481
- 195, 195, 195, 195, 195, 195, 195, 195, 205, 195,
482
-
483
- 195, 204, 195, 195, 195, 195, 195, 195, 195, 201,
484
- 201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
485
- 201, 201, 201, 201, 201, 201, 195, 206, 195, 195,
486
- 201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
487
- 201, 201, 201, 201, 201, 201, 201, 195, 207, 195,
488
- 201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
489
- 201, 201, 201, 208, 201, 201, 201, 201, 201, 201,
490
- 201, 201, 201, 195, 201, 201, 201, 201, 201, 201,
491
- 201, 201, 201, 201, 201, 201, 201, 201, 201, 201,
492
- 201, 201, 201, 201, 0, 195, 195, 195, 195, 195,
493
-
494
- 195, 195, 195, 195, 195, 195, 195, 195
495
- } ;
496
-
497
- static const flex_int16_t yy_nxt[345] =
498
- { 0,
499
- 12, 13, 14, 15, 13, 16, 17, 18, 19, 12,
500
- 20, 21, 12, 22, 23, 12, 24, 25, 26, 27,
501
- 28, 29, 29, 29, 30, 12, 31, 29, 29, 29,
502
- 32, 33, 34, 29, 29, 35, 29, 36, 37, 38,
503
- 29, 39, 29, 40, 41, 42, 29, 29, 29, 43,
504
- 44, 45, 12, 12, 46, 12, 12, 47, 48, 174,
505
- 52, 50, 12, 12, 47, 48, 54, 52, 50, 58,
506
- 59, 58, 59, 54, 60, 61, 61, 60, 62, 61,
507
- 51, 65, 66, 68, 73, 55, 68, 51, 70, 70,
508
- 75, 69, 55, 74, 69, 77, 78, 83, 85, 60,
509
-
510
- 69, 164, 60, 69, 86, 76, 61, 61, 61, 104,
511
- 68, 107, 107, 84, 91, 62, 61, 68, 69, 70,
512
- 70, 121, 116, 92, 149, 69, 117, 69, 122, 107,
513
- 107, 109, 109, 93, 69, 69, 94, 108, 108, 128,
514
- 95, 109, 109, 194, 69, 193, 96, 109, 109, 192,
515
- 97, 191, 98, 99, 68, 190, 70, 70, 189, 188,
516
- 187, 186, 69, 185, 184, 183, 182, 181, 180, 179,
517
- 178, 69, 49, 49, 49, 49, 49, 49, 53, 53,
518
- 53, 53, 53, 53, 56, 56, 56, 56, 56, 56,
519
- 57, 57, 57, 57, 57, 57, 64, 64, 71, 71,
520
-
521
- 89, 89, 89, 90, 177, 90, 90, 90, 90, 102,
522
- 176, 175, 102, 102, 102, 173, 172, 171, 170, 169,
523
- 168, 167, 166, 165, 88, 163, 162, 161, 160, 159,
524
- 158, 157, 156, 155, 154, 153, 152, 151, 150, 148,
525
- 147, 146, 145, 144, 143, 142, 141, 140, 139, 138,
526
- 137, 136, 135, 134, 133, 132, 131, 130, 129, 127,
527
- 126, 125, 124, 123, 120, 119, 118, 115, 114, 113,
528
- 112, 111, 110, 106, 105, 103, 101, 100, 88, 87,
529
- 82, 81, 80, 79, 72, 67, 63, 195, 11, 195,
530
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
531
-
532
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
533
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
534
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
535
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
536
- 195, 195, 195, 195
537
- } ;
538
-
539
- static const flex_int16_t yy_chk[345] =
540
- { 0,
541
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
542
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
543
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
544
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
545
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
546
- 1, 1, 1, 1, 1, 3, 3, 3, 3, 208,
547
- 5, 3, 4, 4, 4, 4, 5, 6, 4, 9,
548
- 9, 10, 10, 6, 13, 14, 14, 13, 15, 15,
549
- 3, 22, 22, 24, 33, 5, 25, 4, 25, 25,
550
- 34, 24, 6, 33, 25, 35, 35, 40, 41, 60,
551
-
552
- 24, 207, 60, 25, 41, 34, 61, 61, 62, 62,
553
- 65, 68, 68, 40, 51, 104, 104, 66, 65, 66,
554
- 66, 83, 78, 51, 206, 66, 78, 65, 83, 107,
555
- 107, 108, 108, 51, 66, 107, 51, 69, 69, 205,
556
- 51, 69, 69, 193, 107, 192, 51, 109, 109, 190,
557
- 51, 188, 51, 51, 70, 186, 70, 70, 184, 183,
558
- 181, 180, 70, 179, 178, 177, 176, 175, 173, 170,
559
- 169, 70, 196, 196, 196, 196, 196, 196, 197, 197,
560
- 197, 197, 197, 197, 198, 198, 198, 198, 198, 198,
561
- 199, 199, 199, 199, 199, 199, 200, 200, 201, 201,
562
-
563
- 202, 202, 202, 203, 168, 203, 203, 203, 203, 204,
564
- 167, 165, 204, 204, 204, 162, 161, 160, 158, 157,
565
- 155, 154, 152, 151, 148, 147, 144, 143, 142, 141,
566
- 139, 138, 137, 136, 135, 134, 133, 131, 130, 127,
567
- 126, 125, 124, 123, 122, 121, 120, 119, 118, 117,
568
- 116, 115, 114, 113, 112, 111, 110, 101, 100, 88,
569
- 87, 86, 85, 84, 82, 80, 79, 77, 76, 75,
570
- 74, 73, 72, 67, 63, 59, 55, 54, 46, 42,
571
- 39, 38, 37, 36, 32, 23, 17, 11, 195, 195,
572
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
573
-
574
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
575
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
576
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
577
- 195, 195, 195, 195, 195, 195, 195, 195, 195, 195,
578
- 195, 195, 195, 195
579
- } ;
580
-
581
- /* The intent behind this definition is that it'll catch
582
- * any uses of REJECT which flex missed.
583
- */
584
- #define REJECT reject_used_but_not_detected
585
- #define yymore() yymore_used_but_not_detected
586
- #define YY_MORE_ADJ 0
587
- #define YY_RESTORE_YY_MORE_OFFSET
588
- #line 1 "lexer.lpp"
589
- /**
590
- * Copyright 2019-present, GraphQL Foundation
591
- *
592
- * This source code is licensed under the MIT license found in the
593
- * LICENSE file in the root directory of this source tree.
594
- */
595
- #line 9 "lexer.lpp"
596
- #include <algorithm>
597
- #include <cassert>
598
- #include <cctype>
599
- #include <climits>
600
- #include <cstdio>
601
- #include <string>
602
- #include <vector>
603
- #include "location.hh"
604
- #include "position.hh"
605
- #include "parser.tab.hpp"
606
- #include "syntaxdefs.h"
607
-
608
- // Keep track of token lengths.
609
- #define YY_USER_ACTION yyextra->loc.columns(yyleng);
610
-
611
- static void escape(char c, char *buf);
612
-
613
- static std::string clean_up_block_string(const std::string &str);
614
-
615
- #line 615 "lexer.cpp"
616
- #define YY_NO_INPUT 1
617
-
618
- #line 618 "lexer.cpp"
619
-
620
- #define INITIAL 0
621
- #define STRING_STATE 1
622
- #define BLOCK_STRING_STATE 2
623
- #define C_COMMENT_STATE 3
624
- #define LINE_COMMENT_STATE 4
625
-
626
- #ifndef YY_NO_UNISTD_H
627
- /* Special case for "unistd.h", since it is non-ANSI. We include it way
628
- * down here because we want the user's section 1 to have been scanned first.
629
- * The user has a chance to override it with an option.
630
- */
631
- #include <unistd.h>
632
- #endif
633
-
634
- #define YY_EXTRA_TYPE struct LexerExtra *
635
-
636
- /* Holds the entire state of the reentrant scanner. */
637
- struct yyguts_t
638
- {
639
-
640
- /* User-defined. Not touched by flex. */
641
- YY_EXTRA_TYPE yyextra_r;
642
-
643
- /* The rest are the same as the globals declared in the non-reentrant scanner. */
644
- FILE *yyin_r, *yyout_r;
645
- size_t yy_buffer_stack_top; /**< index of top of stack. */
646
- size_t yy_buffer_stack_max; /**< capacity of stack. */
647
- YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
648
- char yy_hold_char;
649
- int yy_n_chars;
650
- int yyleng_r;
651
- char *yy_c_buf_p;
652
- int yy_init;
653
- int yy_start;
654
- int yy_did_buffer_switch_on_eof;
655
- int yy_start_stack_ptr;
656
- int yy_start_stack_depth;
657
- int *yy_start_stack;
658
- yy_state_type yy_last_accepting_state;
659
- char* yy_last_accepting_cpos;
660
-
661
- int yylineno_r;
662
- int yy_flex_debug_r;
663
-
664
- char *yytext_r;
665
- int yy_more_flag;
666
- int yy_more_len;
667
-
668
- YYSTYPE * yylval_r;
669
-
670
- YYLTYPE * yylloc_r;
671
-
672
- }; /* end struct yyguts_t */
673
-
674
- static int yy_init_globals ( yyscan_t yyscanner );
675
-
676
- /* This must go here because YYSTYPE and YYLTYPE are included
677
- * from bison output in section 1.*/
678
- # define yylval yyg->yylval_r
679
-
680
- # define yylloc yyg->yylloc_r
681
-
682
- int yylex_init (yyscan_t* scanner);
683
-
684
- int yylex_init_extra ( YY_EXTRA_TYPE user_defined, yyscan_t* scanner);
685
-
686
- /* Accessor methods to globals.
687
- These are made visible to non-reentrant scanners for convenience. */
688
-
689
- int yylex_destroy ( yyscan_t yyscanner );
690
-
691
- int yyget_debug ( yyscan_t yyscanner );
692
-
693
- void yyset_debug ( int debug_flag , yyscan_t yyscanner );
694
-
695
- YY_EXTRA_TYPE yyget_extra ( yyscan_t yyscanner );
696
-
697
- void yyset_extra ( YY_EXTRA_TYPE user_defined , yyscan_t yyscanner );
698
-
699
- FILE *yyget_in ( yyscan_t yyscanner );
700
-
701
- void yyset_in ( FILE * _in_str , yyscan_t yyscanner );
702
-
703
- FILE *yyget_out ( yyscan_t yyscanner );
704
-
705
- void yyset_out ( FILE * _out_str , yyscan_t yyscanner );
706
-
707
- int yyget_leng ( yyscan_t yyscanner );
708
-
709
- char *yyget_text ( yyscan_t yyscanner );
710
-
711
- int yyget_lineno ( yyscan_t yyscanner );
712
-
713
- void yyset_lineno ( int _line_number , yyscan_t yyscanner );
714
-
715
- int yyget_column ( yyscan_t yyscanner );
716
-
717
- void yyset_column ( int _column_no , yyscan_t yyscanner );
718
-
719
- YYSTYPE * yyget_lval ( yyscan_t yyscanner );
720
-
721
- void yyset_lval ( YYSTYPE * yylval_param , yyscan_t yyscanner );
722
-
723
- YYLTYPE *yyget_lloc ( yyscan_t yyscanner );
724
-
725
- void yyset_lloc ( YYLTYPE * yylloc_param , yyscan_t yyscanner );
726
-
727
- /* Macros after this point can all be overridden by user definitions in
728
- * section 1.
729
- */
730
-
731
- #ifndef YY_SKIP_YYWRAP
732
- #ifdef __cplusplus
733
- extern "C" int yywrap ( yyscan_t yyscanner );
734
- #else
735
- extern int yywrap ( yyscan_t yyscanner );
736
- #endif
737
- #endif
738
-
739
- #ifndef YY_NO_UNPUT
740
-
741
- #endif
742
-
743
- #ifndef yytext_ptr
744
- static void yy_flex_strncpy ( char *, const char *, int , yyscan_t yyscanner);
745
- #endif
746
-
747
- #ifdef YY_NEED_STRLEN
748
- static int yy_flex_strlen ( const char * , yyscan_t yyscanner);
749
- #endif
750
-
751
- #ifndef YY_NO_INPUT
752
- #ifdef __cplusplus
753
- static int yyinput ( yyscan_t yyscanner );
754
- #else
755
- static int input ( yyscan_t yyscanner );
756
- #endif
757
-
758
- #endif
759
-
760
- /* Amount of stuff to slurp up with each read. */
761
- #ifndef YY_READ_BUF_SIZE
762
- #ifdef __ia64__
763
- /* On IA-64, the buffer size is 16k, not 8k */
764
- #define YY_READ_BUF_SIZE 16384
765
- #else
766
- #define YY_READ_BUF_SIZE 8192
767
- #endif /* __ia64__ */
768
- #endif
769
-
770
- /* Copy whatever the last rule matched to the standard output. */
771
- #ifndef ECHO
772
- /* This used to be an fputs(), but since the string might contain NUL's,
773
- * we now use fwrite().
774
- */
775
- #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
776
- #endif
777
-
778
- /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
779
- * is returned in "result".
780
- */
781
- #ifndef YY_INPUT
782
- #define YY_INPUT(buf,result,max_size) \
783
- if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
784
- { \
785
- int c = '*'; \
786
- int n; \
787
- for ( n = 0; n < max_size && \
788
- (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
789
- buf[n] = (char) c; \
790
- if ( c == '\n' ) \
791
- buf[n++] = (char) c; \
792
- if ( c == EOF && ferror( yyin ) ) \
793
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
794
- result = n; \
795
- } \
796
- else \
797
- { \
798
- errno=0; \
799
- while ( (result = (int) fread(buf, 1, (yy_size_t) max_size, yyin)) == 0 && ferror(yyin)) \
800
- { \
801
- if( errno != EINTR) \
802
- { \
803
- YY_FATAL_ERROR( "input in flex scanner failed" ); \
804
- break; \
805
- } \
806
- errno=0; \
807
- clearerr(yyin); \
808
- } \
809
- }\
810
- \
811
-
812
- #endif
813
-
814
- /* No semi-colon after return; correct usage is to write "yyterminate();" -
815
- * we don't want an extra ';' after the "return" because that will cause
816
- * some compilers to complain about unreachable statements.
817
- */
818
- #ifndef yyterminate
819
- #define yyterminate() return YY_NULL
820
- #endif
821
-
822
- /* Number of entries by which start-condition stack grows. */
823
- #ifndef YY_START_STACK_INCR
824
- #define YY_START_STACK_INCR 25
825
- #endif
826
-
827
- /* Report a fatal error. */
828
- #ifndef YY_FATAL_ERROR
829
- #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
830
- #endif
831
-
832
- /* end tables serialization structures and prototypes */
833
-
834
- /* Default declaration of generated scanner - a define so the user can
835
- * easily add parameters.
836
- */
837
- #ifndef YY_DECL
838
- #define YY_DECL_IS_OURS 1
839
-
840
- extern int yylex \
841
- (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner);
842
-
843
- #define YY_DECL int yylex \
844
- (YYSTYPE * yylval_param, YYLTYPE * yylloc_param , yyscan_t yyscanner)
845
- #endif /* !YY_DECL */
846
-
847
- /* Code executed at the beginning of each rule, after yytext and yyleng
848
- * have been set up.
849
- */
850
- #ifndef YY_USER_ACTION
851
- #define YY_USER_ACTION
852
- #endif
853
-
854
- /* Code executed at the end of each rule. */
855
- #ifndef YY_BREAK
856
- #define YY_BREAK /*LINTED*/break;
857
- #endif
858
-
859
- #define YY_RULE_SETUP \
860
- YY_USER_ACTION
861
-
862
- /** The main scanner function which does all the work.
863
- */
864
- YY_DECL
865
- {
866
- yy_state_type yy_current_state;
867
- char *yy_cp, *yy_bp;
868
- int yy_act;
869
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
870
-
871
- yylval = yylval_param;
872
-
873
- yylloc = yylloc_param;
874
-
875
- if ( !yyg->yy_init )
876
- {
877
- yyg->yy_init = 1;
878
-
879
- #ifdef YY_USER_INIT
880
- YY_USER_INIT;
881
- #endif
882
-
883
- if ( ! yyg->yy_start )
884
- yyg->yy_start = 1; /* first start state */
885
-
886
- if ( ! yyin )
887
- yyin = stdin;
888
-
889
- if ( ! yyout )
890
- yyout = stdout;
891
-
892
- if ( ! YY_CURRENT_BUFFER ) {
893
- yyensure_buffer_stack (yyscanner);
894
- YY_CURRENT_BUFFER_LVALUE =
895
- yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
896
- }
897
-
898
- yy_load_buffer_state( yyscanner );
899
- }
900
-
901
- {
902
- #line 54 "lexer.lpp"
903
-
904
-
905
-
906
- #line 58 "lexer.lpp"
907
- yyextra->loc.step();
908
-
909
-
910
- #line 910 "lexer.cpp"
911
-
912
- while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
913
- {
914
- yy_cp = yyg->yy_c_buf_p;
915
-
916
- /* Support of yytext. */
917
- *yy_cp = yyg->yy_hold_char;
918
-
919
- /* yy_bp points to the position in yy_ch_buf of the start of
920
- * the current run.
921
- */
922
- yy_bp = yy_cp;
923
-
924
- yy_current_state = yyg->yy_start;
925
- yy_match:
926
- do
927
- {
928
- YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
929
- if ( yy_accept[yy_current_state] )
930
- {
931
- yyg->yy_last_accepting_state = yy_current_state;
932
- yyg->yy_last_accepting_cpos = yy_cp;
933
- }
934
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
935
- {
936
- yy_current_state = (int) yy_def[yy_current_state];
937
- if ( yy_current_state >= 196 )
938
- yy_c = yy_meta[yy_c];
939
- }
940
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
941
- ++yy_cp;
942
- }
943
- while ( yy_current_state != 195 );
944
- yy_cp = yyg->yy_last_accepting_cpos;
945
- yy_current_state = yyg->yy_last_accepting_state;
946
-
947
- yy_find_action:
948
- yy_act = yy_accept[yy_current_state];
949
-
950
- YY_DO_BEFORE_ACTION;
951
-
952
- do_action: /* This label is used only to access EOF actions. */
953
-
954
- switch ( yy_act )
955
- { /* beginning of action switch */
956
- case 0: /* must back up */
957
- /* undo the effects of YY_DO_BEFORE_ACTION */
958
- *yy_cp = yyg->yy_hold_char;
959
- yy_cp = yyg->yy_last_accepting_cpos;
960
- yy_current_state = yyg->yy_last_accepting_state;
961
- goto yy_find_action;
962
-
963
- case 1:
964
- YY_RULE_SETUP
965
- #line 62 "lexer.lpp"
966
- {
967
- BEGIN(INITIAL);
968
- yylval->str = yyextra->str.c_str();
969
- *yylloc = yyextra->loc;
970
- return yy::GraphQLParserImpl::token::TOK_STRING;
971
- }
972
- YY_BREAK
973
- case 2:
974
- /* rule 2 can match eol */
975
- YY_RULE_SETUP
976
- #line 69 "lexer.lpp"
977
- {
978
- throw make_error(yyextra->loc, "Unterminated string");
979
- }
980
- YY_BREAK
981
- case YY_STATE_EOF(STRING_STATE):
982
- #line 73 "lexer.lpp"
983
- {
984
- throw make_error(yyextra->loc, "Unterminated string at EOF");
985
- }
986
- YY_BREAK
987
- case 3:
988
- YY_RULE_SETUP
989
- #line 77 "lexer.lpp"
990
- {
991
- char *p = yytext;
992
- while (*p) {
993
- yyextra->str.push_back(*p++);
994
- }
995
- }
996
- YY_BREAK
997
- case 4:
998
- YY_RULE_SETUP
999
- #line 84 "lexer.lpp"
1000
- { yyextra->str.push_back('"'); }
1001
- YY_BREAK
1002
- case 5:
1003
- YY_RULE_SETUP
1004
- #line 85 "lexer.lpp"
1005
- { yyextra->str.push_back('\\'); }
1006
- YY_BREAK
1007
- case 6:
1008
- YY_RULE_SETUP
1009
- #line 86 "lexer.lpp"
1010
- { yyextra->str.push_back('/'); }
1011
- YY_BREAK
1012
- case 7:
1013
- YY_RULE_SETUP
1014
- #line 87 "lexer.lpp"
1015
- { yyextra->str.push_back('\n'); }
1016
- YY_BREAK
1017
- case 8:
1018
- YY_RULE_SETUP
1019
- #line 88 "lexer.lpp"
1020
- { yyextra->str.push_back('\t'); }
1021
- YY_BREAK
1022
- case 9:
1023
- YY_RULE_SETUP
1024
- #line 89 "lexer.lpp"
1025
- { yyextra->str.push_back('\r'); }
1026
- YY_BREAK
1027
- case 10:
1028
- YY_RULE_SETUP
1029
- #line 90 "lexer.lpp"
1030
- { yyextra->str.push_back('\b'); }
1031
- YY_BREAK
1032
- case 11:
1033
- YY_RULE_SETUP
1034
- #line 91 "lexer.lpp"
1035
- { yyextra->str.push_back('\f'); }
1036
- YY_BREAK
1037
- case 12:
1038
- YY_RULE_SETUP
1039
- #line 93 "lexer.lpp"
1040
- {
1041
- int ch;
1042
- sscanf(yytext + 2, "%x", &ch);
1043
- yyextra->str.push_back(ch);
1044
- }
1045
- YY_BREAK
1046
- case 13:
1047
- YY_RULE_SETUP
1048
- #line 99 "lexer.lpp"
1049
- { throw make_error(yyextra->loc, "bad Unicode escape sequence"); }
1050
- YY_BREAK
1051
- case 14:
1052
- YY_RULE_SETUP
1053
- #line 100 "lexer.lpp"
1054
- { throw make_error(yyextra->loc, std::string("bad escape sequence \\") + yytext[1]); }
1055
- YY_BREAK
1056
-
1057
-
1058
- case YY_STATE_EOF(BLOCK_STRING_STATE):
1059
- #line 105 "lexer.lpp"
1060
- {
1061
- throw make_error(yyextra->loc, "Unterminated block string at EOF");
1062
- }
1063
- YY_BREAK
1064
- case 15:
1065
- YY_RULE_SETUP
1066
- #line 109 "lexer.lpp"
1067
- {
1068
- throw make_error(yyextra->loc, std::string("Invalid character ") + yytext[0]);
1069
- }
1070
- YY_BREAK
1071
- case 16:
1072
- /* rule 16 can match eol */
1073
- YY_RULE_SETUP
1074
- #line 113 "lexer.lpp"
1075
- {
1076
- /* Can't use {GOODCHAR}+ because that would be a better match for
1077
- """ than the explicit rule! */
1078
- yyextra->str.push_back(*yytext);
1079
- }
1080
- YY_BREAK
1081
- case 17:
1082
- YY_RULE_SETUP
1083
- #line 119 "lexer.lpp"
1084
- {
1085
- yyextra->str.append(3, '"');
1086
- }
1087
- YY_BREAK
1088
- case 18:
1089
- YY_RULE_SETUP
1090
- #line 123 "lexer.lpp"
1091
- {
1092
- BEGIN(INITIAL);
1093
- yyextra->str = clean_up_block_string(yyextra->str);
1094
- yylval->str = yyextra->str.c_str();
1095
- *yylloc = yyextra->loc;
1096
- return yy::GraphQLParserImpl::token::TOK_STRING;
1097
- }
1098
- YY_BREAK
1099
-
1100
-
1101
- case 19:
1102
- /* rule 19 can match eol */
1103
- YY_RULE_SETUP
1104
- #line 133 "lexer.lpp"
1105
- { yyextra->loc.lines(yyleng / 2); yyextra->loc.step(); BEGIN(INITIAL); }
1106
- YY_BREAK
1107
- case 20:
1108
- /* rule 20 can match eol */
1109
- YY_RULE_SETUP
1110
- #line 134 "lexer.lpp"
1111
- { yyextra->loc.lines(yyleng); yyextra->loc.step(); BEGIN(INITIAL); }
1112
- YY_BREAK
1113
- case 21:
1114
- YY_RULE_SETUP
1115
- #line 135 "lexer.lpp"
1116
- /* eat comment character */
1117
- YY_BREAK
1118
-
1119
-
1120
- case 22:
1121
- YY_RULE_SETUP
1122
- #line 139 "lexer.lpp"
1123
- { yyextra->loc.step(); }
1124
- YY_BREAK
1125
- case 23:
1126
- YY_RULE_SETUP
1127
- #line 140 "lexer.lpp"
1128
- { yyextra->loc.step(); yyextra->loc.step(); yyextra->loc.step(); }
1129
- YY_BREAK
1130
- case 24:
1131
- /* rule 24 can match eol */
1132
- YY_RULE_SETUP
1133
- #line 141 "lexer.lpp"
1134
- { yyextra->loc.lines(yyleng / 2); yyextra->loc.step(); }
1135
- YY_BREAK
1136
- case 25:
1137
- /* rule 25 can match eol */
1138
- YY_RULE_SETUP
1139
- #line 142 "lexer.lpp"
1140
- { yyextra->loc.lines(yyleng); yyextra->loc.step(); }
1141
- YY_BREAK
1142
- case 26:
1143
- YY_RULE_SETUP
1144
- #line 144 "lexer.lpp"
1145
- {yyextra->loc.step(); BEGIN(LINE_COMMENT_STATE); }
1146
- YY_BREAK
1147
- case 27:
1148
- YY_RULE_SETUP
1149
- #line 146 "lexer.lpp"
1150
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_DIRECTIVE; }
1151
- YY_BREAK
1152
- case 28:
1153
- YY_RULE_SETUP
1154
- #line 147 "lexer.lpp"
1155
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_ENUM; }
1156
- YY_BREAK
1157
- case 29:
1158
- YY_RULE_SETUP
1159
- #line 148 "lexer.lpp"
1160
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_EXTEND; }
1161
- YY_BREAK
1162
- case 30:
1163
- YY_RULE_SETUP
1164
- #line 149 "lexer.lpp"
1165
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_FALSE; }
1166
- YY_BREAK
1167
- case 31:
1168
- YY_RULE_SETUP
1169
- #line 150 "lexer.lpp"
1170
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_FRAGMENT; }
1171
- YY_BREAK
1172
- case 32:
1173
- YY_RULE_SETUP
1174
- #line 151 "lexer.lpp"
1175
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_IMPLEMENTS; }
1176
- YY_BREAK
1177
- case 33:
1178
- YY_RULE_SETUP
1179
- #line 152 "lexer.lpp"
1180
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_INPUT; }
1181
- YY_BREAK
1182
- case 34:
1183
- YY_RULE_SETUP
1184
- #line 153 "lexer.lpp"
1185
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_INTERFACE; }
1186
- YY_BREAK
1187
- case 35:
1188
- YY_RULE_SETUP
1189
- #line 154 "lexer.lpp"
1190
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_MUTATION; }
1191
- YY_BREAK
1192
- case 36:
1193
- YY_RULE_SETUP
1194
- #line 155 "lexer.lpp"
1195
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_NULL; }
1196
- YY_BREAK
1197
- case 37:
1198
- YY_RULE_SETUP
1199
- #line 156 "lexer.lpp"
1200
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_ON; }
1201
- YY_BREAK
1202
- case 38:
1203
- YY_RULE_SETUP
1204
- #line 157 "lexer.lpp"
1205
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_QUERY; }
1206
- YY_BREAK
1207
- case 39:
1208
- YY_RULE_SETUP
1209
- #line 158 "lexer.lpp"
1210
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_SCALAR; }
1211
- YY_BREAK
1212
- case 40:
1213
- YY_RULE_SETUP
1214
- #line 159 "lexer.lpp"
1215
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_SCHEMA; }
1216
- YY_BREAK
1217
- case 41:
1218
- YY_RULE_SETUP
1219
- #line 160 "lexer.lpp"
1220
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_SUBSCRIPTION; }
1221
- YY_BREAK
1222
- case 42:
1223
- YY_RULE_SETUP
1224
- #line 161 "lexer.lpp"
1225
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_TRUE; }
1226
- YY_BREAK
1227
- case 43:
1228
- YY_RULE_SETUP
1229
- #line 162 "lexer.lpp"
1230
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_TYPE; }
1231
- YY_BREAK
1232
- case 44:
1233
- YY_RULE_SETUP
1234
- #line 163 "lexer.lpp"
1235
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_UNION; }
1236
- YY_BREAK
1237
- case 45:
1238
- YY_RULE_SETUP
1239
- #line 165 "lexer.lpp"
1240
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_INTEGER; }
1241
- YY_BREAK
1242
- case 46:
1243
- YY_RULE_SETUP
1244
- #line 166 "lexer.lpp"
1245
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_FLOAT; }
1246
- YY_BREAK
1247
- case 47:
1248
- YY_RULE_SETUP
1249
- #line 167 "lexer.lpp"
1250
- { yylval->str = yytext; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_IDENTIFIER; }
1251
- YY_BREAK
1252
- case 48:
1253
- YY_RULE_SETUP
1254
- #line 168 "lexer.lpp"
1255
- { yylval->str = yytext + 1; *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_VARIABLE; }
1256
- YY_BREAK
1257
- case 49:
1258
- YY_RULE_SETUP
1259
- #line 170 "lexer.lpp"
1260
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_BANG; }
1261
- YY_BREAK
1262
- case 50:
1263
- YY_RULE_SETUP
1264
- #line 171 "lexer.lpp"
1265
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_LPAREN; }
1266
- YY_BREAK
1267
- case 51:
1268
- YY_RULE_SETUP
1269
- #line 172 "lexer.lpp"
1270
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_RPAREN; }
1271
- YY_BREAK
1272
- case 52:
1273
- YY_RULE_SETUP
1274
- #line 173 "lexer.lpp"
1275
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_ELLIPSIS; }
1276
- YY_BREAK
1277
- case 53:
1278
- YY_RULE_SETUP
1279
- #line 174 "lexer.lpp"
1280
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_COLON; }
1281
- YY_BREAK
1282
- case 54:
1283
- YY_RULE_SETUP
1284
- #line 175 "lexer.lpp"
1285
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_EQUAL; }
1286
- YY_BREAK
1287
- case 55:
1288
- YY_RULE_SETUP
1289
- #line 176 "lexer.lpp"
1290
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_AT; }
1291
- YY_BREAK
1292
- case 56:
1293
- YY_RULE_SETUP
1294
- #line 177 "lexer.lpp"
1295
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_LBRACKET; }
1296
- YY_BREAK
1297
- case 57:
1298
- YY_RULE_SETUP
1299
- #line 178 "lexer.lpp"
1300
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_RBRACKET; }
1301
- YY_BREAK
1302
- case 58:
1303
- YY_RULE_SETUP
1304
- #line 179 "lexer.lpp"
1305
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_LBRACE; }
1306
- YY_BREAK
1307
- case 59:
1308
- YY_RULE_SETUP
1309
- #line 180 "lexer.lpp"
1310
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_PIPE; }
1311
- YY_BREAK
1312
- case 60:
1313
- YY_RULE_SETUP
1314
- #line 181 "lexer.lpp"
1315
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_RBRACE; }
1316
- YY_BREAK
1317
- case YY_STATE_EOF(INITIAL):
1318
- #line 184 "lexer.lpp"
1319
- { *yylloc = yyextra->loc; return yy::GraphQLParserImpl::token::TOK_EOF; }
1320
- YY_BREAK
1321
- case 61:
1322
- YY_RULE_SETUP
1323
- #line 186 "lexer.lpp"
1324
- {
1325
- BEGIN(BLOCK_STRING_STATE);
1326
- yyextra->str.clear();
1327
- }
1328
- YY_BREAK
1329
- case 62:
1330
- YY_RULE_SETUP
1331
- #line 191 "lexer.lpp"
1332
- {
1333
- BEGIN(STRING_STATE);
1334
- yyextra->str.clear();
1335
- }
1336
- YY_BREAK
1337
-
1338
- case 63:
1339
- YY_RULE_SETUP
1340
- #line 197 "lexer.lpp"
1341
- {
1342
- char buf[6];
1343
- escape(yytext[0], buf);
1344
- throw make_error(
1345
- yyextra->loc,
1346
- std::string("unrecognized character ") + buf);
1347
- }
1348
- YY_BREAK
1349
- case 64:
1350
- YY_RULE_SETUP
1351
- #line 205 "lexer.lpp"
1352
- ECHO;
1353
- YY_BREAK
1354
- #line 1354 "lexer.cpp"
1355
- case YY_STATE_EOF(C_COMMENT_STATE):
1356
- case YY_STATE_EOF(LINE_COMMENT_STATE):
1357
- yyterminate();
1358
-
1359
- case YY_END_OF_BUFFER:
1360
- {
1361
- /* Amount of text matched not including the EOB char. */
1362
- int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1363
-
1364
- /* Undo the effects of YY_DO_BEFORE_ACTION. */
1365
- *yy_cp = yyg->yy_hold_char;
1366
- YY_RESTORE_YY_MORE_OFFSET
1367
-
1368
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1369
- {
1370
- /* We're scanning a new file or input source. It's
1371
- * possible that this happened because the user
1372
- * just pointed yyin at a new source and called
1373
- * yylex(). If so, then we have to assure
1374
- * consistency between YY_CURRENT_BUFFER and our
1375
- * globals. Here is the right place to do so, because
1376
- * this is the first action (other than possibly a
1377
- * back-up) that will match for the new input source.
1378
- */
1379
- yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1380
- YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1381
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1382
- }
1383
-
1384
- /* Note that here we test for yy_c_buf_p "<=" to the position
1385
- * of the first EOB in the buffer, since yy_c_buf_p will
1386
- * already have been incremented past the NUL character
1387
- * (since all states make transitions on EOB to the
1388
- * end-of-buffer state). Contrast this with the test
1389
- * in input().
1390
- */
1391
- if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1392
- { /* This was really a NUL. */
1393
- yy_state_type yy_next_state;
1394
-
1395
- yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1396
-
1397
- yy_current_state = yy_get_previous_state( yyscanner );
1398
-
1399
- /* Okay, we're now positioned to make the NUL
1400
- * transition. We couldn't have
1401
- * yy_get_previous_state() go ahead and do it
1402
- * for us because it doesn't know how to deal
1403
- * with the possibility of jamming (and we don't
1404
- * want to build jamming into it because then it
1405
- * will run more slowly).
1406
- */
1407
-
1408
- yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1409
-
1410
- yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1411
-
1412
- if ( yy_next_state )
1413
- {
1414
- /* Consume the NUL. */
1415
- yy_cp = ++yyg->yy_c_buf_p;
1416
- yy_current_state = yy_next_state;
1417
- goto yy_match;
1418
- }
1419
-
1420
- else
1421
- {
1422
- yy_cp = yyg->yy_last_accepting_cpos;
1423
- yy_current_state = yyg->yy_last_accepting_state;
1424
- goto yy_find_action;
1425
- }
1426
- }
1427
-
1428
- else switch ( yy_get_next_buffer( yyscanner ) )
1429
- {
1430
- case EOB_ACT_END_OF_FILE:
1431
- {
1432
- yyg->yy_did_buffer_switch_on_eof = 0;
1433
-
1434
- if ( yywrap( yyscanner ) )
1435
- {
1436
- /* Note: because we've taken care in
1437
- * yy_get_next_buffer() to have set up
1438
- * yytext, we can now set up
1439
- * yy_c_buf_p so that if some total
1440
- * hoser (like flex itself) wants to
1441
- * call the scanner after we return the
1442
- * YY_NULL, it'll still work - another
1443
- * YY_NULL will get returned.
1444
- */
1445
- yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1446
-
1447
- yy_act = YY_STATE_EOF(YY_START);
1448
- goto do_action;
1449
- }
1450
-
1451
- else
1452
- {
1453
- if ( ! yyg->yy_did_buffer_switch_on_eof )
1454
- YY_NEW_FILE;
1455
- }
1456
- break;
1457
- }
1458
-
1459
- case EOB_ACT_CONTINUE_SCAN:
1460
- yyg->yy_c_buf_p =
1461
- yyg->yytext_ptr + yy_amount_of_matched_text;
1462
-
1463
- yy_current_state = yy_get_previous_state( yyscanner );
1464
-
1465
- yy_cp = yyg->yy_c_buf_p;
1466
- yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1467
- goto yy_match;
1468
-
1469
- case EOB_ACT_LAST_MATCH:
1470
- yyg->yy_c_buf_p =
1471
- &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1472
-
1473
- yy_current_state = yy_get_previous_state( yyscanner );
1474
-
1475
- yy_cp = yyg->yy_c_buf_p;
1476
- yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1477
- goto yy_find_action;
1478
- }
1479
- break;
1480
- }
1481
-
1482
- default:
1483
- YY_FATAL_ERROR(
1484
- "fatal flex scanner internal error--no action found" );
1485
- } /* end of action switch */
1486
- } /* end of scanning one token */
1487
- } /* end of user's declarations */
1488
- } /* end of yylex */
1489
-
1490
- /* yy_get_next_buffer - try to read in a new buffer
1491
- *
1492
- * Returns a code representing an action:
1493
- * EOB_ACT_LAST_MATCH -
1494
- * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1495
- * EOB_ACT_END_OF_FILE - end of file
1496
- */
1497
- static int yy_get_next_buffer (yyscan_t yyscanner)
1498
- {
1499
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1500
- char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1501
- char *source = yyg->yytext_ptr;
1502
- int number_to_move, i;
1503
- int ret_val;
1504
-
1505
- if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1506
- YY_FATAL_ERROR(
1507
- "fatal flex scanner internal error--end of buffer missed" );
1508
-
1509
- if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1510
- { /* Don't try to fill the buffer, so this is an EOF. */
1511
- if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1512
- {
1513
- /* We matched a single character, the EOB, so
1514
- * treat this as a final EOF.
1515
- */
1516
- return EOB_ACT_END_OF_FILE;
1517
- }
1518
-
1519
- else
1520
- {
1521
- /* We matched some text prior to the EOB, first
1522
- * process it.
1523
- */
1524
- return EOB_ACT_LAST_MATCH;
1525
- }
1526
- }
1527
-
1528
- /* Try to read more data. */
1529
-
1530
- /* First move last chars to start of buffer. */
1531
- number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr - 1);
1532
-
1533
- for ( i = 0; i < number_to_move; ++i )
1534
- *(dest++) = *(source++);
1535
-
1536
- if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1537
- /* don't do the read, it's not guaranteed to return an EOF,
1538
- * just force an EOF
1539
- */
1540
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1541
-
1542
- else
1543
- {
1544
- int num_to_read =
1545
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1546
-
1547
- while ( num_to_read <= 0 )
1548
- { /* Not enough room in the buffer - grow it. */
1549
-
1550
- /* just a shorter name for the current buffer */
1551
- YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
1552
-
1553
- int yy_c_buf_p_offset =
1554
- (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1555
-
1556
- if ( b->yy_is_our_buffer )
1557
- {
1558
- int new_size = b->yy_buf_size * 2;
1559
-
1560
- if ( new_size <= 0 )
1561
- b->yy_buf_size += b->yy_buf_size / 8;
1562
- else
1563
- b->yy_buf_size *= 2;
1564
-
1565
- b->yy_ch_buf = (char *)
1566
- /* Include room in for 2 EOB chars. */
1567
- yyrealloc( (void *) b->yy_ch_buf,
1568
- (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1569
- }
1570
- else
1571
- /* Can't grow it, we don't own it. */
1572
- b->yy_ch_buf = NULL;
1573
-
1574
- if ( ! b->yy_ch_buf )
1575
- YY_FATAL_ERROR(
1576
- "fatal error - scanner input buffer overflow" );
1577
-
1578
- yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1579
-
1580
- num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1581
- number_to_move - 1;
1582
-
1583
- }
1584
-
1585
- if ( num_to_read > YY_READ_BUF_SIZE )
1586
- num_to_read = YY_READ_BUF_SIZE;
1587
-
1588
- /* Read in more data. */
1589
- YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1590
- yyg->yy_n_chars, num_to_read );
1591
-
1592
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1593
- }
1594
-
1595
- if ( yyg->yy_n_chars == 0 )
1596
- {
1597
- if ( number_to_move == YY_MORE_ADJ )
1598
- {
1599
- ret_val = EOB_ACT_END_OF_FILE;
1600
- yyrestart( yyin , yyscanner);
1601
- }
1602
-
1603
- else
1604
- {
1605
- ret_val = EOB_ACT_LAST_MATCH;
1606
- YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1607
- YY_BUFFER_EOF_PENDING;
1608
- }
1609
- }
1610
-
1611
- else
1612
- ret_val = EOB_ACT_CONTINUE_SCAN;
1613
-
1614
- if ((yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1615
- /* Extend the array by 50%, plus the number we really need. */
1616
- int new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1617
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc(
1618
- (void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf, (yy_size_t) new_size , yyscanner );
1619
- if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1620
- YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1621
- /* "- 2" to take care of EOB's */
1622
- YY_CURRENT_BUFFER_LVALUE->yy_buf_size = (int) (new_size - 2);
1623
- }
1624
-
1625
- yyg->yy_n_chars += number_to_move;
1626
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1627
- YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1628
-
1629
- yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1630
-
1631
- return ret_val;
1632
- }
1633
-
1634
- /* yy_get_previous_state - get the state just before the EOB char was reached */
1635
-
1636
- static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1637
- {
1638
- yy_state_type yy_current_state;
1639
- char *yy_cp;
1640
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1641
-
1642
- yy_current_state = yyg->yy_start;
1643
-
1644
- for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1645
- {
1646
- YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1647
- if ( yy_accept[yy_current_state] )
1648
- {
1649
- yyg->yy_last_accepting_state = yy_current_state;
1650
- yyg->yy_last_accepting_cpos = yy_cp;
1651
- }
1652
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1653
- {
1654
- yy_current_state = (int) yy_def[yy_current_state];
1655
- if ( yy_current_state >= 196 )
1656
- yy_c = yy_meta[yy_c];
1657
- }
1658
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1659
- }
1660
-
1661
- return yy_current_state;
1662
- }
1663
-
1664
- /* yy_try_NUL_trans - try to make a transition on the NUL character
1665
- *
1666
- * synopsis
1667
- * next_state = yy_try_NUL_trans( current_state );
1668
- */
1669
- static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1670
- {
1671
- int yy_is_jam;
1672
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1673
- char *yy_cp = yyg->yy_c_buf_p;
1674
-
1675
- YY_CHAR yy_c = 1;
1676
- if ( yy_accept[yy_current_state] )
1677
- {
1678
- yyg->yy_last_accepting_state = yy_current_state;
1679
- yyg->yy_last_accepting_cpos = yy_cp;
1680
- }
1681
- while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1682
- {
1683
- yy_current_state = (int) yy_def[yy_current_state];
1684
- if ( yy_current_state >= 196 )
1685
- yy_c = yy_meta[yy_c];
1686
- }
1687
- yy_current_state = yy_nxt[yy_base[yy_current_state] + yy_c];
1688
- yy_is_jam = (yy_current_state == 195);
1689
-
1690
- (void)yyg;
1691
- return yy_is_jam ? 0 : yy_current_state;
1692
- }
1693
-
1694
- #ifndef YY_NO_UNPUT
1695
-
1696
- #endif
1697
-
1698
- #ifndef YY_NO_INPUT
1699
- #ifdef __cplusplus
1700
- static int yyinput (yyscan_t yyscanner)
1701
- #else
1702
- static int input (yyscan_t yyscanner)
1703
- #endif
1704
-
1705
- {
1706
- int c;
1707
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1708
-
1709
- *yyg->yy_c_buf_p = yyg->yy_hold_char;
1710
-
1711
- if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1712
- {
1713
- /* yy_c_buf_p now points to the character we want to return.
1714
- * If this occurs *before* the EOB characters, then it's a
1715
- * valid NUL; if not, then we've hit the end of the buffer.
1716
- */
1717
- if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1718
- /* This was really a NUL. */
1719
- *yyg->yy_c_buf_p = '\0';
1720
-
1721
- else
1722
- { /* need more input */
1723
- int offset = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr);
1724
- ++yyg->yy_c_buf_p;
1725
-
1726
- switch ( yy_get_next_buffer( yyscanner ) )
1727
- {
1728
- case EOB_ACT_LAST_MATCH:
1729
- /* This happens because yy_g_n_b()
1730
- * sees that we've accumulated a
1731
- * token and flags that we need to
1732
- * try matching the token before
1733
- * proceeding. But for input(),
1734
- * there's no matching to consider.
1735
- * So convert the EOB_ACT_LAST_MATCH
1736
- * to EOB_ACT_END_OF_FILE.
1737
- */
1738
-
1739
- /* Reset buffer status. */
1740
- yyrestart( yyin , yyscanner);
1741
-
1742
- /*FALLTHROUGH*/
1743
-
1744
- case EOB_ACT_END_OF_FILE:
1745
- {
1746
- if ( yywrap( yyscanner ) )
1747
- return 0;
1748
-
1749
- if ( ! yyg->yy_did_buffer_switch_on_eof )
1750
- YY_NEW_FILE;
1751
- #ifdef __cplusplus
1752
- return yyinput(yyscanner);
1753
- #else
1754
- return input(yyscanner);
1755
- #endif
1756
- }
1757
-
1758
- case EOB_ACT_CONTINUE_SCAN:
1759
- yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1760
- break;
1761
- }
1762
- }
1763
- }
1764
-
1765
- c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1766
- *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1767
- yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1768
-
1769
- return c;
1770
- }
1771
- #endif /* ifndef YY_NO_INPUT */
1772
-
1773
- /** Immediately switch to a different input stream.
1774
- * @param input_file A readable stream.
1775
- * @param yyscanner The scanner object.
1776
- * @note This function does not reset the start condition to @c INITIAL .
1777
- */
1778
- void yyrestart (FILE * input_file , yyscan_t yyscanner)
1779
- {
1780
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1781
-
1782
- if ( ! YY_CURRENT_BUFFER ){
1783
- yyensure_buffer_stack (yyscanner);
1784
- YY_CURRENT_BUFFER_LVALUE =
1785
- yy_create_buffer( yyin, YY_BUF_SIZE , yyscanner);
1786
- }
1787
-
1788
- yy_init_buffer( YY_CURRENT_BUFFER, input_file , yyscanner);
1789
- yy_load_buffer_state( yyscanner );
1790
- }
1791
-
1792
- /** Switch to a different input buffer.
1793
- * @param new_buffer The new input buffer.
1794
- * @param yyscanner The scanner object.
1795
- */
1796
- void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1797
- {
1798
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1799
-
1800
- /* TODO. We should be able to replace this entire function body
1801
- * with
1802
- * yypop_buffer_state();
1803
- * yypush_buffer_state(new_buffer);
1804
- */
1805
- yyensure_buffer_stack (yyscanner);
1806
- if ( YY_CURRENT_BUFFER == new_buffer )
1807
- return;
1808
-
1809
- if ( YY_CURRENT_BUFFER )
1810
- {
1811
- /* Flush out information for old buffer. */
1812
- *yyg->yy_c_buf_p = yyg->yy_hold_char;
1813
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1814
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1815
- }
1816
-
1817
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
1818
- yy_load_buffer_state( yyscanner );
1819
-
1820
- /* We don't actually know whether we did this switch during
1821
- * EOF (yywrap()) processing, but the only time this flag
1822
- * is looked at is after yywrap() is called, so it's safe
1823
- * to go ahead and always set it.
1824
- */
1825
- yyg->yy_did_buffer_switch_on_eof = 1;
1826
- }
1827
-
1828
- static void yy_load_buffer_state (yyscan_t yyscanner)
1829
- {
1830
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1831
- yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1832
- yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1833
- yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1834
- yyg->yy_hold_char = *yyg->yy_c_buf_p;
1835
- }
1836
-
1837
- /** Allocate and initialize an input buffer state.
1838
- * @param file A readable stream.
1839
- * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1840
- * @param yyscanner The scanner object.
1841
- * @return the allocated buffer state.
1842
- */
1843
- YY_BUFFER_STATE yy_create_buffer (FILE * file, int size , yyscan_t yyscanner)
1844
- {
1845
- YY_BUFFER_STATE b;
1846
-
1847
- b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
1848
- if ( ! b )
1849
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1850
-
1851
- b->yy_buf_size = size;
1852
-
1853
- /* yy_ch_buf has to be 2 characters longer than the size given because
1854
- * we need to put in 2 end-of-buffer characters.
1855
- */
1856
- b->yy_ch_buf = (char *) yyalloc( (yy_size_t) (b->yy_buf_size + 2) , yyscanner );
1857
- if ( ! b->yy_ch_buf )
1858
- YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
1859
-
1860
- b->yy_is_our_buffer = 1;
1861
-
1862
- yy_init_buffer( b, file , yyscanner);
1863
-
1864
- return b;
1865
- }
1866
-
1867
- /** Destroy the buffer.
1868
- * @param b a buffer created with yy_create_buffer()
1869
- * @param yyscanner The scanner object.
1870
- */
1871
- void yy_delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1872
- {
1873
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1874
-
1875
- if ( ! b )
1876
- return;
1877
-
1878
- if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1879
- YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1880
-
1881
- if ( b->yy_is_our_buffer )
1882
- yyfree( (void *) b->yy_ch_buf , yyscanner );
1883
-
1884
- yyfree( (void *) b , yyscanner );
1885
- }
1886
-
1887
- /* Initializes or reinitializes a buffer.
1888
- * This function is sometimes called more than once on the same buffer,
1889
- * such as during a yyrestart() or at EOF.
1890
- */
1891
- static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1892
-
1893
- {
1894
- int oerrno = errno;
1895
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1896
-
1897
- yy_flush_buffer( b , yyscanner);
1898
-
1899
- b->yy_input_file = file;
1900
- b->yy_fill_buffer = 1;
1901
-
1902
- /* If b is the current buffer, then yy_init_buffer was _probably_
1903
- * called from yyrestart() or through yy_get_next_buffer.
1904
- * In that case, we don't want to reset the lineno or column.
1905
- */
1906
- if (b != YY_CURRENT_BUFFER){
1907
- b->yy_bs_lineno = 1;
1908
- b->yy_bs_column = 0;
1909
- }
1910
-
1911
- b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1912
-
1913
- errno = oerrno;
1914
- }
1915
-
1916
- /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1917
- * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1918
- * @param yyscanner The scanner object.
1919
- */
1920
- void yy_flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1921
- {
1922
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1923
- if ( ! b )
1924
- return;
1925
-
1926
- b->yy_n_chars = 0;
1927
-
1928
- /* We always need two end-of-buffer characters. The first causes
1929
- * a transition to the end-of-buffer state. The second causes
1930
- * a jam in that state.
1931
- */
1932
- b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1933
- b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1934
-
1935
- b->yy_buf_pos = &b->yy_ch_buf[0];
1936
-
1937
- b->yy_at_bol = 1;
1938
- b->yy_buffer_status = YY_BUFFER_NEW;
1939
-
1940
- if ( b == YY_CURRENT_BUFFER )
1941
- yy_load_buffer_state( yyscanner );
1942
- }
1943
-
1944
- /** Pushes the new state onto the stack. The new state becomes
1945
- * the current state. This function will allocate the stack
1946
- * if necessary.
1947
- * @param new_buffer The new state.
1948
- * @param yyscanner The scanner object.
1949
- */
1950
- void yypush_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1951
- {
1952
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1953
- if (new_buffer == NULL)
1954
- return;
1955
-
1956
- yyensure_buffer_stack(yyscanner);
1957
-
1958
- /* This block is copied from yy_switch_to_buffer. */
1959
- if ( YY_CURRENT_BUFFER )
1960
- {
1961
- /* Flush out information for old buffer. */
1962
- *yyg->yy_c_buf_p = yyg->yy_hold_char;
1963
- YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1964
- YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1965
- }
1966
-
1967
- /* Only push if top exists. Otherwise, replace top. */
1968
- if (YY_CURRENT_BUFFER)
1969
- yyg->yy_buffer_stack_top++;
1970
- YY_CURRENT_BUFFER_LVALUE = new_buffer;
1971
-
1972
- /* copied from yy_switch_to_buffer. */
1973
- yy_load_buffer_state( yyscanner );
1974
- yyg->yy_did_buffer_switch_on_eof = 1;
1975
- }
1976
-
1977
- /** Removes and deletes the top of the stack, if present.
1978
- * The next element becomes the new top.
1979
- * @param yyscanner The scanner object.
1980
- */
1981
- void yypop_buffer_state (yyscan_t yyscanner)
1982
- {
1983
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1984
- if (!YY_CURRENT_BUFFER)
1985
- return;
1986
-
1987
- yy_delete_buffer(YY_CURRENT_BUFFER , yyscanner);
1988
- YY_CURRENT_BUFFER_LVALUE = NULL;
1989
- if (yyg->yy_buffer_stack_top > 0)
1990
- --yyg->yy_buffer_stack_top;
1991
-
1992
- if (YY_CURRENT_BUFFER) {
1993
- yy_load_buffer_state( yyscanner );
1994
- yyg->yy_did_buffer_switch_on_eof = 1;
1995
- }
1996
- }
1997
-
1998
- /* Allocates the stack if it does not exist.
1999
- * Guarantees space for at least one push.
2000
- */
2001
- static void yyensure_buffer_stack (yyscan_t yyscanner)
2002
- {
2003
- yy_size_t num_to_alloc;
2004
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2005
-
2006
- if (!yyg->yy_buffer_stack) {
2007
-
2008
- /* First allocation is just for 2 elements, since we don't know if this
2009
- * scanner will even need a stack. We use 2 instead of 1 to avoid an
2010
- * immediate realloc on the next call.
2011
- */
2012
- num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
2013
- yyg->yy_buffer_stack = (struct yy_buffer_state**)yyalloc
2014
- (num_to_alloc * sizeof(struct yy_buffer_state*)
2015
- , yyscanner);
2016
- if ( ! yyg->yy_buffer_stack )
2017
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2018
-
2019
- memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
2020
-
2021
- yyg->yy_buffer_stack_max = num_to_alloc;
2022
- yyg->yy_buffer_stack_top = 0;
2023
- return;
2024
- }
2025
-
2026
- if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
2027
-
2028
- /* Increase the buffer to prepare for a possible push. */
2029
- yy_size_t grow_size = 8 /* arbitrary grow size */;
2030
-
2031
- num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
2032
- yyg->yy_buffer_stack = (struct yy_buffer_state**)yyrealloc
2033
- (yyg->yy_buffer_stack,
2034
- num_to_alloc * sizeof(struct yy_buffer_state*)
2035
- , yyscanner);
2036
- if ( ! yyg->yy_buffer_stack )
2037
- YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
2038
-
2039
- /* zero only the new slots.*/
2040
- memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
2041
- yyg->yy_buffer_stack_max = num_to_alloc;
2042
- }
2043
- }
2044
-
2045
- /** Setup the input buffer state to scan directly from a user-specified character buffer.
2046
- * @param base the character buffer
2047
- * @param size the size in bytes of the character buffer
2048
- * @param yyscanner The scanner object.
2049
- * @return the newly allocated buffer state object.
2050
- */
2051
- YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
2052
- {
2053
- YY_BUFFER_STATE b;
2054
-
2055
- if ( size < 2 ||
2056
- base[size-2] != YY_END_OF_BUFFER_CHAR ||
2057
- base[size-1] != YY_END_OF_BUFFER_CHAR )
2058
- /* They forgot to leave room for the EOB's. */
2059
- return NULL;
2060
-
2061
- b = (YY_BUFFER_STATE) yyalloc( sizeof( struct yy_buffer_state ) , yyscanner );
2062
- if ( ! b )
2063
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
2064
-
2065
- b->yy_buf_size = (int) (size - 2); /* "- 2" to take care of EOB's */
2066
- b->yy_buf_pos = b->yy_ch_buf = base;
2067
- b->yy_is_our_buffer = 0;
2068
- b->yy_input_file = NULL;
2069
- b->yy_n_chars = b->yy_buf_size;
2070
- b->yy_is_interactive = 0;
2071
- b->yy_at_bol = 1;
2072
- b->yy_fill_buffer = 0;
2073
- b->yy_buffer_status = YY_BUFFER_NEW;
2074
-
2075
- yy_switch_to_buffer( b , yyscanner );
2076
-
2077
- return b;
2078
- }
2079
-
2080
- /** Setup the input buffer state to scan a string. The next call to yylex() will
2081
- * scan from a @e copy of @a str.
2082
- * @param yystr a NUL-terminated string to scan
2083
- * @param yyscanner The scanner object.
2084
- * @return the newly allocated buffer state object.
2085
- * @note If you want to scan bytes that may contain NUL values, then use
2086
- * yy_scan_bytes() instead.
2087
- */
2088
- YY_BUFFER_STATE yy_scan_string (const char * yystr , yyscan_t yyscanner)
2089
- {
2090
-
2091
- return yy_scan_bytes( yystr, (int) strlen(yystr) , yyscanner);
2092
- }
2093
-
2094
- /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
2095
- * scan from a @e copy of @a bytes.
2096
- * @param yybytes the byte buffer to scan
2097
- * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
2098
- * @param yyscanner The scanner object.
2099
- * @return the newly allocated buffer state object.
2100
- */
2101
- YY_BUFFER_STATE yy_scan_bytes (const char * yybytes, int _yybytes_len , yyscan_t yyscanner)
2102
- {
2103
- YY_BUFFER_STATE b;
2104
- char *buf;
2105
- yy_size_t n;
2106
- int i;
2107
-
2108
- /* Get memory for full buffer, including space for trailing EOB's. */
2109
- n = (yy_size_t) (_yybytes_len + 2);
2110
- buf = (char *) yyalloc( n , yyscanner );
2111
- if ( ! buf )
2112
- YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
2113
-
2114
- for ( i = 0; i < _yybytes_len; ++i )
2115
- buf[i] = yybytes[i];
2116
-
2117
- buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
2118
-
2119
- b = yy_scan_buffer( buf, n , yyscanner);
2120
- if ( ! b )
2121
- YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
2122
-
2123
- /* It's okay to grow etc. this buffer, and we should throw it
2124
- * away when we're done.
2125
- */
2126
- b->yy_is_our_buffer = 1;
2127
-
2128
- return b;
2129
- }
2130
-
2131
- #ifndef YY_EXIT_FAILURE
2132
- #define YY_EXIT_FAILURE 2
2133
- #endif
2134
-
2135
- static void yynoreturn yy_fatal_error (const char* msg , yyscan_t yyscanner)
2136
- {
2137
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2138
- (void)yyg;
2139
- fprintf( stderr, "%s\n", msg );
2140
- exit( YY_EXIT_FAILURE );
2141
- }
2142
-
2143
- /* Redefine yyless() so it works in section 3 code. */
2144
-
2145
- #undef yyless
2146
- #define yyless(n) \
2147
- do \
2148
- { \
2149
- /* Undo effects of setting up yytext. */ \
2150
- int yyless_macro_arg = (n); \
2151
- YY_LESS_LINENO(yyless_macro_arg);\
2152
- yytext[yyleng] = yyg->yy_hold_char; \
2153
- yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2154
- yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2155
- *yyg->yy_c_buf_p = '\0'; \
2156
- yyleng = yyless_macro_arg; \
2157
- } \
2158
- while ( 0 )
2159
-
2160
- /* Accessor methods (get/set functions) to struct members. */
2161
-
2162
- /** Get the user-defined data for this scanner.
2163
- * @param yyscanner The scanner object.
2164
- */
2165
- YY_EXTRA_TYPE yyget_extra (yyscan_t yyscanner)
2166
- {
2167
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2168
- return yyextra;
2169
- }
2170
-
2171
- /** Get the current line number.
2172
- * @param yyscanner The scanner object.
2173
- */
2174
- int yyget_lineno (yyscan_t yyscanner)
2175
- {
2176
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2177
-
2178
- if (! YY_CURRENT_BUFFER)
2179
- return 0;
2180
-
2181
- return yylineno;
2182
- }
2183
-
2184
- /** Get the current column number.
2185
- * @param yyscanner The scanner object.
2186
- */
2187
- int yyget_column (yyscan_t yyscanner)
2188
- {
2189
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2190
-
2191
- if (! YY_CURRENT_BUFFER)
2192
- return 0;
2193
-
2194
- return yycolumn;
2195
- }
2196
-
2197
- /** Get the input stream.
2198
- * @param yyscanner The scanner object.
2199
- */
2200
- FILE *yyget_in (yyscan_t yyscanner)
2201
- {
2202
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2203
- return yyin;
2204
- }
2205
-
2206
- /** Get the output stream.
2207
- * @param yyscanner The scanner object.
2208
- */
2209
- FILE *yyget_out (yyscan_t yyscanner)
2210
- {
2211
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2212
- return yyout;
2213
- }
2214
-
2215
- /** Get the length of the current token.
2216
- * @param yyscanner The scanner object.
2217
- */
2218
- int yyget_leng (yyscan_t yyscanner)
2219
- {
2220
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2221
- return yyleng;
2222
- }
2223
-
2224
- /** Get the current token.
2225
- * @param yyscanner The scanner object.
2226
- */
2227
-
2228
- char *yyget_text (yyscan_t yyscanner)
2229
- {
2230
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2231
- return yytext;
2232
- }
2233
-
2234
- /** Set the user-defined data. This data is never touched by the scanner.
2235
- * @param user_defined The data to be associated with this scanner.
2236
- * @param yyscanner The scanner object.
2237
- */
2238
- void yyset_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2239
- {
2240
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2241
- yyextra = user_defined ;
2242
- }
2243
-
2244
- /** Set the current line number.
2245
- * @param _line_number line number
2246
- * @param yyscanner The scanner object.
2247
- */
2248
- void yyset_lineno (int _line_number , yyscan_t yyscanner)
2249
- {
2250
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2251
-
2252
- /* lineno is only valid if an input buffer exists. */
2253
- if (! YY_CURRENT_BUFFER )
2254
- YY_FATAL_ERROR( "yyset_lineno called with no buffer" );
2255
-
2256
- yylineno = _line_number;
2257
- }
2258
-
2259
- /** Set the current column.
2260
- * @param _column_no column number
2261
- * @param yyscanner The scanner object.
2262
- */
2263
- void yyset_column (int _column_no , yyscan_t yyscanner)
2264
- {
2265
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2266
-
2267
- /* column is only valid if an input buffer exists. */
2268
- if (! YY_CURRENT_BUFFER )
2269
- YY_FATAL_ERROR( "yyset_column called with no buffer" );
2270
-
2271
- yycolumn = _column_no;
2272
- }
2273
-
2274
- /** Set the input stream. This does not discard the current
2275
- * input buffer.
2276
- * @param _in_str A readable stream.
2277
- * @param yyscanner The scanner object.
2278
- * @see yy_switch_to_buffer
2279
- */
2280
- void yyset_in (FILE * _in_str , yyscan_t yyscanner)
2281
- {
2282
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2283
- yyin = _in_str ;
2284
- }
2285
-
2286
- void yyset_out (FILE * _out_str , yyscan_t yyscanner)
2287
- {
2288
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2289
- yyout = _out_str ;
2290
- }
2291
-
2292
- int yyget_debug (yyscan_t yyscanner)
2293
- {
2294
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2295
- return yy_flex_debug;
2296
- }
2297
-
2298
- void yyset_debug (int _bdebug , yyscan_t yyscanner)
2299
- {
2300
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2301
- yy_flex_debug = _bdebug ;
2302
- }
2303
-
2304
- /* Accessor methods for yylval and yylloc */
2305
-
2306
- YYSTYPE * yyget_lval (yyscan_t yyscanner)
2307
- {
2308
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2309
- return yylval;
2310
- }
2311
-
2312
- void yyset_lval (YYSTYPE * yylval_param , yyscan_t yyscanner)
2313
- {
2314
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2315
- yylval = yylval_param;
2316
- }
2317
-
2318
- YYLTYPE *yyget_lloc (yyscan_t yyscanner)
2319
- {
2320
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2321
- return yylloc;
2322
- }
2323
-
2324
- void yyset_lloc (YYLTYPE * yylloc_param , yyscan_t yyscanner)
2325
- {
2326
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2327
- yylloc = yylloc_param;
2328
- }
2329
-
2330
- /* User-visible API */
2331
-
2332
- /* yylex_init is special because it creates the scanner itself, so it is
2333
- * the ONLY reentrant function that doesn't take the scanner as the last argument.
2334
- * That's why we explicitly handle the declaration, instead of using our macros.
2335
- */
2336
- int yylex_init(yyscan_t* ptr_yy_globals)
2337
- {
2338
- if (ptr_yy_globals == NULL){
2339
- errno = EINVAL;
2340
- return 1;
2341
- }
2342
-
2343
- *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), NULL );
2344
-
2345
- if (*ptr_yy_globals == NULL){
2346
- errno = ENOMEM;
2347
- return 1;
2348
- }
2349
-
2350
- /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2351
- memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2352
-
2353
- return yy_init_globals ( *ptr_yy_globals );
2354
- }
2355
-
2356
- /* yylex_init_extra has the same functionality as yylex_init, but follows the
2357
- * convention of taking the scanner as the last argument. Note however, that
2358
- * this is a *pointer* to a scanner, as it will be allocated by this call (and
2359
- * is the reason, too, why this function also must handle its own declaration).
2360
- * The user defined value in the first argument will be available to yyalloc in
2361
- * the yyextra field.
2362
- */
2363
- int yylex_init_extra( YY_EXTRA_TYPE yy_user_defined, yyscan_t* ptr_yy_globals )
2364
- {
2365
- struct yyguts_t dummy_yyguts;
2366
-
2367
- yyset_extra (yy_user_defined, &dummy_yyguts);
2368
-
2369
- if (ptr_yy_globals == NULL){
2370
- errno = EINVAL;
2371
- return 1;
2372
- }
2373
-
2374
- *ptr_yy_globals = (yyscan_t) yyalloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2375
-
2376
- if (*ptr_yy_globals == NULL){
2377
- errno = ENOMEM;
2378
- return 1;
2379
- }
2380
-
2381
- /* By setting to 0xAA, we expose bugs in
2382
- yy_init_globals. Leave at 0x00 for releases. */
2383
- memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2384
-
2385
- yyset_extra (yy_user_defined, *ptr_yy_globals);
2386
-
2387
- return yy_init_globals ( *ptr_yy_globals );
2388
- }
2389
-
2390
- static int yy_init_globals (yyscan_t yyscanner)
2391
- {
2392
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2393
- /* Initialization is the same as for the non-reentrant scanner.
2394
- * This function is called from yylex_destroy(), so don't allocate here.
2395
- */
2396
-
2397
- yyg->yy_buffer_stack = NULL;
2398
- yyg->yy_buffer_stack_top = 0;
2399
- yyg->yy_buffer_stack_max = 0;
2400
- yyg->yy_c_buf_p = NULL;
2401
- yyg->yy_init = 0;
2402
- yyg->yy_start = 0;
2403
-
2404
- yyg->yy_start_stack_ptr = 0;
2405
- yyg->yy_start_stack_depth = 0;
2406
- yyg->yy_start_stack = NULL;
2407
-
2408
- /* Defined in main.c */
2409
- #ifdef YY_STDINIT
2410
- yyin = stdin;
2411
- yyout = stdout;
2412
- #else
2413
- yyin = NULL;
2414
- yyout = NULL;
2415
- #endif
2416
-
2417
- /* For future reference: Set errno on error, since we are called by
2418
- * yylex_init()
2419
- */
2420
- return 0;
2421
- }
2422
-
2423
- /* yylex_destroy is for both reentrant and non-reentrant scanners. */
2424
- int yylex_destroy (yyscan_t yyscanner)
2425
- {
2426
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2427
-
2428
- /* Pop the buffer stack, destroying each element. */
2429
- while(YY_CURRENT_BUFFER){
2430
- yy_delete_buffer( YY_CURRENT_BUFFER , yyscanner );
2431
- YY_CURRENT_BUFFER_LVALUE = NULL;
2432
- yypop_buffer_state(yyscanner);
2433
- }
2434
-
2435
- /* Destroy the stack itself. */
2436
- yyfree(yyg->yy_buffer_stack , yyscanner);
2437
- yyg->yy_buffer_stack = NULL;
2438
-
2439
- /* Destroy the start condition stack. */
2440
- yyfree( yyg->yy_start_stack , yyscanner );
2441
- yyg->yy_start_stack = NULL;
2442
-
2443
- /* Reset the globals. This is important in a non-reentrant scanner so the next time
2444
- * yylex() is called, initialization will occur. */
2445
- yy_init_globals( yyscanner);
2446
-
2447
- /* Destroy the main struct (reentrant only). */
2448
- yyfree ( yyscanner , yyscanner );
2449
- yyscanner = NULL;
2450
- return 0;
2451
- }
2452
-
2453
- /*
2454
- * Internal utility routines.
2455
- */
2456
-
2457
- #ifndef yytext_ptr
2458
- static void yy_flex_strncpy (char* s1, const char * s2, int n , yyscan_t yyscanner)
2459
- {
2460
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2461
- (void)yyg;
2462
-
2463
- int i;
2464
- for ( i = 0; i < n; ++i )
2465
- s1[i] = s2[i];
2466
- }
2467
- #endif
2468
-
2469
- #ifdef YY_NEED_STRLEN
2470
- static int yy_flex_strlen (const char * s , yyscan_t yyscanner)
2471
- {
2472
- int n;
2473
- for ( n = 0; s[n]; ++n )
2474
- ;
2475
-
2476
- return n;
2477
- }
2478
- #endif
2479
-
2480
- void *yyalloc (yy_size_t size , yyscan_t yyscanner)
2481
- {
2482
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2483
- (void)yyg;
2484
- return malloc(size);
2485
- }
2486
-
2487
- void *yyrealloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2488
- {
2489
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2490
- (void)yyg;
2491
-
2492
- /* The cast to (char *) in the following accommodates both
2493
- * implementations that use char* generic pointers, and those
2494
- * that use void* generic pointers. It works with the latter
2495
- * because both ANSI C and C++ allow castless assignment from
2496
- * any pointer type to void*, and deal with argument conversions
2497
- * as though doing an assignment.
2498
- */
2499
- return realloc(ptr, size);
2500
- }
2501
-
2502
- void yyfree (void * ptr , yyscan_t yyscanner)
2503
- {
2504
- struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2505
- (void)yyg;
2506
- free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
2507
- }
2508
-
2509
- #define YYTABLES_NAME "yytables"
2510
-
2511
- #line 205 "lexer.lpp"
2512
-
2513
-
2514
- static void escape(char c, char *buf) {
2515
- if (std::isgraph(c)) {
2516
- *buf = c;
2517
- buf[1] = '\0';
2518
- } else {
2519
- buf[0] = '\\';
2520
- buf[2] = '\0';
2521
- switch (c) {
2522
- case '\a':
2523
- buf[1] = 'a';
2524
- break;
2525
- case '\b':
2526
- buf[1] = 'b';
2527
- break;
2528
- case '\f':
2529
- buf[1] = 'f';
2530
- break;
2531
- case '\n':
2532
- buf[1] = 'n';
2533
- break;
2534
- case '\r':
2535
- buf[1] = 'r';
2536
- break;
2537
- case '\t':
2538
- buf[1] = 't';
2539
- break;
2540
- case '\v':
2541
- buf[1] = 'v';
2542
- break;
2543
- default:
2544
- buf[1] = 'x';
2545
- std::snprintf(buf + 2, 3, "%x", ((int)c & 0xFF));
2546
- break;
2547
- }
2548
- }
2549
- }
2550
-
2551
- static std::vector<std::string> splitLines(const std::string &str) {
2552
- std::vector<std::string> lines;
2553
- auto it = str.begin();
2554
- while (it != str.end()) {
2555
- static char terminators[2] = {'\r', '\n'};
2556
- auto nextIt = std::find_first_of(it, str.end(), terminators, terminators + sizeof(terminators));
2557
- lines.emplace_back(str.data() + (it - str.begin()), nextIt - it);
2558
- if (nextIt != str.end()) {
2559
- auto advancedIt = nextIt + 1;
2560
- if (advancedIt != str.end()) {
2561
- if (*nextIt == '\r' && *advancedIt == '\n') {
2562
- ++advancedIt;
2563
- }
2564
- }
2565
- nextIt = std::move(advancedIt);
2566
- }
2567
- it = std::move(nextIt);
2568
- }
2569
- return lines;
2570
- }
2571
-
2572
- static int count_leading_whitespace(const std::string &str) {
2573
- auto pos = str.find_first_not_of(" \t", 0, strlen(" \t"));
2574
- if (pos == std::string::npos) {
2575
- return str.length();
2576
- }
2577
- return pos;
2578
- }
2579
-
2580
- static bool is_all_whitespace(const std::string &str) {
2581
- return count_leading_whitespace(str) == str.length();
2582
- }
2583
-
2584
- static std::string clean_up_block_string(const std::string &str) {
2585
- auto lines = splitLines(str);
2586
- bool first = true;
2587
- int commonIndent = INT_MAX;
2588
- for (const auto &line : lines) {
2589
- if (first) {
2590
- first = false;
2591
- continue;
2592
- }
2593
- const auto indent = count_leading_whitespace(line);
2594
- if (indent < line.length()) {
2595
- if (indent < commonIndent) {
2596
- commonIndent = indent;
2597
- }
2598
- }
2599
- }
2600
- if (commonIndent != INT_MAX) {
2601
- first = true;
2602
- for (auto &line : lines) {
2603
- if (first) {
2604
- first = false;
2605
- continue;
2606
- }
2607
- line.erase(0, commonIndent);
2608
- }
2609
- }
2610
-
2611
- const auto firstNonBlankIt = std::find_if(lines.begin(), lines.end(), [](const std::string &line) {
2612
- return !is_all_whitespace(line);
2613
- });
2614
- lines.erase(lines.begin(), firstNonBlankIt);
2615
-
2616
- const auto firstNonBlankReverseIt = std::find_if(lines.rbegin(), lines.rend(), [](const std::string &line) {
2617
- return !is_all_whitespace(line);
2618
- });
2619
- lines.erase(lines.end() - (firstNonBlankReverseIt - lines.rbegin()), lines.end());
2620
-
2621
- std::string formatted;
2622
- first = true;
2623
- for (const auto &line: lines) {
2624
- if (first) {
2625
- first = false;
2626
- } else {
2627
- formatted.push_back('\n');
2628
- }
2629
- formatted.append(line);
2630
- }
2631
- return formatted;
2632
- }
2633
-