langscan 1.2

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