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