langscan 1.2-x86-mswin32-60

Sign up to get free protection for your applications and to get access to all the features.
Files changed (180) hide show
  1. data/AUTHORS.txt +19 -0
  2. data/History.txt +126 -0
  3. data/Manifest.txt +167 -0
  4. data/README.rdoc +91 -0
  5. data/Rakefile +40 -0
  6. data/ext/langscan/_make_c.rb +20 -0
  7. data/ext/langscan/_make_h.rb +30 -0
  8. data/ext/langscan/_template.c +134 -0
  9. data/ext/langscan/_template.h +53 -0
  10. data/ext/langscan/c/c/Makefile +188 -0
  11. data/ext/langscan/c/c/c.c +134 -0
  12. data/ext/langscan/c/c/c.h +66 -0
  13. data/ext/langscan/c/c/ctok.c +4629 -0
  14. data/ext/langscan/c/c/ctok.l +212 -0
  15. data/ext/langscan/c/c/extconf.rb +3 -0
  16. data/ext/langscan/c/c/modulename.txt +1 -0
  17. data/ext/langscan/c/c/tokenlist.txt +13 -0
  18. data/ext/langscan/csharp/csharp/Makefile +188 -0
  19. data/ext/langscan/csharp/csharp/csharp.c +134 -0
  20. data/ext/langscan/csharp/csharp/csharp.h +65 -0
  21. data/ext/langscan/csharp/csharp/csharptok.c +2971 -0
  22. data/ext/langscan/csharp/csharp/csharptok.l +200 -0
  23. data/ext/langscan/csharp/csharp/extconf.rb +3 -0
  24. data/ext/langscan/csharp/csharp/modulename.txt +1 -0
  25. data/ext/langscan/csharp/csharp/tokenlist.txt +12 -0
  26. data/ext/langscan/d/d/Makefile +188 -0
  27. data/ext/langscan/d/d/d.c +134 -0
  28. data/ext/langscan/d/d/d.h +64 -0
  29. data/ext/langscan/d/d/dtok.c +5468 -0
  30. data/ext/langscan/d/d/dtok.l +282 -0
  31. data/ext/langscan/d/d/extconf.rb +3 -0
  32. data/ext/langscan/d/d/modulename.txt +1 -0
  33. data/ext/langscan/d/d/tokenlist.txt +11 -0
  34. data/ext/langscan/elisp/elisp/Makefile +188 -0
  35. data/ext/langscan/elisp/elisp/elisp.c +134 -0
  36. data/ext/langscan/elisp/elisp/elisp.h +62 -0
  37. data/ext/langscan/elisp/elisp/elisptok.c +2108 -0
  38. data/ext/langscan/elisp/elisp/elisptok.l +151 -0
  39. data/ext/langscan/elisp/elisp/extconf.rb +3 -0
  40. data/ext/langscan/elisp/elisp/modulename.txt +1 -0
  41. data/ext/langscan/elisp/elisp/tokenlist.txt +9 -0
  42. data/ext/langscan/java/java/Makefile +188 -0
  43. data/ext/langscan/java/java/extconf.rb +3 -0
  44. data/ext/langscan/java/java/java.c +134 -0
  45. data/ext/langscan/java/java/java.h +64 -0
  46. data/ext/langscan/java/java/javatok.c +2097 -0
  47. data/ext/langscan/java/java/javatok.l +155 -0
  48. data/ext/langscan/java/java/modulename.txt +1 -0
  49. data/ext/langscan/java/java/tokenlist.txt +11 -0
  50. data/ext/langscan/javascript/javascript/Makefile +188 -0
  51. data/ext/langscan/javascript/javascript/extconf.rb +3 -0
  52. data/ext/langscan/javascript/javascript/javascript.c +134 -0
  53. data/ext/langscan/javascript/javascript/javascript.h +63 -0
  54. data/ext/langscan/javascript/javascript/javascripttok.c +2058 -0
  55. data/ext/langscan/javascript/javascript/javascripttok.l +147 -0
  56. data/ext/langscan/javascript/javascript/modulename.txt +1 -0
  57. data/ext/langscan/javascript/javascript/tokenlist.txt +10 -0
  58. data/ext/langscan/pairmatcher/pairmatcher/Makefile +188 -0
  59. data/ext/langscan/pairmatcher/pairmatcher/extconf.rb +3 -0
  60. data/ext/langscan/pairmatcher/pairmatcher/pairmatcher.c +890 -0
  61. data/ext/langscan/php/php/Makefile +188 -0
  62. data/ext/langscan/php/php/extconf.rb +3 -0
  63. data/ext/langscan/php/php/modulename.txt +1 -0
  64. data/ext/langscan/php/php/php.c +134 -0
  65. data/ext/langscan/php/php/php.h +64 -0
  66. data/ext/langscan/php/php/phptok.c +2413 -0
  67. data/ext/langscan/php/php/phptok.l +212 -0
  68. data/ext/langscan/php/php/tokenlist.txt +11 -0
  69. data/ext/langscan/post-distclean.rb +21 -0
  70. data/ext/langscan/pre-config.rb +57 -0
  71. data/ext/langscan/python/python/Makefile +188 -0
  72. data/ext/langscan/python/python/extconf.rb +3 -0
  73. data/ext/langscan/python/python/modulename.txt +1 -0
  74. data/ext/langscan/python/python/python.c +134 -0
  75. data/ext/langscan/python/python/python.h +61 -0
  76. data/ext/langscan/python/python/pythontok.c +2109 -0
  77. data/ext/langscan/python/python/pythontok.l +155 -0
  78. data/ext/langscan/python/python/tokenlist.txt +8 -0
  79. data/ext/langscan/ruby/compat/ripper/Makefile +189 -0
  80. data/ext/langscan/ruby/compat/ripper/depend +1 -0
  81. data/ext/langscan/ruby/compat/ripper/extconf.rb +4 -0
  82. data/ext/langscan/ruby/compat/ripper/include/eventids1.c +251 -0
  83. data/ext/langscan/ruby/compat/ripper/include/eventids2.c +277 -0
  84. data/ext/langscan/ruby/compat/ripper/include/lex.c +138 -0
  85. data/ext/langscan/ruby/compat/ripper/ripper.c +14420 -0
  86. data/ext/langscan/scheme/scheme/Makefile +188 -0
  87. data/ext/langscan/scheme/scheme/extconf.rb +3 -0
  88. data/ext/langscan/scheme/scheme/modulename.txt +1 -0
  89. data/ext/langscan/scheme/scheme/scheme.c +134 -0
  90. data/ext/langscan/scheme/scheme/scheme.h +60 -0
  91. data/ext/langscan/scheme/scheme/schemetok.c +2454 -0
  92. data/ext/langscan/scheme/scheme/schemetok.l +177 -0
  93. data/ext/langscan/scheme/scheme/tokenlist.txt +7 -0
  94. data/ext/langscan/sh/sh/Makefile +188 -0
  95. data/ext/langscan/sh/sh/extconf.rb +3 -0
  96. data/ext/langscan/sh/sh/modulename.txt +1 -0
  97. data/ext/langscan/sh/sh/sh.c +134 -0
  98. data/ext/langscan/sh/sh/sh.h +61 -0
  99. data/ext/langscan/sh/sh/shtok.c +2477 -0
  100. data/ext/langscan/sh/sh/shtok.l +325 -0
  101. data/ext/langscan/sh/sh/tokenlist.txt +8 -0
  102. data/lib/langscan.rb +124 -0
  103. data/lib/langscan/_common.rb +50 -0
  104. data/lib/langscan/_easyscanner.rb +78 -0
  105. data/lib/langscan/_pairmatcher.rb +46 -0
  106. data/lib/langscan/_type.rb +125 -0
  107. data/lib/langscan/autoconf.rb +51 -0
  108. data/lib/langscan/automake.rb +51 -0
  109. data/lib/langscan/brainfuck.rb +48 -0
  110. data/lib/langscan/c.rb +144 -0
  111. data/lib/langscan/c/c.so +0 -0
  112. data/lib/langscan/csharp.rb +101 -0
  113. data/lib/langscan/csharp/csharp.so +0 -0
  114. data/lib/langscan/css.rb +109 -0
  115. data/lib/langscan/d.rb +201 -0
  116. data/lib/langscan/d/d.so +0 -0
  117. data/lib/langscan/eiffel.rb +167 -0
  118. data/lib/langscan/elisp.rb +132 -0
  119. data/lib/langscan/elisp/elisp.so +0 -0
  120. data/lib/langscan/io.rb +84 -0
  121. data/lib/langscan/java.rb +95 -0
  122. data/lib/langscan/java/java.so +0 -0
  123. data/lib/langscan/javascript.rb +97 -0
  124. data/lib/langscan/javascript/javascript.so +0 -0
  125. data/lib/langscan/lua.rb +116 -0
  126. data/lib/langscan/ocaml.rb +298 -0
  127. data/lib/langscan/ocaml/camlexer.ml +28 -0
  128. data/lib/langscan/ocaml/lexer.mll +230 -0
  129. data/lib/langscan/ocaml/types.ml +36 -0
  130. data/lib/langscan/pairmatcher/pairmatcher.so +0 -0
  131. data/lib/langscan/perl.rb +87 -0
  132. data/lib/langscan/perl/tokenizer.pl +231 -0
  133. data/lib/langscan/php.rb +80 -0
  134. data/lib/langscan/php/php.so +0 -0
  135. data/lib/langscan/python.rb +101 -0
  136. data/lib/langscan/python/python.so +0 -0
  137. data/lib/langscan/rpmspec.rb +71 -0
  138. data/lib/langscan/ruby.rb +164 -0
  139. data/lib/langscan/ruby/compat/README +5 -0
  140. data/lib/langscan/ruby/compat/ripper.rb +4 -0
  141. data/lib/langscan/ruby/compat/ripper.so +0 -0
  142. data/lib/langscan/ruby/compat/ripper/core.rb +918 -0
  143. data/lib/langscan/ruby/compat/ripper/filter.rb +70 -0
  144. data/lib/langscan/ruby/compat/ripper/lexer.rb +179 -0
  145. data/lib/langscan/ruby/compat/ripper/sexp.rb +100 -0
  146. data/lib/langscan/scheme.rb +160 -0
  147. data/lib/langscan/scheme/scheme.so +0 -0
  148. data/lib/langscan/sh.rb +116 -0
  149. data/lib/langscan/sh/sh.so +0 -0
  150. data/lib/langscan/text.rb +37 -0
  151. data/metaconfig +2 -0
  152. data/script/console +10 -0
  153. data/script/destroy +14 -0
  154. data/script/generate +14 -0
  155. data/script/makemanifest.rb +21 -0
  156. data/setup.rb +1604 -0
  157. data/tasks/extconf.rake +13 -0
  158. data/tasks/extconf/langscan.rake +42 -0
  159. data/test/langscan/brainfuck/test/test_scan.rb +55 -0
  160. data/test/langscan/c/test/test_scan.rb +216 -0
  161. data/test/langscan/c/test/test_token.rb +41 -0
  162. data/test/langscan/csharp/test/test_scan.rb +157 -0
  163. data/test/langscan/css/test/test_css.rb +79 -0
  164. data/test/langscan/d/test/test_scan.rb +233 -0
  165. data/test/langscan/d/test/test_token.rb +205 -0
  166. data/test/langscan/eiffel/test/test_eiffel.rb +95 -0
  167. data/test/langscan/elisp/test/test_elisp.rb +177 -0
  168. data/test/langscan/io/test/test_io.rb +79 -0
  169. data/test/langscan/java/test/test_java.rb +74 -0
  170. data/test/langscan/javascript/test/test_javascript.rb +39 -0
  171. data/test/langscan/lua/test/test_lua.rb +69 -0
  172. data/test/langscan/ocaml/test/test_ocaml.rb +161 -0
  173. data/test/langscan/php/test/test_scan.rb +138 -0
  174. data/test/langscan/python/test/test_scan.rb +105 -0
  175. data/test/langscan/rpmspec/test/test_rpmspec.rb +51 -0
  176. data/test/langscan/ruby/test/test_scan.rb +71 -0
  177. data/test/langscan/scheme/test/test_scan.rb +198 -0
  178. data/test/test_helper.rb +7 -0
  179. data/test/test_langscan.rb +123 -0
  180. metadata +320 -0
@@ -0,0 +1,3 @@
1
+ require "mkmf"
2
+ dir_config( 'include' )
3
+ create_makefile('langscan/python/python')
@@ -0,0 +1,134 @@
1
+ /* -*- mode: C; indent-tabs-mode: nil; c-basic-offset: 2 c-style: "BSD" -*- */
2
+ /*
3
+ * _template.c - a template file for LangScan modules
4
+ *
5
+ * Copyright (C) 2004-2005 Akira Tanaka <akr@m17n.org>
6
+ * All rights reserved.
7
+ * This is free software with ABSOLUTELY NO WARRANTY.
8
+ *
9
+ * You can redistribute it and/or modify it under the terms of
10
+ * the GNU General Public License version 2.
11
+ */
12
+
13
+
14
+ #include <ruby.h>
15
+ #include "python.h"
16
+
17
+ static VALUE token_symbol_list[
18
+ #define LANGSCAN_PYTHON_TOKEN(token) 1 +
19
+ 1 + LANGSCAN_PYTHON_TOKEN_LIST 0
20
+ #undef LANGSCAN_PYTHON_TOKEN
21
+ ];
22
+
23
+ #ifndef RSTRING_PTR
24
+ # define RSTRING_PTR(str) (RSTRING(str)->ptr)
25
+ #endif
26
+ #ifndef RSTRING_LEN
27
+ # define RSTRING_LEN(str) (RSTRING(str)->len)
28
+ #endif
29
+
30
+ #ifndef RARRAY_PTR
31
+ # define RARRAY_PTR(str) (RARRAY(str)->ptr)
32
+ #endif
33
+ #ifndef RARRAY_LEN
34
+ # define RARRAY_LEN(str) (RARRAY(str)->len)
35
+ #endif
36
+
37
+ static size_t user_read_str(void **user_data_p, char *buf, size_t maxlen)
38
+ {
39
+ VALUE user_data = (VALUE)*user_data_p;
40
+ VALUE user_str = RARRAY_PTR(user_data)[0];
41
+ VALUE user_off = RARRAY_PTR(user_data)[1];
42
+ long off = NUM2LONG(user_off);
43
+ if (RSTRING_LEN(user_str)-off < maxlen) {
44
+ maxlen = RSTRING_LEN(user_str)-off;
45
+ }
46
+ memcpy(buf, RSTRING_PTR(user_str)+off, maxlen);
47
+ RARRAY_PTR(user_data)[1] = LONG2NUM(off+maxlen);
48
+ return maxlen;
49
+ }
50
+
51
+ static void tokenizer_mark(langscan_python_tokenizer_t *tokenizer)
52
+ {
53
+ if (tokenizer == NULL)
54
+ return;
55
+ rb_gc_mark((VALUE)langscan_python_tokenizer_get_user_data(tokenizer));
56
+ }
57
+
58
+ static void tokenizer_free(langscan_python_tokenizer_t *tokenizer)
59
+ {
60
+ if (tokenizer == NULL)
61
+ return;
62
+ langscan_python_free_tokenizer(tokenizer);
63
+ }
64
+
65
+ static VALUE tokenizer_s_allocate(VALUE klass)
66
+ {
67
+ return Data_Wrap_Struct(klass, tokenizer_mark, tokenizer_free, NULL);
68
+ }
69
+
70
+ static VALUE tokenizer_initialize(VALUE self, VALUE user_data)
71
+ {
72
+ VALUE tmp;
73
+ user_read_t user_read;
74
+ langscan_python_tokenizer_t *tokenizer;
75
+ Data_Get_Struct(self, langscan_python_tokenizer_t, tokenizer);
76
+ StringValue(user_data);
77
+ user_read = user_read_str;
78
+ user_data = rb_ary_new3(2, rb_str_new4(user_data), INT2FIX(0));
79
+ RBASIC(user_data)->klass = 0;
80
+ DATA_PTR(self) = langscan_python_make_tokenizer(user_read, (void *)user_data);
81
+ return self;
82
+ }
83
+
84
+ static VALUE tokenizer_get_token(VALUE self)
85
+ {
86
+ langscan_python_tokenizer_t *tokenizer;
87
+ langscan_python_token_t token;
88
+ Data_Get_Struct(self, langscan_python_tokenizer_t, tokenizer);
89
+ if (tokenizer == NULL) { return Qnil; }
90
+ token = langscan_python_get_token(tokenizer);
91
+ if (token == langscan_python_eof) {
92
+ DATA_PTR(self) = NULL;
93
+ langscan_python_free_tokenizer(tokenizer);
94
+ return Qnil;
95
+ }
96
+ return rb_ary_new3(8,
97
+ token_symbol_list[token],
98
+ rb_str_new(langscan_python_curtoken_text(tokenizer), langscan_python_curtoken_leng(tokenizer)),
99
+ INT2NUM(langscan_python_curtoken_beg_lineno(tokenizer)),
100
+ INT2NUM(langscan_python_curtoken_beg_columnno(tokenizer)),
101
+ INT2NUM(langscan_python_curtoken_beg_byteno(tokenizer)),
102
+ INT2NUM(langscan_python_curtoken_end_lineno(tokenizer)),
103
+ INT2NUM(langscan_python_curtoken_end_columnno(tokenizer)),
104
+ INT2NUM(langscan_python_curtoken_end_byteno(tokenizer)));
105
+ }
106
+
107
+ static VALUE tokenizer_close(VALUE self)
108
+ {
109
+ langscan_python_tokenizer_t *tokenizer;
110
+ Data_Get_Struct(self, langscan_python_tokenizer_t, tokenizer);
111
+ if (tokenizer == NULL) { return Qnil; }
112
+ DATA_PTR(self) = NULL;
113
+ langscan_python_free_tokenizer(tokenizer);
114
+ return Qnil;
115
+ }
116
+
117
+ void Init_python()
118
+ {
119
+ VALUE LangScan = rb_define_module("LangScan");
120
+ VALUE LangScan_PYTHON = rb_define_module_under(LangScan, "Python");
121
+ VALUE Tokenizer = rb_define_class_under(LangScan_PYTHON, "Tokenizer", rb_cData);
122
+ langscan_python_token_t token_id;
123
+
124
+ token_id = 0;
125
+ token_symbol_list[token_id++] = Qnil;
126
+ #define LANGSCAN_PYTHON_TOKEN(token) token_symbol_list[token_id++] = ID2SYM(rb_intern(#token));
127
+ LANGSCAN_PYTHON_TOKEN_LIST
128
+ #undef LANGSCAN_PYTHON_TOKEN
129
+
130
+ rb_define_alloc_func(Tokenizer, tokenizer_s_allocate);
131
+ rb_define_method(Tokenizer, "initialize", tokenizer_initialize, 1);
132
+ rb_define_method(Tokenizer, "get_token", tokenizer_get_token, 0);
133
+ rb_define_method(Tokenizer, "close", tokenizer_close, 0);
134
+ }
@@ -0,0 +1,61 @@
1
+ #ifndef LANGSCAN_PYTHON_H
2
+ #define LANGSCAN_PYTHON_H
3
+
4
+ #define LANGSCAN_PYTHON_TOKEN_LIST \
5
+ LANGSCAN_PYTHON_TOKEN(integer) \
6
+ LANGSCAN_PYTHON_TOKEN(floating) \
7
+ LANGSCAN_PYTHON_TOKEN(imaginary) \
8
+ LANGSCAN_PYTHON_TOKEN(string) \
9
+ LANGSCAN_PYTHON_TOKEN(ident) \
10
+ LANGSCAN_PYTHON_TOKEN(punct) \
11
+ LANGSCAN_PYTHON_TOKEN(comment) \
12
+ LANGSCAN_PYTHON_TOKEN(space)
13
+
14
+ typedef enum {
15
+ langscan_python_eof = 0,
16
+ #define LANGSCAN_PYTHON_TOKEN(name) langscan_python_##name,
17
+ LANGSCAN_PYTHON_TOKEN_LIST
18
+ #undef LANGSCAN_PYTHON_TOKEN
19
+ } langscan_python_token_t;
20
+
21
+ typedef struct {
22
+ int beg_lineno;
23
+ int beg_columnno;
24
+ int beg_byteno;
25
+ int end_lineno;
26
+ int end_columnno;
27
+ int end_byteno;
28
+ int eof;
29
+ char *text;
30
+ int leng;
31
+ size_t (*user_read)(void **user_data_p, char *buf, size_t maxlen);
32
+ void *user_data;
33
+ } langscan_python_lex_extra_t;
34
+
35
+ typedef struct langscan_python_tokenizer_tag {
36
+ langscan_python_lex_extra_t *extra;
37
+ void *scanner;
38
+ } langscan_python_tokenizer_t;
39
+
40
+ typedef size_t (*user_read_t)(void **user_data_p, char *buf, size_t maxlen);
41
+
42
+ langscan_python_tokenizer_t *langscan_python_make_tokenizer(user_read_t user_read, void *user_data);
43
+ langscan_python_token_t langscan_python_get_token(langscan_python_tokenizer_t *tokenizer);
44
+ void langscan_python_free_tokenizer(langscan_python_tokenizer_t *tokenizer);
45
+
46
+ user_read_t langscan_python_tokenizer_get_user_read(langscan_python_tokenizer_t *tokenizer);
47
+ void *langscan_python_tokenizer_get_user_data(langscan_python_tokenizer_t *tokenizer);
48
+
49
+ const char *langscan_python_token_name(langscan_python_token_t token);
50
+ #define langscan_python_curtoken_beg_lineno(tokenizer) ((tokenizer)->extra->beg_lineno)
51
+ #define langscan_python_curtoken_beg_columnno(tokenizer) ((tokenizer)->extra->beg_columnno)
52
+ #define langscan_python_curtoken_beg_byteno(tokenizer) ((tokenizer)->extra->beg_byteno)
53
+ #define langscan_python_curtoken_end_lineno(tokenizer) ((tokenizer)->extra->end_lineno)
54
+ #define langscan_python_curtoken_end_columnno(tokenizer) ((tokenizer)->extra->end_columnno)
55
+ #define langscan_python_curtoken_end_byteno(tokenizer) ((tokenizer)->extra->end_byteno)
56
+ #define langscan_python_curtoken_text(tokenizer) ((tokenizer)->extra->text)
57
+ #define langscan_python_curtoken_leng(tokenizer) ((tokenizer)->extra->leng)
58
+
59
+ void langscan_python_extract_functions(langscan_python_tokenizer_t *);
60
+
61
+ #endif
@@ -0,0 +1,2109 @@
1
+
2
+ #line 3 "<stdout>"
3
+
4
+ #define YY_INT_ALIGNED short int
5
+
6
+ /* A lexical scanner generated by flex */
7
+
8
+ #define FLEX_SCANNER
9
+ #define YY_FLEX_MAJOR_VERSION 2
10
+ #define YY_FLEX_MINOR_VERSION 5
11
+ #define YY_FLEX_SUBMINOR_VERSION 35
12
+ #if YY_FLEX_SUBMINOR_VERSION > 0
13
+ #define FLEX_BETA
14
+ #endif
15
+
16
+ /* First, we deal with platform-specific or compiler-specific issues. */
17
+
18
+ /* begin standard C headers. */
19
+ #include <stdio.h>
20
+ #include <string.h>
21
+ #include <errno.h>
22
+ #include <stdlib.h>
23
+
24
+ /* end standard C headers. */
25
+
26
+ /* flex integer type definitions */
27
+
28
+ #ifndef FLEXINT_H
29
+ #define FLEXINT_H
30
+
31
+ /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
32
+
33
+ #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
34
+
35
+ /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
36
+ * if you want the limit (max/min) macros for int types.
37
+ */
38
+ #ifndef __STDC_LIMIT_MACROS
39
+ #define __STDC_LIMIT_MACROS 1
40
+ #endif
41
+
42
+ #include <inttypes.h>
43
+ typedef int8_t flex_int8_t;
44
+ typedef uint8_t flex_uint8_t;
45
+ typedef int16_t flex_int16_t;
46
+ typedef uint16_t flex_uint16_t;
47
+ typedef int32_t flex_int32_t;
48
+ typedef uint32_t flex_uint32_t;
49
+ #else
50
+ typedef signed char flex_int8_t;
51
+ typedef short int flex_int16_t;
52
+ typedef int flex_int32_t;
53
+ typedef unsigned char flex_uint8_t;
54
+ typedef unsigned short int flex_uint16_t;
55
+ typedef unsigned int flex_uint32_t;
56
+
57
+ /* Limits of integral types. */
58
+ #ifndef INT8_MIN
59
+ #define INT8_MIN (-128)
60
+ #endif
61
+ #ifndef INT16_MIN
62
+ #define INT16_MIN (-32767-1)
63
+ #endif
64
+ #ifndef INT32_MIN
65
+ #define INT32_MIN (-2147483647-1)
66
+ #endif
67
+ #ifndef INT8_MAX
68
+ #define INT8_MAX (127)
69
+ #endif
70
+ #ifndef INT16_MAX
71
+ #define INT16_MAX (32767)
72
+ #endif
73
+ #ifndef INT32_MAX
74
+ #define INT32_MAX (2147483647)
75
+ #endif
76
+ #ifndef UINT8_MAX
77
+ #define UINT8_MAX (255U)
78
+ #endif
79
+ #ifndef UINT16_MAX
80
+ #define UINT16_MAX (65535U)
81
+ #endif
82
+ #ifndef UINT32_MAX
83
+ #define UINT32_MAX (4294967295U)
84
+ #endif
85
+
86
+ #endif /* ! C99 */
87
+
88
+ #endif /* ! FLEXINT_H */
89
+
90
+ #ifdef __cplusplus
91
+
92
+ /* The "const" storage-class-modifier is valid. */
93
+ #define YY_USE_CONST
94
+
95
+ #else /* ! __cplusplus */
96
+
97
+ /* C99 requires __STDC__ to be defined as 1. */
98
+ #if defined (__STDC__)
99
+
100
+ #define YY_USE_CONST
101
+
102
+ #endif /* defined (__STDC__) */
103
+ #endif /* ! __cplusplus */
104
+
105
+ #ifdef YY_USE_CONST
106
+ #define yyconst const
107
+ #else
108
+ #define yyconst
109
+ #endif
110
+
111
+ /* Returned upon end-of-file. */
112
+ #define YY_NULL 0
113
+
114
+ /* Promotes a possibly negative, possibly signed char to an unsigned
115
+ * integer for use as an array index. If the signed char is negative,
116
+ * we want to instead treat it as an 8-bit unsigned char, hence the
117
+ * double cast.
118
+ */
119
+ #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
120
+
121
+ /* An opaque pointer. */
122
+ #ifndef YY_TYPEDEF_YY_SCANNER_T
123
+ #define YY_TYPEDEF_YY_SCANNER_T
124
+ typedef void* yyscan_t;
125
+ #endif
126
+
127
+ /* For convenience, these vars (plus the bison vars far below)
128
+ are macros in the reentrant scanner. */
129
+ #define yyin yyg->yyin_r
130
+ #define yyout yyg->yyout_r
131
+ #define yyextra yyg->yyextra_r
132
+ #define yyleng yyg->yyleng_r
133
+ #define yytext yyg->yytext_r
134
+ #define yylineno (YY_CURRENT_BUFFER_LVALUE->yy_bs_lineno)
135
+ #define yycolumn (YY_CURRENT_BUFFER_LVALUE->yy_bs_column)
136
+ #define yy_flex_debug yyg->yy_flex_debug_r
137
+
138
+ /* Enter a start condition. This macro really ought to take a parameter,
139
+ * but we do it the disgusting crufty way forced on us by the ()-less
140
+ * definition of BEGIN.
141
+ */
142
+ #define BEGIN yyg->yy_start = 1 + 2 *
143
+
144
+ /* Translate the current start state into a value that can be later handed
145
+ * to BEGIN to return to the state. The YYSTATE alias is for lex
146
+ * compatibility.
147
+ */
148
+ #define YY_START ((yyg->yy_start - 1) / 2)
149
+ #define YYSTATE YY_START
150
+
151
+ /* Action number for EOF rule of a given start state. */
152
+ #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
153
+
154
+ /* Special action meaning "start processing a new file". */
155
+ #define YY_NEW_FILE langscan_python_lex_restart(yyin ,yyscanner )
156
+
157
+ #define YY_END_OF_BUFFER_CHAR 0
158
+
159
+ /* Size of default input buffer. */
160
+ #ifndef YY_BUF_SIZE
161
+ #ifdef __ia64__
162
+ /* On IA-64, the buffer size is 16k, not 8k.
163
+ * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
164
+ * Ditto for the __ia64__ case accordingly.
165
+ */
166
+ #define YY_BUF_SIZE 32768
167
+ #else
168
+ #define YY_BUF_SIZE 16384
169
+ #endif /* __ia64__ */
170
+ #endif
171
+
172
+ /* The state buf must be large enough to hold one state per character in the main buffer.
173
+ */
174
+ #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
175
+
176
+ #ifndef YY_TYPEDEF_YY_BUFFER_STATE
177
+ #define YY_TYPEDEF_YY_BUFFER_STATE
178
+ typedef struct yy_buffer_state *YY_BUFFER_STATE;
179
+ #endif
180
+
181
+ #define EOB_ACT_CONTINUE_SCAN 0
182
+ #define EOB_ACT_END_OF_FILE 1
183
+ #define EOB_ACT_LAST_MATCH 2
184
+
185
+ #define YY_LESS_LINENO(n)
186
+
187
+ /* Return all but the first "n" matched characters back to the input stream. */
188
+ #define yyless(n) \
189
+ do \
190
+ { \
191
+ /* Undo effects of setting up yytext. */ \
192
+ int yyless_macro_arg = (n); \
193
+ YY_LESS_LINENO(yyless_macro_arg);\
194
+ *yy_cp = yyg->yy_hold_char; \
195
+ YY_RESTORE_YY_MORE_OFFSET \
196
+ yyg->yy_c_buf_p = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
197
+ YY_DO_BEFORE_ACTION; /* set up yytext again */ \
198
+ } \
199
+ while ( 0 )
200
+
201
+ #define unput(c) yyunput( c, yyg->yytext_ptr , yyscanner )
202
+
203
+ #ifndef YY_TYPEDEF_YY_SIZE_T
204
+ #define YY_TYPEDEF_YY_SIZE_T
205
+ typedef size_t yy_size_t;
206
+ #endif
207
+
208
+ #ifndef YY_STRUCT_YY_BUFFER_STATE
209
+ #define YY_STRUCT_YY_BUFFER_STATE
210
+ struct yy_buffer_state
211
+ {
212
+ FILE *yy_input_file;
213
+
214
+ char *yy_ch_buf; /* input buffer */
215
+ char *yy_buf_pos; /* current position in input buffer */
216
+
217
+ /* Size of input buffer in bytes, not including room for EOB
218
+ * characters.
219
+ */
220
+ yy_size_t yy_buf_size;
221
+
222
+ /* Number of characters read into yy_ch_buf, not including EOB
223
+ * characters.
224
+ */
225
+ int yy_n_chars;
226
+
227
+ /* Whether we "own" the buffer - i.e., we know we created it,
228
+ * and can realloc() it to grow it, and should free() it to
229
+ * delete it.
230
+ */
231
+ int yy_is_our_buffer;
232
+
233
+ /* Whether this is an "interactive" input source; if so, and
234
+ * if we're using stdio for input, then we want to use getc()
235
+ * instead of fread(), to make sure we stop fetching input after
236
+ * each newline.
237
+ */
238
+ int yy_is_interactive;
239
+
240
+ /* Whether we're considered to be at the beginning of a line.
241
+ * If so, '^' rules will be active on the next match, otherwise
242
+ * not.
243
+ */
244
+ int yy_at_bol;
245
+
246
+ int yy_bs_lineno; /**< The line count. */
247
+ int yy_bs_column; /**< The column count. */
248
+
249
+ /* Whether to try to fill the input buffer when we reach the
250
+ * end of it.
251
+ */
252
+ int yy_fill_buffer;
253
+
254
+ int yy_buffer_status;
255
+
256
+ #define YY_BUFFER_NEW 0
257
+ #define YY_BUFFER_NORMAL 1
258
+ /* When an EOF's been seen but there's still some text to process
259
+ * then we mark the buffer as YY_EOF_PENDING, to indicate that we
260
+ * shouldn't try reading from the input source any more. We might
261
+ * still have a bunch of tokens to match, though, because of
262
+ * possible backing-up.
263
+ *
264
+ * When we actually see the EOF, we change the status to "new"
265
+ * (via langscan_python_lex_restart()), so that the user can continue scanning by
266
+ * just pointing yyin at a new input file.
267
+ */
268
+ #define YY_BUFFER_EOF_PENDING 2
269
+
270
+ };
271
+ #endif /* !YY_STRUCT_YY_BUFFER_STATE */
272
+
273
+ /* We provide macros for accessing buffer states in case in the
274
+ * future we want to put the buffer states in a more general
275
+ * "scanner state".
276
+ *
277
+ * Returns the top of the stack, or NULL.
278
+ */
279
+ #define YY_CURRENT_BUFFER ( yyg->yy_buffer_stack \
280
+ ? yyg->yy_buffer_stack[yyg->yy_buffer_stack_top] \
281
+ : NULL)
282
+
283
+ /* Same as previous macro, but useful when we know that the buffer stack is not
284
+ * NULL or when we need an lvalue. For internal use only.
285
+ */
286
+ #define YY_CURRENT_BUFFER_LVALUE yyg->yy_buffer_stack[yyg->yy_buffer_stack_top]
287
+
288
+ void langscan_python_lex_restart (FILE *input_file ,yyscan_t yyscanner );
289
+ void langscan_python_lex__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
290
+ YY_BUFFER_STATE langscan_python_lex__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
291
+ void langscan_python_lex__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
292
+ void langscan_python_lex__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
293
+ void langscan_python_lex_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
294
+ void langscan_python_lex_pop_buffer_state (yyscan_t yyscanner );
295
+
296
+ static void langscan_python_lex_ensure_buffer_stack (yyscan_t yyscanner );
297
+ static void langscan_python_lex__load_buffer_state (yyscan_t yyscanner );
298
+ static void langscan_python_lex__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
299
+
300
+ #define YY_FLUSH_BUFFER langscan_python_lex__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
301
+
302
+ YY_BUFFER_STATE langscan_python_lex__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
303
+ YY_BUFFER_STATE langscan_python_lex__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
304
+ YY_BUFFER_STATE langscan_python_lex__scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
305
+
306
+ void *langscan_python_lex_alloc (yy_size_t ,yyscan_t yyscanner );
307
+ void *langscan_python_lex_realloc (void *,yy_size_t ,yyscan_t yyscanner );
308
+ void langscan_python_lex_free (void * ,yyscan_t yyscanner );
309
+
310
+ #define yy_new_buffer langscan_python_lex__create_buffer
311
+
312
+ #define yy_set_interactive(is_interactive) \
313
+ { \
314
+ if ( ! YY_CURRENT_BUFFER ){ \
315
+ langscan_python_lex_ensure_buffer_stack (yyscanner); \
316
+ YY_CURRENT_BUFFER_LVALUE = \
317
+ langscan_python_lex__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
318
+ } \
319
+ YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
320
+ }
321
+
322
+ #define yy_set_bol(at_bol) \
323
+ { \
324
+ if ( ! YY_CURRENT_BUFFER ){\
325
+ langscan_python_lex_ensure_buffer_stack (yyscanner); \
326
+ YY_CURRENT_BUFFER_LVALUE = \
327
+ langscan_python_lex__create_buffer(yyin,YY_BUF_SIZE ,yyscanner); \
328
+ } \
329
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
330
+ }
331
+
332
+ #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
333
+
334
+ /* Begin user sect3 */
335
+
336
+ #define langscan_python_lex_wrap(n) 1
337
+ #define YY_SKIP_YYWRAP
338
+
339
+ typedef unsigned char YY_CHAR;
340
+
341
+ typedef int yy_state_type;
342
+
343
+ #define yytext_ptr yytext_r
344
+
345
+ static yy_state_type yy_get_previous_state (yyscan_t yyscanner );
346
+ static yy_state_type yy_try_NUL_trans (yy_state_type current_state ,yyscan_t yyscanner);
347
+ static int yy_get_next_buffer (yyscan_t yyscanner );
348
+ static void yy_fatal_error (yyconst char msg[] ,yyscan_t yyscanner );
349
+
350
+ /* Done after the current pattern has been matched and before the
351
+ * corresponding action - sets up yytext.
352
+ */
353
+ #define YY_DO_BEFORE_ACTION \
354
+ yyg->yytext_ptr = yy_bp; \
355
+ yyleng = (size_t) (yy_cp - yy_bp); \
356
+ yyg->yy_hold_char = *yy_cp; \
357
+ *yy_cp = '\0'; \
358
+ yyg->yy_c_buf_p = yy_cp;
359
+
360
+ #define YY_NUM_RULES 10
361
+ #define YY_END_OF_BUFFER 11
362
+ /* This struct is not used in this scanner,
363
+ but its presence is necessary. */
364
+ struct yy_trans_info
365
+ {
366
+ flex_int32_t yy_verify;
367
+ flex_int32_t yy_nxt;
368
+ };
369
+ static yyconst flex_int16_t yy_accept[65] =
370
+ { 0,
371
+ 0, 0, 11, 9, 1, 2, 2, 9, 3, 9,
372
+ 9, 5, 5, 8, 8, 8, 8, 1, 2, 0,
373
+ 4, 0, 3, 0, 4, 0, 6, 6, 5, 0,
374
+ 7, 5, 0, 8, 0, 0, 8, 4, 0, 0,
375
+ 0, 0, 0, 0, 5, 0, 0, 0, 0, 0,
376
+ 0, 0, 6, 0, 0, 0, 0, 0, 0, 6,
377
+ 4, 0, 0, 0
378
+ } ;
379
+
380
+ static yyconst flex_int32_t yy_ec[256] =
381
+ { 0,
382
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
383
+ 1, 2, 4, 1, 1, 1, 1, 1, 1, 1,
384
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
385
+ 1, 2, 1, 5, 6, 1, 1, 1, 7, 1,
386
+ 1, 1, 8, 1, 8, 9, 1, 10, 11, 11,
387
+ 11, 11, 11, 11, 11, 11, 11, 1, 1, 1,
388
+ 1, 1, 1, 1, 12, 12, 12, 12, 13, 12,
389
+ 14, 14, 14, 15, 14, 16, 14, 14, 14, 14,
390
+ 14, 17, 14, 14, 18, 14, 14, 19, 14, 14,
391
+ 1, 20, 1, 1, 14, 1, 12, 12, 12, 12,
392
+
393
+ 13, 12, 14, 14, 14, 15, 14, 16, 14, 14,
394
+ 14, 14, 14, 21, 14, 14, 22, 14, 14, 19,
395
+ 14, 14, 1, 1, 1, 1, 1, 1, 1, 1,
396
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
397
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
398
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
399
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
400
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
401
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
402
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
403
+
404
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
406
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409
+ 1, 1, 1, 1, 1
410
+ } ;
411
+
412
+ static yyconst flex_int32_t yy_meta[23] =
413
+ { 0,
414
+ 1, 1, 2, 3, 1, 1, 1, 1, 1, 4,
415
+ 4, 4, 4, 5, 5, 5, 5, 5, 5, 1,
416
+ 5, 5
417
+ } ;
418
+
419
+ static yyconst flex_int16_t yy_base[74] =
420
+ { 0,
421
+ 0, 0, 148, 149, 145, 149, 119, 18, 0, 17,
422
+ 15, 30, 102, 0, 22, 45, 0, 114, 149, 27,
423
+ 107, 27, 0, 28, 104, 30, 43, 47, 89, 99,
424
+ 149, 149, 0, 0, 31, 35, 54, 149, 58, 62,
425
+ 57, 65, 95, 59, 58, 66, 97, 97, 68, 93,
426
+ 95, 69, 73, 90, 71, 84, 37, 74, 89, 87,
427
+ 149, 85, 86, 149, 109, 114, 119, 121, 24, 126,
428
+ 131, 136, 141
429
+ } ;
430
+
431
+ static yyconst flex_int16_t yy_def[74] =
432
+ { 0,
433
+ 64, 1, 64, 64, 64, 64, 64, 65, 66, 67,
434
+ 64, 64, 12, 68, 68, 68, 16, 64, 64, 65,
435
+ 64, 65, 66, 67, 64, 67, 64, 64, 12, 64,
436
+ 64, 64, 69, 68, 65, 67, 68, 64, 70, 65,
437
+ 71, 67, 64, 64, 69, 70, 70, 72, 71, 71,
438
+ 73, 64, 64, 70, 70, 70, 71, 71, 71, 64,
439
+ 64, 70, 71, 0, 64, 64, 64, 64, 64, 64,
440
+ 64, 64, 64
441
+ } ;
442
+
443
+ static yyconst flex_int16_t yy_nxt[172] =
444
+ { 0,
445
+ 4, 5, 6, 7, 8, 9, 10, 4, 11, 12,
446
+ 13, 14, 14, 14, 14, 14, 15, 16, 14, 4,
447
+ 15, 17, 21, 25, 27, 27, 35, 45, 36, 20,
448
+ 40, 38, 24, 42, 38, 21, 26, 22, 28, 29,
449
+ 29, 25, 30, 61, 31, 32, 22, 26, 33, 35,
450
+ 22, 36, 27, 27, 26, 43, 27, 27, 35, 43,
451
+ 36, 37, 47, 50, 20, 37, 38, 24, 53, 53,
452
+ 47, 38, 31, 32, 50, 47, 51, 48, 60, 60,
453
+ 50, 22, 53, 53, 26, 48, 62, 51, 47, 47,
454
+ 48, 63, 50, 51, 61, 50, 60, 60, 59, 57,
455
+
456
+ 56, 54, 52, 48, 48, 51, 44, 64, 51, 20,
457
+ 41, 39, 20, 20, 23, 18, 23, 23, 23, 24,
458
+ 64, 19, 24, 24, 34, 34, 46, 46, 46, 46,
459
+ 46, 49, 49, 49, 49, 49, 55, 55, 55, 55,
460
+ 55, 58, 58, 58, 58, 58, 18, 64, 3, 64,
461
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
462
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
463
+ 64
464
+ } ;
465
+
466
+ static yyconst flex_int16_t yy_chk[172] =
467
+ { 0,
468
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
469
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
470
+ 1, 1, 8, 10, 11, 11, 15, 69, 15, 22,
471
+ 22, 20, 26, 26, 24, 35, 10, 8, 12, 12,
472
+ 12, 36, 12, 57, 12, 12, 20, 24, 12, 16,
473
+ 35, 16, 27, 27, 36, 27, 28, 28, 37, 28,
474
+ 37, 16, 39, 41, 40, 16, 40, 42, 44, 44,
475
+ 46, 42, 45, 45, 49, 55, 41, 39, 52, 52,
476
+ 58, 40, 53, 53, 42, 46, 56, 49, 56, 62,
477
+ 55, 59, 63, 58, 54, 59, 60, 60, 51, 50,
478
+
479
+ 48, 47, 43, 56, 62, 63, 30, 29, 59, 65,
480
+ 25, 21, 65, 65, 66, 18, 66, 66, 66, 67,
481
+ 13, 7, 67, 67, 68, 68, 70, 70, 70, 70,
482
+ 70, 71, 71, 71, 71, 71, 72, 72, 72, 72,
483
+ 72, 73, 73, 73, 73, 73, 5, 3, 64, 64,
484
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
485
+ 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,
486
+ 64
487
+ } ;
488
+
489
+ /* The intent behind this definition is that it'll catch
490
+ * any uses of REJECT which flex missed.
491
+ */
492
+ #define REJECT reject_used_but_not_detected
493
+ #define yymore() yymore_used_but_not_detected
494
+ #define YY_MORE_ADJ 0
495
+ #define YY_RESTORE_YY_MORE_OFFSET
496
+ /*
497
+ * pythontok.l - a lex rule for python
498
+ *
499
+ * Copyright (C) 2005 Yoshinori K. Okuji <okuji@enbug.org>
500
+ * All rights reserved.
501
+ * This is free software with ABSOLUTELY NO WARRANTY.
502
+ *
503
+ * You can redistribute it and/or modify it under the terms of
504
+ * the GNU General Public License version 2.
505
+ */
506
+
507
+ #include "python.h"
508
+
509
+ #define YY_EXTRA_TYPE langscan_python_lex_extra_t *
510
+
511
+ #if YY_NULL != 0
512
+ #error "YY_NULL is not 0."
513
+ #endif
514
+
515
+ #define YY_DECL langscan_python_token_t langscan_python_lex_lex(yyscan_t yyscanner)
516
+
517
+ #define YY_INPUT(buf,result,max_size) \
518
+ if (!yyextra->eof) { \
519
+ result = yyextra->user_read(&(yyextra->user_data), (buf), (max_size)); \
520
+ if (result == 0) \
521
+ yyextra->eof = 1; \
522
+ }
523
+
524
+ #define UPD update_pos(yyextra, yytext, yyleng)
525
+ static void update_pos(langscan_python_lex_extra_t *, char *, int);
526
+
527
+ #define report(token) \
528
+ do { \
529
+ yyextra->text = yytext; \
530
+ yyextra->leng = yyleng; \
531
+ return langscan_python_##token; \
532
+ } while (0)
533
+
534
+ #define INITIAL 0
535
+
536
+ #ifndef YY_EXTRA_TYPE
537
+ #define YY_EXTRA_TYPE void *
538
+ #endif
539
+
540
+ /* Holds the entire state of the reentrant scanner. */
541
+ struct yyguts_t
542
+ {
543
+
544
+ /* User-defined. Not touched by flex. */
545
+ YY_EXTRA_TYPE yyextra_r;
546
+
547
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
548
+ FILE *yyin_r, *yyout_r;
549
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
550
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
551
+ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
552
+ char yy_hold_char;
553
+ int yy_n_chars;
554
+ int yyleng_r;
555
+ char *yy_c_buf_p;
556
+ int yy_init;
557
+ int yy_start;
558
+ int yy_did_buffer_switch_on_eof;
559
+ int yy_start_stack_ptr;
560
+ int yy_start_stack_depth;
561
+ int *yy_start_stack;
562
+ yy_state_type yy_last_accepting_state;
563
+ char* yy_last_accepting_cpos;
564
+
565
+ int yylineno_r;
566
+ int yy_flex_debug_r;
567
+
568
+ char *yytext_r;
569
+ int yy_more_flag;
570
+ int yy_more_len;
571
+
572
+ }; /* end struct yyguts_t */
573
+
574
+ static int yy_init_globals (yyscan_t yyscanner );
575
+
576
+ int langscan_python_lex_lex_init (yyscan_t* scanner);
577
+
578
+ int langscan_python_lex_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
579
+
580
+ /* Accessor methods to globals.
581
+ These are made visible to non-reentrant scanners for convenience. */
582
+
583
+ int langscan_python_lex_lex_destroy (yyscan_t yyscanner );
584
+
585
+ int langscan_python_lex_get_debug (yyscan_t yyscanner );
586
+
587
+ void langscan_python_lex_set_debug (int debug_flag ,yyscan_t yyscanner );
588
+
589
+ YY_EXTRA_TYPE langscan_python_lex_get_extra (yyscan_t yyscanner );
590
+
591
+ void langscan_python_lex_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
592
+
593
+ FILE *langscan_python_lex_get_in (yyscan_t yyscanner );
594
+
595
+ void langscan_python_lex_set_in (FILE * in_str ,yyscan_t yyscanner );
596
+
597
+ FILE *langscan_python_lex_get_out (yyscan_t yyscanner );
598
+
599
+ void langscan_python_lex_set_out (FILE * out_str ,yyscan_t yyscanner );
600
+
601
+ int langscan_python_lex_get_leng (yyscan_t yyscanner );
602
+
603
+ char *langscan_python_lex_get_text (yyscan_t yyscanner );
604
+
605
+ int langscan_python_lex_get_lineno (yyscan_t yyscanner );
606
+
607
+ void langscan_python_lex_set_lineno (int line_number ,yyscan_t yyscanner );
608
+
609
+ /* Macros after this point can all be overridden by user definitions in
610
+ * section 1.
611
+ */
612
+
613
+ #ifndef YY_SKIP_YYWRAP
614
+ #ifdef __cplusplus
615
+ extern "C" int langscan_python_lex_wrap (yyscan_t yyscanner );
616
+ #else
617
+ extern int langscan_python_lex_wrap (yyscan_t yyscanner );
618
+ #endif
619
+ #endif
620
+
621
+ static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
622
+
623
+ #ifndef yytext_ptr
624
+ static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
625
+ #endif
626
+
627
+ #ifdef YY_NEED_STRLEN
628
+ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
629
+ #endif
630
+
631
+ #ifndef YY_NO_INPUT
632
+
633
+ #ifdef __cplusplus
634
+ static int yyinput (yyscan_t yyscanner );
635
+ #else
636
+ static int input (yyscan_t yyscanner );
637
+ #endif
638
+
639
+ #endif
640
+
641
+ /* Amount of stuff to slurp up with each read. */
642
+ #ifndef YY_READ_BUF_SIZE
643
+ #ifdef __ia64__
644
+ /* On IA-64, the buffer size is 16k, not 8k */
645
+ #define YY_READ_BUF_SIZE 16384
646
+ #else
647
+ #define YY_READ_BUF_SIZE 8192
648
+ #endif /* __ia64__ */
649
+ #endif
650
+
651
+ /* Copy whatever the last rule matched to the standard output. */
652
+ #ifndef ECHO
653
+ /* This used to be an fputs(), but since the string might contain NUL's,
654
+ * we now use fwrite().
655
+ */
656
+ #define ECHO do { if (fwrite( yytext, yyleng, 1, yyout )) {} } while (0)
657
+ #endif
658
+
659
+ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
660
+ * is returned in "result".
661
+ */
662
+ #ifndef YY_INPUT
663
+ #define YY_INPUT(buf,result,max_size) \
664
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
665
+ { \
666
+ int c = '*'; \
667
+ size_t n; \
668
+ for ( n = 0; n < max_size && \
669
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
670
+ buf[n] = (char) c; \
671
+ if ( c == '\n' ) \
672
+ buf[n++] = (char) c; \
673
+ if ( c == EOF && ferror( yyin ) ) \
674
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
675
+ result = n; \
676
+ } \
677
+ else \
678
+ { \
679
+ errno=0; \
680
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
681
+ { \
682
+ if( errno != EINTR) \
683
+ { \
684
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
685
+ break; \
686
+ } \
687
+ errno=0; \
688
+ clearerr(yyin); \
689
+ } \
690
+ }\
691
+ \
692
+
693
+ #endif
694
+
695
+ /* No semi-colon after return; correct usage is to write "yyterminate();" -
696
+ * we don't want an extra ';' after the "return" because that will cause
697
+ * some compilers to complain about unreachable statements.
698
+ */
699
+ #ifndef yyterminate
700
+ #define yyterminate() return YY_NULL
701
+ #endif
702
+
703
+ /* Number of entries by which start-condition stack grows. */
704
+ #ifndef YY_START_STACK_INCR
705
+ #define YY_START_STACK_INCR 25
706
+ #endif
707
+
708
+ /* Report a fatal error. */
709
+ #ifndef YY_FATAL_ERROR
710
+ #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
711
+ #endif
712
+
713
+ /* end tables serialization structures and prototypes */
714
+
715
+ /* Default declaration of generated scanner - a define so the user can
716
+ * easily add parameters.
717
+ */
718
+ #ifndef YY_DECL
719
+ #define YY_DECL_IS_OURS 1
720
+
721
+ extern int langscan_python_lex_lex (yyscan_t yyscanner);
722
+
723
+ #define YY_DECL int langscan_python_lex_lex (yyscan_t yyscanner)
724
+ #endif /* !YY_DECL */
725
+
726
+ /* Code executed at the beginning of each rule, after yytext and yyleng
727
+ * have been set up.
728
+ */
729
+ #ifndef YY_USER_ACTION
730
+ #define YY_USER_ACTION
731
+ #endif
732
+
733
+ /* Code executed at the end of each rule. */
734
+ #ifndef YY_BREAK
735
+ #define YY_BREAK break;
736
+ #endif
737
+
738
+ #define YY_RULE_SETUP \
739
+ YY_USER_ACTION
740
+
741
+ /** The main scanner function which does all the work.
742
+ */
743
+ YY_DECL
744
+ {
745
+ register yy_state_type yy_current_state;
746
+ register char *yy_cp, *yy_bp;
747
+ register int yy_act;
748
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
749
+
750
+ if ( !yyg->yy_init )
751
+ {
752
+ yyg->yy_init = 1;
753
+
754
+ #ifdef YY_USER_INIT
755
+ YY_USER_INIT;
756
+ #endif
757
+
758
+ if ( ! yyg->yy_start )
759
+ yyg->yy_start = 1; /* first start state */
760
+
761
+ if ( ! yyin )
762
+ yyin = stdin;
763
+
764
+ if ( ! yyout )
765
+ yyout = stdout;
766
+
767
+ if ( ! YY_CURRENT_BUFFER ) {
768
+ langscan_python_lex_ensure_buffer_stack (yyscanner);
769
+ YY_CURRENT_BUFFER_LVALUE =
770
+ langscan_python_lex__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
771
+ }
772
+
773
+ langscan_python_lex__load_buffer_state(yyscanner );
774
+ }
775
+
776
+ while ( 1 ) /* loops until end-of-file is reached */
777
+ {
778
+ yy_cp = yyg->yy_c_buf_p;
779
+
780
+ /* Support of yytext. */
781
+ *yy_cp = yyg->yy_hold_char;
782
+
783
+ /* yy_bp points to the position in yy_ch_buf of the start of
784
+ * the current run.
785
+ */
786
+ yy_bp = yy_cp;
787
+
788
+ yy_current_state = yyg->yy_start;
789
+ yy_match:
790
+ do
791
+ {
792
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
793
+ if ( yy_accept[yy_current_state] )
794
+ {
795
+ yyg->yy_last_accepting_state = yy_current_state;
796
+ yyg->yy_last_accepting_cpos = yy_cp;
797
+ }
798
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
799
+ {
800
+ yy_current_state = (int) yy_def[yy_current_state];
801
+ if ( yy_current_state >= 65 )
802
+ yy_c = yy_meta[(unsigned int) yy_c];
803
+ }
804
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
805
+ ++yy_cp;
806
+ }
807
+ while ( yy_base[yy_current_state] != 149 );
808
+
809
+ yy_find_action:
810
+ yy_act = yy_accept[yy_current_state];
811
+ if ( yy_act == 0 )
812
+ { /* have to back up */
813
+ yy_cp = yyg->yy_last_accepting_cpos;
814
+ yy_current_state = yyg->yy_last_accepting_state;
815
+ yy_act = yy_accept[yy_current_state];
816
+ }
817
+
818
+ YY_DO_BEFORE_ACTION;
819
+
820
+ do_action: /* This label is used only to access EOF actions. */
821
+
822
+ switch ( yy_act )
823
+ { /* beginning of action switch */
824
+ case 0: /* must back up */
825
+ /* undo the effects of YY_DO_BEFORE_ACTION */
826
+ *yy_cp = yyg->yy_hold_char;
827
+ yy_cp = yyg->yy_last_accepting_cpos;
828
+ yy_current_state = yyg->yy_last_accepting_state;
829
+ goto yy_find_action;
830
+
831
+ case 1:
832
+ YY_RULE_SETUP
833
+ { UPD; report(space); }
834
+ YY_BREAK
835
+ case 2:
836
+ /* rule 2 can match eol */
837
+ YY_RULE_SETUP
838
+ { UPD; report(space); }
839
+ YY_BREAK
840
+ case 3:
841
+ YY_RULE_SETUP
842
+ { UPD; report(comment); }
843
+ YY_BREAK
844
+ case 4:
845
+ /* rule 4 can match eol */
846
+ YY_RULE_SETUP
847
+ { UPD; report(string); }
848
+ YY_BREAK
849
+ case 5:
850
+ YY_RULE_SETUP
851
+ { UPD; report(integer); }
852
+ YY_BREAK
853
+ case 6:
854
+ YY_RULE_SETUP
855
+ { UPD; report(floating); }
856
+ YY_BREAK
857
+ case 7:
858
+ YY_RULE_SETUP
859
+ { UPD; report(imaginary); }
860
+ YY_BREAK
861
+ case 8:
862
+ YY_RULE_SETUP
863
+ { UPD; report(ident); }
864
+ YY_BREAK
865
+ case 9:
866
+ YY_RULE_SETUP
867
+ { UPD; report(punct); }
868
+ YY_BREAK
869
+ case 10:
870
+ YY_RULE_SETUP
871
+ YY_FATAL_ERROR( "flex scanner jammed" );
872
+ YY_BREAK
873
+ case YY_STATE_EOF(INITIAL):
874
+ yyterminate();
875
+
876
+ case YY_END_OF_BUFFER:
877
+ {
878
+ /* Amount of text matched not including the EOB char. */
879
+ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
880
+
881
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
882
+ *yy_cp = yyg->yy_hold_char;
883
+ YY_RESTORE_YY_MORE_OFFSET
884
+
885
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
886
+ {
887
+ /* We're scanning a new file or input source. It's
888
+ * possible that this happened because the user
889
+ * just pointed yyin at a new source and called
890
+ * langscan_python_lex_lex(). If so, then we have to assure
891
+ * consistency between YY_CURRENT_BUFFER and our
892
+ * globals. Here is the right place to do so, because
893
+ * this is the first action (other than possibly a
894
+ * back-up) that will match for the new input source.
895
+ */
896
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
897
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
898
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
899
+ }
900
+
901
+ /* Note that here we test for yy_c_buf_p "<=" to the position
902
+ * of the first EOB in the buffer, since yy_c_buf_p will
903
+ * already have been incremented past the NUL character
904
+ * (since all states make transitions on EOB to the
905
+ * end-of-buffer state). Contrast this with the test
906
+ * in input().
907
+ */
908
+ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
909
+ { /* This was really a NUL. */
910
+ yy_state_type yy_next_state;
911
+
912
+ yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
913
+
914
+ yy_current_state = yy_get_previous_state( yyscanner );
915
+
916
+ /* Okay, we're now positioned to make the NUL
917
+ * transition. We couldn't have
918
+ * yy_get_previous_state() go ahead and do it
919
+ * for us because it doesn't know how to deal
920
+ * with the possibility of jamming (and we don't
921
+ * want to build jamming into it because then it
922
+ * will run more slowly).
923
+ */
924
+
925
+ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
926
+
927
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
928
+
929
+ if ( yy_next_state )
930
+ {
931
+ /* Consume the NUL. */
932
+ yy_cp = ++yyg->yy_c_buf_p;
933
+ yy_current_state = yy_next_state;
934
+ goto yy_match;
935
+ }
936
+
937
+ else
938
+ {
939
+ yy_cp = yyg->yy_c_buf_p;
940
+ goto yy_find_action;
941
+ }
942
+ }
943
+
944
+ else switch ( yy_get_next_buffer( yyscanner ) )
945
+ {
946
+ case EOB_ACT_END_OF_FILE:
947
+ {
948
+ yyg->yy_did_buffer_switch_on_eof = 0;
949
+
950
+ if ( langscan_python_lex_wrap(yyscanner ) )
951
+ {
952
+ /* Note: because we've taken care in
953
+ * yy_get_next_buffer() to have set up
954
+ * yytext, we can now set up
955
+ * yy_c_buf_p so that if some total
956
+ * hoser (like flex itself) wants to
957
+ * call the scanner after we return the
958
+ * YY_NULL, it'll still work - another
959
+ * YY_NULL will get returned.
960
+ */
961
+ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
962
+
963
+ yy_act = YY_STATE_EOF(YY_START);
964
+ goto do_action;
965
+ }
966
+
967
+ else
968
+ {
969
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
970
+ YY_NEW_FILE;
971
+ }
972
+ break;
973
+ }
974
+
975
+ case EOB_ACT_CONTINUE_SCAN:
976
+ yyg->yy_c_buf_p =
977
+ yyg->yytext_ptr + yy_amount_of_matched_text;
978
+
979
+ yy_current_state = yy_get_previous_state( yyscanner );
980
+
981
+ yy_cp = yyg->yy_c_buf_p;
982
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
983
+ goto yy_match;
984
+
985
+ case EOB_ACT_LAST_MATCH:
986
+ yyg->yy_c_buf_p =
987
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
988
+
989
+ yy_current_state = yy_get_previous_state( yyscanner );
990
+
991
+ yy_cp = yyg->yy_c_buf_p;
992
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
993
+ goto yy_find_action;
994
+ }
995
+ break;
996
+ }
997
+
998
+ default:
999
+ YY_FATAL_ERROR(
1000
+ "fatal flex scanner internal error--no action found" );
1001
+ } /* end of action switch */
1002
+ } /* end of scanning one token */
1003
+ } /* end of langscan_python_lex_lex */
1004
+
1005
+ /* yy_get_next_buffer - try to read in a new buffer
1006
+ *
1007
+ * Returns a code representing an action:
1008
+ * EOB_ACT_LAST_MATCH -
1009
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1010
+ * EOB_ACT_END_OF_FILE - end of file
1011
+ */
1012
+ static int yy_get_next_buffer (yyscan_t yyscanner)
1013
+ {
1014
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1015
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1016
+ register char *source = yyg->yytext_ptr;
1017
+ register int number_to_move, i;
1018
+ int ret_val;
1019
+
1020
+ if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1021
+ YY_FATAL_ERROR(
1022
+ "fatal flex scanner internal error--end of buffer missed" );
1023
+
1024
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1025
+ { /* Don't try to fill the buffer, so this is an EOF. */
1026
+ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1027
+ {
1028
+ /* We matched a single character, the EOB, so
1029
+ * treat this as a final EOF.
1030
+ */
1031
+ return EOB_ACT_END_OF_FILE;
1032
+ }
1033
+
1034
+ else
1035
+ {
1036
+ /* We matched some text prior to the EOB, first
1037
+ * process it.
1038
+ */
1039
+ return EOB_ACT_LAST_MATCH;
1040
+ }
1041
+ }
1042
+
1043
+ /* Try to read more data. */
1044
+
1045
+ /* First move last chars to start of buffer. */
1046
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1047
+
1048
+ for ( i = 0; i < number_to_move; ++i )
1049
+ *(dest++) = *(source++);
1050
+
1051
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1052
+ /* don't do the read, it's not guaranteed to return an EOF,
1053
+ * just force an EOF
1054
+ */
1055
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1056
+
1057
+ else
1058
+ {
1059
+ int num_to_read =
1060
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1061
+
1062
+ while ( num_to_read <= 0 )
1063
+ { /* Not enough room in the buffer - grow it. */
1064
+
1065
+ /* just a shorter name for the current buffer */
1066
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1067
+
1068
+ int yy_c_buf_p_offset =
1069
+ (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1070
+
1071
+ if ( b->yy_is_our_buffer )
1072
+ {
1073
+ int new_size = b->yy_buf_size * 2;
1074
+
1075
+ if ( new_size <= 0 )
1076
+ b->yy_buf_size += b->yy_buf_size / 8;
1077
+ else
1078
+ b->yy_buf_size *= 2;
1079
+
1080
+ b->yy_ch_buf = (char *)
1081
+ /* Include room in for 2 EOB chars. */
1082
+ langscan_python_lex_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1083
+ }
1084
+ else
1085
+ /* Can't grow it, we don't own it. */
1086
+ b->yy_ch_buf = 0;
1087
+
1088
+ if ( ! b->yy_ch_buf )
1089
+ YY_FATAL_ERROR(
1090
+ "fatal error - scanner input buffer overflow" );
1091
+
1092
+ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1093
+
1094
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1095
+ number_to_move - 1;
1096
+
1097
+ }
1098
+
1099
+ if ( num_to_read > YY_READ_BUF_SIZE )
1100
+ num_to_read = YY_READ_BUF_SIZE;
1101
+
1102
+ /* Read in more data. */
1103
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1104
+ yyg->yy_n_chars, (size_t) num_to_read );
1105
+
1106
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1107
+ }
1108
+
1109
+ if ( yyg->yy_n_chars == 0 )
1110
+ {
1111
+ if ( number_to_move == YY_MORE_ADJ )
1112
+ {
1113
+ ret_val = EOB_ACT_END_OF_FILE;
1114
+ langscan_python_lex_restart(yyin ,yyscanner);
1115
+ }
1116
+
1117
+ else
1118
+ {
1119
+ ret_val = EOB_ACT_LAST_MATCH;
1120
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1121
+ YY_BUFFER_EOF_PENDING;
1122
+ }
1123
+ }
1124
+
1125
+ else
1126
+ ret_val = EOB_ACT_CONTINUE_SCAN;
1127
+
1128
+ if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1129
+ /* Extend the array by 50%, plus the number we really need. */
1130
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1131
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) langscan_python_lex_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1132
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1133
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1134
+ }
1135
+
1136
+ yyg->yy_n_chars += number_to_move;
1137
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1138
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1139
+
1140
+ yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1141
+
1142
+ return ret_val;
1143
+ }
1144
+
1145
+ /* yy_get_previous_state - get the state just before the EOB char was reached */
1146
+
1147
+ static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1148
+ {
1149
+ register yy_state_type yy_current_state;
1150
+ register char *yy_cp;
1151
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1152
+
1153
+ yy_current_state = yyg->yy_start;
1154
+
1155
+ for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1156
+ {
1157
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1158
+ if ( yy_accept[yy_current_state] )
1159
+ {
1160
+ yyg->yy_last_accepting_state = yy_current_state;
1161
+ yyg->yy_last_accepting_cpos = yy_cp;
1162
+ }
1163
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1164
+ {
1165
+ yy_current_state = (int) yy_def[yy_current_state];
1166
+ if ( yy_current_state >= 65 )
1167
+ yy_c = yy_meta[(unsigned int) yy_c];
1168
+ }
1169
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1170
+ }
1171
+
1172
+ return yy_current_state;
1173
+ }
1174
+
1175
+ /* yy_try_NUL_trans - try to make a transition on the NUL character
1176
+ *
1177
+ * synopsis
1178
+ * next_state = yy_try_NUL_trans( current_state );
1179
+ */
1180
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1181
+ {
1182
+ register int yy_is_jam;
1183
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1184
+ register char *yy_cp = yyg->yy_c_buf_p;
1185
+
1186
+ register YY_CHAR yy_c = 1;
1187
+ if ( yy_accept[yy_current_state] )
1188
+ {
1189
+ yyg->yy_last_accepting_state = yy_current_state;
1190
+ yyg->yy_last_accepting_cpos = yy_cp;
1191
+ }
1192
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1193
+ {
1194
+ yy_current_state = (int) yy_def[yy_current_state];
1195
+ if ( yy_current_state >= 65 )
1196
+ yy_c = yy_meta[(unsigned int) yy_c];
1197
+ }
1198
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1199
+ yy_is_jam = (yy_current_state == 64);
1200
+
1201
+ return yy_is_jam ? 0 : yy_current_state;
1202
+ }
1203
+
1204
+ static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
1205
+ {
1206
+ register char *yy_cp;
1207
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1208
+
1209
+ yy_cp = yyg->yy_c_buf_p;
1210
+
1211
+ /* undo effects of setting up yytext */
1212
+ *yy_cp = yyg->yy_hold_char;
1213
+
1214
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1215
+ { /* need to shift things up to make room */
1216
+ /* +2 for EOB chars. */
1217
+ register int number_to_move = yyg->yy_n_chars + 2;
1218
+ register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1219
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1220
+ register char *source =
1221
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1222
+
1223
+ while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1224
+ *--dest = *--source;
1225
+
1226
+ yy_cp += (int) (dest - source);
1227
+ yy_bp += (int) (dest - source);
1228
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1229
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1230
+
1231
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1232
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
1233
+ }
1234
+
1235
+ *--yy_cp = (char) c;
1236
+
1237
+ yyg->yytext_ptr = yy_bp;
1238
+ yyg->yy_hold_char = *yy_cp;
1239
+ yyg->yy_c_buf_p = yy_cp;
1240
+ }
1241
+
1242
+ #ifndef YY_NO_INPUT
1243
+ #ifdef __cplusplus
1244
+ static int yyinput (yyscan_t yyscanner)
1245
+ #else
1246
+ static int input (yyscan_t yyscanner)
1247
+ #endif
1248
+
1249
+ {
1250
+ int c;
1251
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1252
+
1253
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1254
+
1255
+ if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1256
+ {
1257
+ /* yy_c_buf_p now points to the character we want to return.
1258
+ * If this occurs *before* the EOB characters, then it's a
1259
+ * valid NUL; if not, then we've hit the end of the buffer.
1260
+ */
1261
+ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1262
+ /* This was really a NUL. */
1263
+ *yyg->yy_c_buf_p = '\0';
1264
+
1265
+ else
1266
+ { /* need more input */
1267
+ int offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
1268
+ ++yyg->yy_c_buf_p;
1269
+
1270
+ switch ( yy_get_next_buffer( yyscanner ) )
1271
+ {
1272
+ case EOB_ACT_LAST_MATCH:
1273
+ /* This happens because yy_g_n_b()
1274
+ * sees that we've accumulated a
1275
+ * token and flags that we need to
1276
+ * try matching the token before
1277
+ * proceeding. But for input(),
1278
+ * there's no matching to consider.
1279
+ * So convert the EOB_ACT_LAST_MATCH
1280
+ * to EOB_ACT_END_OF_FILE.
1281
+ */
1282
+
1283
+ /* Reset buffer status. */
1284
+ langscan_python_lex_restart(yyin ,yyscanner);
1285
+
1286
+ /*FALLTHROUGH*/
1287
+
1288
+ case EOB_ACT_END_OF_FILE:
1289
+ {
1290
+ if ( langscan_python_lex_wrap(yyscanner ) )
1291
+ return EOF;
1292
+
1293
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
1294
+ YY_NEW_FILE;
1295
+ #ifdef __cplusplus
1296
+ return yyinput(yyscanner);
1297
+ #else
1298
+ return input(yyscanner);
1299
+ #endif
1300
+ }
1301
+
1302
+ case EOB_ACT_CONTINUE_SCAN:
1303
+ yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1304
+ break;
1305
+ }
1306
+ }
1307
+ }
1308
+
1309
+ c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1310
+ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1311
+ yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1312
+
1313
+ return c;
1314
+ }
1315
+ #endif /* ifndef YY_NO_INPUT */
1316
+
1317
+ /** Immediately switch to a different input stream.
1318
+ * @param input_file A readable stream.
1319
+ * @param yyscanner The scanner object.
1320
+ * @note This function does not reset the start condition to @c INITIAL .
1321
+ */
1322
+ void langscan_python_lex_restart (FILE * input_file , yyscan_t yyscanner)
1323
+ {
1324
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1325
+
1326
+ if ( ! YY_CURRENT_BUFFER ){
1327
+ langscan_python_lex_ensure_buffer_stack (yyscanner);
1328
+ YY_CURRENT_BUFFER_LVALUE =
1329
+ langscan_python_lex__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1330
+ }
1331
+
1332
+ langscan_python_lex__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1333
+ langscan_python_lex__load_buffer_state(yyscanner );
1334
+ }
1335
+
1336
+ /** Switch to a different input buffer.
1337
+ * @param new_buffer The new input buffer.
1338
+ * @param yyscanner The scanner object.
1339
+ */
1340
+ void langscan_python_lex__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1341
+ {
1342
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1343
+
1344
+ /* TODO. We should be able to replace this entire function body
1345
+ * with
1346
+ * langscan_python_lex_pop_buffer_state();
1347
+ * langscan_python_lex_push_buffer_state(new_buffer);
1348
+ */
1349
+ langscan_python_lex_ensure_buffer_stack (yyscanner);
1350
+ if ( YY_CURRENT_BUFFER == new_buffer )
1351
+ return;
1352
+
1353
+ if ( YY_CURRENT_BUFFER )
1354
+ {
1355
+ /* Flush out information for old buffer. */
1356
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1357
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1358
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1359
+ }
1360
+
1361
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
1362
+ langscan_python_lex__load_buffer_state(yyscanner );
1363
+
1364
+ /* We don't actually know whether we did this switch during
1365
+ * EOF (langscan_python_lex_wrap()) processing, but the only time this flag
1366
+ * is looked at is after langscan_python_lex_wrap() is called, so it's safe
1367
+ * to go ahead and always set it.
1368
+ */
1369
+ yyg->yy_did_buffer_switch_on_eof = 1;
1370
+ }
1371
+
1372
+ static void langscan_python_lex__load_buffer_state (yyscan_t yyscanner)
1373
+ {
1374
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1375
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1376
+ yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1377
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1378
+ yyg->yy_hold_char = *yyg->yy_c_buf_p;
1379
+ }
1380
+
1381
+ /** Allocate and initialize an input buffer state.
1382
+ * @param file A readable stream.
1383
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1384
+ * @param yyscanner The scanner object.
1385
+ * @return the allocated buffer state.
1386
+ */
1387
+ YY_BUFFER_STATE langscan_python_lex__create_buffer (FILE * file, int size , yyscan_t yyscanner)
1388
+ {
1389
+ YY_BUFFER_STATE b;
1390
+
1391
+ b = (YY_BUFFER_STATE) langscan_python_lex_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1392
+ if ( ! b )
1393
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_python_lex__create_buffer()" );
1394
+
1395
+ b->yy_buf_size = size;
1396
+
1397
+ /* yy_ch_buf has to be 2 characters longer than the size given because
1398
+ * we need to put in 2 end-of-buffer characters.
1399
+ */
1400
+ b->yy_ch_buf = (char *) langscan_python_lex_alloc(b->yy_buf_size + 2 ,yyscanner );
1401
+ if ( ! b->yy_ch_buf )
1402
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_python_lex__create_buffer()" );
1403
+
1404
+ b->yy_is_our_buffer = 1;
1405
+
1406
+ langscan_python_lex__init_buffer(b,file ,yyscanner);
1407
+
1408
+ return b;
1409
+ }
1410
+
1411
+ /** Destroy the buffer.
1412
+ * @param b a buffer created with langscan_python_lex__create_buffer()
1413
+ * @param yyscanner The scanner object.
1414
+ */
1415
+ void langscan_python_lex__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1416
+ {
1417
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1418
+
1419
+ if ( ! b )
1420
+ return;
1421
+
1422
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1423
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1424
+
1425
+ if ( b->yy_is_our_buffer )
1426
+ langscan_python_lex_free((void *) b->yy_ch_buf ,yyscanner );
1427
+
1428
+ langscan_python_lex_free((void *) b ,yyscanner );
1429
+ }
1430
+
1431
+ #ifndef __cplusplus
1432
+ extern int isatty (int );
1433
+ #endif /* __cplusplus */
1434
+
1435
+ /* Initializes or reinitializes a buffer.
1436
+ * This function is sometimes called more than once on the same buffer,
1437
+ * such as during a langscan_python_lex_restart() or at EOF.
1438
+ */
1439
+ static void langscan_python_lex__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1440
+
1441
+ {
1442
+ int oerrno = errno;
1443
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1444
+
1445
+ langscan_python_lex__flush_buffer(b ,yyscanner);
1446
+
1447
+ b->yy_input_file = file;
1448
+ b->yy_fill_buffer = 1;
1449
+
1450
+ /* If b is the current buffer, then langscan_python_lex__init_buffer was _probably_
1451
+ * called from langscan_python_lex_restart() or through yy_get_next_buffer.
1452
+ * In that case, we don't want to reset the lineno or column.
1453
+ */
1454
+ if (b != YY_CURRENT_BUFFER){
1455
+ b->yy_bs_lineno = 1;
1456
+ b->yy_bs_column = 0;
1457
+ }
1458
+
1459
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1460
+
1461
+ errno = oerrno;
1462
+ }
1463
+
1464
+ /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1465
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1466
+ * @param yyscanner The scanner object.
1467
+ */
1468
+ void langscan_python_lex__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1469
+ {
1470
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1471
+ if ( ! b )
1472
+ return;
1473
+
1474
+ b->yy_n_chars = 0;
1475
+
1476
+ /* We always need two end-of-buffer characters. The first causes
1477
+ * a transition to the end-of-buffer state. The second causes
1478
+ * a jam in that state.
1479
+ */
1480
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1481
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1482
+
1483
+ b->yy_buf_pos = &b->yy_ch_buf[0];
1484
+
1485
+ b->yy_at_bol = 1;
1486
+ b->yy_buffer_status = YY_BUFFER_NEW;
1487
+
1488
+ if ( b == YY_CURRENT_BUFFER )
1489
+ langscan_python_lex__load_buffer_state(yyscanner );
1490
+ }
1491
+
1492
+ /** Pushes the new state onto the stack. The new state becomes
1493
+ * the current state. This function will allocate the stack
1494
+ * if necessary.
1495
+ * @param new_buffer The new state.
1496
+ * @param yyscanner The scanner object.
1497
+ */
1498
+ void langscan_python_lex_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1499
+ {
1500
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1501
+ if (new_buffer == NULL)
1502
+ return;
1503
+
1504
+ langscan_python_lex_ensure_buffer_stack(yyscanner);
1505
+
1506
+ /* This block is copied from langscan_python_lex__switch_to_buffer. */
1507
+ if ( YY_CURRENT_BUFFER )
1508
+ {
1509
+ /* Flush out information for old buffer. */
1510
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1511
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1512
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1513
+ }
1514
+
1515
+ /* Only push if top exists. Otherwise, replace top. */
1516
+ if (YY_CURRENT_BUFFER)
1517
+ yyg->yy_buffer_stack_top++;
1518
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
1519
+
1520
+ /* copied from langscan_python_lex__switch_to_buffer. */
1521
+ langscan_python_lex__load_buffer_state(yyscanner );
1522
+ yyg->yy_did_buffer_switch_on_eof = 1;
1523
+ }
1524
+
1525
+ /** Removes and deletes the top of the stack, if present.
1526
+ * The next element becomes the new top.
1527
+ * @param yyscanner The scanner object.
1528
+ */
1529
+ void langscan_python_lex_pop_buffer_state (yyscan_t yyscanner)
1530
+ {
1531
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1532
+ if (!YY_CURRENT_BUFFER)
1533
+ return;
1534
+
1535
+ langscan_python_lex__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1536
+ YY_CURRENT_BUFFER_LVALUE = NULL;
1537
+ if (yyg->yy_buffer_stack_top > 0)
1538
+ --yyg->yy_buffer_stack_top;
1539
+
1540
+ if (YY_CURRENT_BUFFER) {
1541
+ langscan_python_lex__load_buffer_state(yyscanner );
1542
+ yyg->yy_did_buffer_switch_on_eof = 1;
1543
+ }
1544
+ }
1545
+
1546
+ /* Allocates the stack if it does not exist.
1547
+ * Guarantees space for at least one push.
1548
+ */
1549
+ static void langscan_python_lex_ensure_buffer_stack (yyscan_t yyscanner)
1550
+ {
1551
+ int num_to_alloc;
1552
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1553
+
1554
+ if (!yyg->yy_buffer_stack) {
1555
+
1556
+ /* First allocation is just for 2 elements, since we don't know if this
1557
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
1558
+ * immediate realloc on the next call.
1559
+ */
1560
+ num_to_alloc = 1;
1561
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)langscan_python_lex_alloc
1562
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
1563
+ , yyscanner);
1564
+ if ( ! yyg->yy_buffer_stack )
1565
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_python_lex_ensure_buffer_stack()" );
1566
+
1567
+ memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1568
+
1569
+ yyg->yy_buffer_stack_max = num_to_alloc;
1570
+ yyg->yy_buffer_stack_top = 0;
1571
+ return;
1572
+ }
1573
+
1574
+ if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1575
+
1576
+ /* Increase the buffer to prepare for a possible push. */
1577
+ int grow_size = 8 /* arbitrary grow size */;
1578
+
1579
+ num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1580
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)langscan_python_lex_realloc
1581
+ (yyg->yy_buffer_stack,
1582
+ num_to_alloc * sizeof(struct yy_buffer_state*)
1583
+ , yyscanner);
1584
+ if ( ! yyg->yy_buffer_stack )
1585
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_python_lex_ensure_buffer_stack()" );
1586
+
1587
+ /* zero only the new slots.*/
1588
+ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1589
+ yyg->yy_buffer_stack_max = num_to_alloc;
1590
+ }
1591
+ }
1592
+
1593
+ /** Setup the input buffer state to scan directly from a user-specified character buffer.
1594
+ * @param base the character buffer
1595
+ * @param size the size in bytes of the character buffer
1596
+ * @param yyscanner The scanner object.
1597
+ * @return the newly allocated buffer state object.
1598
+ */
1599
+ YY_BUFFER_STATE langscan_python_lex__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1600
+ {
1601
+ YY_BUFFER_STATE b;
1602
+
1603
+ if ( size < 2 ||
1604
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
1605
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
1606
+ /* They forgot to leave room for the EOB's. */
1607
+ return 0;
1608
+
1609
+ b = (YY_BUFFER_STATE) langscan_python_lex_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1610
+ if ( ! b )
1611
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_python_lex__scan_buffer()" );
1612
+
1613
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1614
+ b->yy_buf_pos = b->yy_ch_buf = base;
1615
+ b->yy_is_our_buffer = 0;
1616
+ b->yy_input_file = 0;
1617
+ b->yy_n_chars = b->yy_buf_size;
1618
+ b->yy_is_interactive = 0;
1619
+ b->yy_at_bol = 1;
1620
+ b->yy_fill_buffer = 0;
1621
+ b->yy_buffer_status = YY_BUFFER_NEW;
1622
+
1623
+ langscan_python_lex__switch_to_buffer(b ,yyscanner );
1624
+
1625
+ return b;
1626
+ }
1627
+
1628
+ /** Setup the input buffer state to scan a string. The next call to langscan_python_lex_lex() will
1629
+ * scan from a @e copy of @a str.
1630
+ * @param yystr a NUL-terminated string to scan
1631
+ * @param yyscanner The scanner object.
1632
+ * @return the newly allocated buffer state object.
1633
+ * @note If you want to scan bytes that may contain NUL values, then use
1634
+ * langscan_python_lex__scan_bytes() instead.
1635
+ */
1636
+ YY_BUFFER_STATE langscan_python_lex__scan_string (yyconst char * yystr , yyscan_t yyscanner)
1637
+ {
1638
+
1639
+ return langscan_python_lex__scan_bytes(yystr,strlen(yystr) ,yyscanner);
1640
+ }
1641
+
1642
+ /** Setup the input buffer state to scan the given bytes. The next call to langscan_python_lex_lex() will
1643
+ * scan from a @e copy of @a bytes.
1644
+ * @param yybytes the byte buffer to scan
1645
+ * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
1646
+ * @param yyscanner The scanner object.
1647
+ * @return the newly allocated buffer state object.
1648
+ */
1649
+ YY_BUFFER_STATE langscan_python_lex__scan_bytes (yyconst char * yybytes, int _yybytes_len , yyscan_t yyscanner)
1650
+ {
1651
+ YY_BUFFER_STATE b;
1652
+ char *buf;
1653
+ yy_size_t n;
1654
+ int i;
1655
+
1656
+ /* Get memory for full buffer, including space for trailing EOB's. */
1657
+ n = _yybytes_len + 2;
1658
+ buf = (char *) langscan_python_lex_alloc(n ,yyscanner );
1659
+ if ( ! buf )
1660
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_python_lex__scan_bytes()" );
1661
+
1662
+ for ( i = 0; i < _yybytes_len; ++i )
1663
+ buf[i] = yybytes[i];
1664
+
1665
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1666
+
1667
+ b = langscan_python_lex__scan_buffer(buf,n ,yyscanner);
1668
+ if ( ! b )
1669
+ YY_FATAL_ERROR( "bad buffer in langscan_python_lex__scan_bytes()" );
1670
+
1671
+ /* It's okay to grow etc. this buffer, and we should throw it
1672
+ * away when we're done.
1673
+ */
1674
+ b->yy_is_our_buffer = 1;
1675
+
1676
+ return b;
1677
+ }
1678
+
1679
+ #ifndef YY_EXIT_FAILURE
1680
+ #define YY_EXIT_FAILURE 2
1681
+ #endif
1682
+
1683
+ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
1684
+ {
1685
+ (void) fprintf( stderr, "%s\n", msg );
1686
+ exit( YY_EXIT_FAILURE );
1687
+ }
1688
+
1689
+ /* Redefine yyless() so it works in section 3 code. */
1690
+
1691
+ #undef yyless
1692
+ #define yyless(n) \
1693
+ do \
1694
+ { \
1695
+ /* Undo effects of setting up yytext. */ \
1696
+ int yyless_macro_arg = (n); \
1697
+ YY_LESS_LINENO(yyless_macro_arg);\
1698
+ yytext[yyleng] = yyg->yy_hold_char; \
1699
+ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
1700
+ yyg->yy_hold_char = *yyg->yy_c_buf_p; \
1701
+ *yyg->yy_c_buf_p = '\0'; \
1702
+ yyleng = yyless_macro_arg; \
1703
+ } \
1704
+ while ( 0 )
1705
+
1706
+ /* Accessor methods (get/set functions) to struct members. */
1707
+
1708
+ /** Get the user-defined data for this scanner.
1709
+ * @param yyscanner The scanner object.
1710
+ */
1711
+ YY_EXTRA_TYPE langscan_python_lex_get_extra (yyscan_t yyscanner)
1712
+ {
1713
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1714
+ return yyextra;
1715
+ }
1716
+
1717
+ /** Get the current line number.
1718
+ * @param yyscanner The scanner object.
1719
+ */
1720
+ int langscan_python_lex_get_lineno (yyscan_t yyscanner)
1721
+ {
1722
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1723
+
1724
+ if (! YY_CURRENT_BUFFER)
1725
+ return 0;
1726
+
1727
+ return yylineno;
1728
+ }
1729
+
1730
+ /** Get the current column number.
1731
+ * @param yyscanner The scanner object.
1732
+ */
1733
+ int langscan_python_lex_get_column (yyscan_t yyscanner)
1734
+ {
1735
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1736
+
1737
+ if (! YY_CURRENT_BUFFER)
1738
+ return 0;
1739
+
1740
+ return yycolumn;
1741
+ }
1742
+
1743
+ /** Get the input stream.
1744
+ * @param yyscanner The scanner object.
1745
+ */
1746
+ FILE *langscan_python_lex_get_in (yyscan_t yyscanner)
1747
+ {
1748
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1749
+ return yyin;
1750
+ }
1751
+
1752
+ /** Get the output stream.
1753
+ * @param yyscanner The scanner object.
1754
+ */
1755
+ FILE *langscan_python_lex_get_out (yyscan_t yyscanner)
1756
+ {
1757
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1758
+ return yyout;
1759
+ }
1760
+
1761
+ /** Get the length of the current token.
1762
+ * @param yyscanner The scanner object.
1763
+ */
1764
+ int langscan_python_lex_get_leng (yyscan_t yyscanner)
1765
+ {
1766
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1767
+ return yyleng;
1768
+ }
1769
+
1770
+ /** Get the current token.
1771
+ * @param yyscanner The scanner object.
1772
+ */
1773
+
1774
+ char *langscan_python_lex_get_text (yyscan_t yyscanner)
1775
+ {
1776
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1777
+ return yytext;
1778
+ }
1779
+
1780
+ /** Set the user-defined data. This data is never touched by the scanner.
1781
+ * @param user_defined The data to be associated with this scanner.
1782
+ * @param yyscanner The scanner object.
1783
+ */
1784
+ void langscan_python_lex_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
1785
+ {
1786
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1787
+ yyextra = user_defined ;
1788
+ }
1789
+
1790
+ /** Set the current line number.
1791
+ * @param line_number
1792
+ * @param yyscanner The scanner object.
1793
+ */
1794
+ void langscan_python_lex_set_lineno (int line_number , yyscan_t yyscanner)
1795
+ {
1796
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1797
+
1798
+ /* lineno is only valid if an input buffer exists. */
1799
+ if (! YY_CURRENT_BUFFER )
1800
+ yy_fatal_error( "langscan_python_lex_set_lineno called with no buffer" , yyscanner);
1801
+
1802
+ yylineno = line_number;
1803
+ }
1804
+
1805
+ /** Set the current column.
1806
+ * @param line_number
1807
+ * @param yyscanner The scanner object.
1808
+ */
1809
+ void langscan_python_lex_set_column (int column_no , yyscan_t yyscanner)
1810
+ {
1811
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1812
+
1813
+ /* column is only valid if an input buffer exists. */
1814
+ if (! YY_CURRENT_BUFFER )
1815
+ yy_fatal_error( "langscan_python_lex_set_column called with no buffer" , yyscanner);
1816
+
1817
+ yycolumn = column_no;
1818
+ }
1819
+
1820
+ /** Set the input stream. This does not discard the current
1821
+ * input buffer.
1822
+ * @param in_str A readable stream.
1823
+ * @param yyscanner The scanner object.
1824
+ * @see langscan_python_lex__switch_to_buffer
1825
+ */
1826
+ void langscan_python_lex_set_in (FILE * in_str , yyscan_t yyscanner)
1827
+ {
1828
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1829
+ yyin = in_str ;
1830
+ }
1831
+
1832
+ void langscan_python_lex_set_out (FILE * out_str , yyscan_t yyscanner)
1833
+ {
1834
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1835
+ yyout = out_str ;
1836
+ }
1837
+
1838
+ int langscan_python_lex_get_debug (yyscan_t yyscanner)
1839
+ {
1840
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1841
+ return yy_flex_debug;
1842
+ }
1843
+
1844
+ void langscan_python_lex_set_debug (int bdebug , yyscan_t yyscanner)
1845
+ {
1846
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1847
+ yy_flex_debug = bdebug ;
1848
+ }
1849
+
1850
+ /* Accessor methods for yylval and yylloc */
1851
+
1852
+ /* User-visible API */
1853
+
1854
+ /* langscan_python_lex_lex_init is special because it creates the scanner itself, so it is
1855
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
1856
+ * That's why we explicitly handle the declaration, instead of using our macros.
1857
+ */
1858
+
1859
+ int langscan_python_lex_lex_init(yyscan_t* ptr_yy_globals)
1860
+
1861
+ {
1862
+ if (ptr_yy_globals == NULL){
1863
+ errno = EINVAL;
1864
+ return 1;
1865
+ }
1866
+
1867
+ *ptr_yy_globals = (yyscan_t) langscan_python_lex_alloc ( sizeof( struct yyguts_t ), NULL );
1868
+
1869
+ if (*ptr_yy_globals == NULL){
1870
+ errno = ENOMEM;
1871
+ return 1;
1872
+ }
1873
+
1874
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
1875
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
1876
+
1877
+ return yy_init_globals ( *ptr_yy_globals );
1878
+ }
1879
+
1880
+ /* langscan_python_lex_lex_init_extra has the same functionality as langscan_python_lex_lex_init, but follows the
1881
+ * convention of taking the scanner as the last argument. Note however, that
1882
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
1883
+ * is the reason, too, why this function also must handle its own declaration).
1884
+ * The user defined value in the first argument will be available to langscan_python_lex_alloc in
1885
+ * the yyextra field.
1886
+ */
1887
+
1888
+ int langscan_python_lex_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
1889
+
1890
+ {
1891
+ struct yyguts_t dummy_yyguts;
1892
+
1893
+ langscan_python_lex_set_extra (yy_user_defined, &dummy_yyguts);
1894
+
1895
+ if (ptr_yy_globals == NULL){
1896
+ errno = EINVAL;
1897
+ return 1;
1898
+ }
1899
+
1900
+ *ptr_yy_globals = (yyscan_t) langscan_python_lex_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
1901
+
1902
+ if (*ptr_yy_globals == NULL){
1903
+ errno = ENOMEM;
1904
+ return 1;
1905
+ }
1906
+
1907
+ /* By setting to 0xAA, we expose bugs in
1908
+ yy_init_globals. Leave at 0x00 for releases. */
1909
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
1910
+
1911
+ langscan_python_lex_set_extra (yy_user_defined, *ptr_yy_globals);
1912
+
1913
+ return yy_init_globals ( *ptr_yy_globals );
1914
+ }
1915
+
1916
+ static int yy_init_globals (yyscan_t yyscanner)
1917
+ {
1918
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1919
+ /* Initialization is the same as for the non-reentrant scanner.
1920
+ * This function is called from langscan_python_lex_lex_destroy(), so don't allocate here.
1921
+ */
1922
+
1923
+ yyg->yy_buffer_stack = 0;
1924
+ yyg->yy_buffer_stack_top = 0;
1925
+ yyg->yy_buffer_stack_max = 0;
1926
+ yyg->yy_c_buf_p = (char *) 0;
1927
+ yyg->yy_init = 0;
1928
+ yyg->yy_start = 0;
1929
+
1930
+ yyg->yy_start_stack_ptr = 0;
1931
+ yyg->yy_start_stack_depth = 0;
1932
+ yyg->yy_start_stack = NULL;
1933
+
1934
+ /* Defined in main.c */
1935
+ #ifdef YY_STDINIT
1936
+ yyin = stdin;
1937
+ yyout = stdout;
1938
+ #else
1939
+ yyin = (FILE *) 0;
1940
+ yyout = (FILE *) 0;
1941
+ #endif
1942
+
1943
+ /* For future reference: Set errno on error, since we are called by
1944
+ * langscan_python_lex_lex_init()
1945
+ */
1946
+ return 0;
1947
+ }
1948
+
1949
+ /* langscan_python_lex_lex_destroy is for both reentrant and non-reentrant scanners. */
1950
+ int langscan_python_lex_lex_destroy (yyscan_t yyscanner)
1951
+ {
1952
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1953
+
1954
+ /* Pop the buffer stack, destroying each element. */
1955
+ while(YY_CURRENT_BUFFER){
1956
+ langscan_python_lex__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
1957
+ YY_CURRENT_BUFFER_LVALUE = NULL;
1958
+ langscan_python_lex_pop_buffer_state(yyscanner);
1959
+ }
1960
+
1961
+ /* Destroy the stack itself. */
1962
+ langscan_python_lex_free(yyg->yy_buffer_stack ,yyscanner);
1963
+ yyg->yy_buffer_stack = NULL;
1964
+
1965
+ /* Destroy the start condition stack. */
1966
+ langscan_python_lex_free(yyg->yy_start_stack ,yyscanner );
1967
+ yyg->yy_start_stack = NULL;
1968
+
1969
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
1970
+ * langscan_python_lex_lex() is called, initialization will occur. */
1971
+ yy_init_globals( yyscanner);
1972
+
1973
+ /* Destroy the main struct (reentrant only). */
1974
+ langscan_python_lex_free ( yyscanner , yyscanner );
1975
+ yyscanner = NULL;
1976
+ return 0;
1977
+ }
1978
+
1979
+ /*
1980
+ * Internal utility routines.
1981
+ */
1982
+
1983
+ #ifndef yytext_ptr
1984
+ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
1985
+ {
1986
+ register int i;
1987
+ for ( i = 0; i < n; ++i )
1988
+ s1[i] = s2[i];
1989
+ }
1990
+ #endif
1991
+
1992
+ #ifdef YY_NEED_STRLEN
1993
+ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
1994
+ {
1995
+ register int n;
1996
+ for ( n = 0; s[n]; ++n )
1997
+ ;
1998
+
1999
+ return n;
2000
+ }
2001
+ #endif
2002
+
2003
+ void *langscan_python_lex_alloc (yy_size_t size , yyscan_t yyscanner)
2004
+ {
2005
+ return (void *) malloc( size );
2006
+ }
2007
+
2008
+ void *langscan_python_lex_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2009
+ {
2010
+ /* The cast to (char *) in the following accommodates both
2011
+ * implementations that use char* generic pointers, and those
2012
+ * that use void* generic pointers. It works with the latter
2013
+ * because both ANSI C and C++ allow castless assignment from
2014
+ * any pointer type to void*, and deal with argument conversions
2015
+ * as though doing an assignment.
2016
+ */
2017
+ return (void *) realloc( (char *) ptr, size );
2018
+ }
2019
+
2020
+ void langscan_python_lex_free (void * ptr , yyscan_t yyscanner)
2021
+ {
2022
+ free( (char *) ptr ); /* see langscan_python_lex_realloc() for (char *) cast */
2023
+ }
2024
+
2025
+ #define YYTABLES_NAME "yytables"
2026
+
2027
+ static void update_pos(
2028
+ langscan_python_lex_extra_t *extra,
2029
+ char *text,
2030
+ int leng)
2031
+ {
2032
+ int i, j;
2033
+ extra->beg_byteno = extra->end_byteno;
2034
+ extra->beg_lineno = extra->end_lineno;
2035
+ extra->beg_columnno = extra->end_columnno;
2036
+ j = 0;
2037
+ for (i = 0; i < leng; i++) {
2038
+ if (text[i] == '\r' || (i == 0 || text[i - 1] != '\r') && text[i] == '\n') {
2039
+ extra->end_lineno++;
2040
+ j = i + 1;
2041
+ extra->end_columnno = 0;
2042
+ }
2043
+ }
2044
+ extra->end_columnno += leng - j;
2045
+ extra->end_byteno += leng;
2046
+ }
2047
+
2048
+ langscan_python_tokenizer_t *langscan_python_make_tokenizer(
2049
+ size_t (*user_read)(void **user_data_p, char *buf, size_t maxlen),
2050
+ void *user_data)
2051
+ {
2052
+ langscan_python_tokenizer_t *tokenizer;
2053
+ langscan_python_lex_extra_t *extra;
2054
+ tokenizer = (langscan_python_tokenizer_t *)malloc(sizeof(langscan_python_tokenizer_t));
2055
+ if (tokenizer == NULL)
2056
+ return NULL;
2057
+ extra = (langscan_python_lex_extra_t *)malloc(sizeof(langscan_python_lex_extra_t));
2058
+ if (extra == NULL)
2059
+ return NULL;
2060
+ extra->user_read = user_read;
2061
+ extra->user_data = user_data;
2062
+ extra->beg_lineno = 1;
2063
+ extra->beg_columnno = 0;
2064
+ extra->beg_byteno = 0;
2065
+ extra->end_lineno = 1;
2066
+ extra->end_columnno = 0;
2067
+ extra->end_byteno = 0;
2068
+ extra->eof = 0;
2069
+ tokenizer->extra = extra;
2070
+ langscan_python_lex_lex_init(&tokenizer->scanner);
2071
+ langscan_python_lex_set_extra(extra, tokenizer->scanner);
2072
+ return tokenizer;
2073
+ }
2074
+
2075
+ langscan_python_token_t langscan_python_get_token(langscan_python_tokenizer_t *tokenizer)
2076
+ {
2077
+ return langscan_python_lex_lex(tokenizer->scanner);
2078
+ }
2079
+
2080
+ void langscan_python_free_tokenizer(langscan_python_tokenizer_t *tokenizer)
2081
+ {
2082
+ langscan_python_lex_extra_t *extra = langscan_python_lex_get_extra(tokenizer->scanner);
2083
+ free((void *)extra);
2084
+ langscan_python_lex_lex_destroy(tokenizer->scanner);
2085
+ free((void *)tokenizer);
2086
+ }
2087
+
2088
+ user_read_t langscan_python_tokenizer_get_user_read(langscan_python_tokenizer_t *tokenizer)
2089
+ {
2090
+ return tokenizer->extra->user_read;
2091
+ }
2092
+
2093
+ void *langscan_python_tokenizer_get_user_data(langscan_python_tokenizer_t *tokenizer)
2094
+ {
2095
+ return tokenizer->extra->user_data;
2096
+ }
2097
+
2098
+ const char *langscan_python_token_name(langscan_python_token_t token)
2099
+ {
2100
+ static char *token_names[] = {
2101
+ "*eof*",
2102
+ #define LANGSCAN_PYTHON_TOKEN(name) #name,
2103
+ LANGSCAN_PYTHON_TOKEN_LIST
2104
+ #undef LANGSCAN_PYTHON_TOKEN
2105
+ };
2106
+
2107
+ return token_names[token];
2108
+ }
2109
+