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,61 @@
1
+ #ifndef LANGSCAN_SH_H
2
+ #define LANGSCAN_SH_H
3
+
4
+ #define LANGSCAN_SH_TOKEN_LIST \
5
+ LANGSCAN_SH_TOKEN(string) \
6
+ LANGSCAN_SH_TOKEN(fundef) \
7
+ LANGSCAN_SH_TOKEN(ident) \
8
+ LANGSCAN_SH_TOKEN(punct) \
9
+ LANGSCAN_SH_TOKEN(comment) \
10
+ LANGSCAN_SH_TOKEN(space) \
11
+ LANGSCAN_SH_TOKEN(heredoc_beg) \
12
+ LANGSCAN_SH_TOKEN(heredoc_end)
13
+
14
+ typedef enum {
15
+ langscan_sh_eof = 0,
16
+ #define LANGSCAN_SH_TOKEN(name) langscan_sh_##name,
17
+ LANGSCAN_SH_TOKEN_LIST
18
+ #undef LANGSCAN_SH_TOKEN
19
+ } langscan_sh_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_sh_lex_extra_t;
34
+
35
+ typedef struct langscan_sh_tokenizer_tag {
36
+ langscan_sh_lex_extra_t *extra;
37
+ void *scanner;
38
+ } langscan_sh_tokenizer_t;
39
+
40
+ typedef size_t (*user_read_t)(void **user_data_p, char *buf, size_t maxlen);
41
+
42
+ langscan_sh_tokenizer_t *langscan_sh_make_tokenizer(user_read_t user_read, void *user_data);
43
+ langscan_sh_token_t langscan_sh_get_token(langscan_sh_tokenizer_t *tokenizer);
44
+ void langscan_sh_free_tokenizer(langscan_sh_tokenizer_t *tokenizer);
45
+
46
+ user_read_t langscan_sh_tokenizer_get_user_read(langscan_sh_tokenizer_t *tokenizer);
47
+ void *langscan_sh_tokenizer_get_user_data(langscan_sh_tokenizer_t *tokenizer);
48
+
49
+ const char *langscan_sh_token_name(langscan_sh_token_t token);
50
+ #define langscan_sh_curtoken_beg_lineno(tokenizer) ((tokenizer)->extra->beg_lineno)
51
+ #define langscan_sh_curtoken_beg_columnno(tokenizer) ((tokenizer)->extra->beg_columnno)
52
+ #define langscan_sh_curtoken_beg_byteno(tokenizer) ((tokenizer)->extra->beg_byteno)
53
+ #define langscan_sh_curtoken_end_lineno(tokenizer) ((tokenizer)->extra->end_lineno)
54
+ #define langscan_sh_curtoken_end_columnno(tokenizer) ((tokenizer)->extra->end_columnno)
55
+ #define langscan_sh_curtoken_end_byteno(tokenizer) ((tokenizer)->extra->end_byteno)
56
+ #define langscan_sh_curtoken_text(tokenizer) ((tokenizer)->extra->text)
57
+ #define langscan_sh_curtoken_leng(tokenizer) ((tokenizer)->extra->leng)
58
+
59
+ void langscan_sh_extract_functions(langscan_sh_tokenizer_t *);
60
+
61
+ #endif
@@ -0,0 +1,2470 @@
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_sh_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_sh_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_sh_lex_restart (FILE *input_file ,yyscan_t yyscanner );
280
+ void langscan_sh_lex__switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
281
+ YY_BUFFER_STATE langscan_sh_lex__create_buffer (FILE *file,int size ,yyscan_t yyscanner );
282
+ void langscan_sh_lex__delete_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
283
+ void langscan_sh_lex__flush_buffer (YY_BUFFER_STATE b ,yyscan_t yyscanner );
284
+ void langscan_sh_lex_push_buffer_state (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
285
+ void langscan_sh_lex_pop_buffer_state (yyscan_t yyscanner );
286
+
287
+ static void langscan_sh_lex_ensure_buffer_stack (yyscan_t yyscanner );
288
+ static void langscan_sh_lex__load_buffer_state (yyscan_t yyscanner );
289
+ static void langscan_sh_lex__init_buffer (YY_BUFFER_STATE b,FILE *file ,yyscan_t yyscanner );
290
+
291
+ #define YY_FLUSH_BUFFER langscan_sh_lex__flush_buffer(YY_CURRENT_BUFFER ,yyscanner)
292
+
293
+ YY_BUFFER_STATE langscan_sh_lex__scan_buffer (char *base,yy_size_t size ,yyscan_t yyscanner );
294
+ YY_BUFFER_STATE langscan_sh_lex__scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
295
+ YY_BUFFER_STATE langscan_sh_lex__scan_bytes (yyconst char *bytes,yy_size_t len ,yyscan_t yyscanner );
296
+
297
+ void *langscan_sh_lex_alloc (yy_size_t ,yyscan_t yyscanner );
298
+ void *langscan_sh_lex_realloc (void *,yy_size_t ,yyscan_t yyscanner );
299
+ void langscan_sh_lex_free (void * ,yyscan_t yyscanner );
300
+
301
+ #define yy_new_buffer langscan_sh_lex__create_buffer
302
+
303
+ #define yy_set_interactive(is_interactive) \
304
+ { \
305
+ if ( ! YY_CURRENT_BUFFER ){ \
306
+ langscan_sh_lex_ensure_buffer_stack (yyscanner); \
307
+ YY_CURRENT_BUFFER_LVALUE = \
308
+ langscan_sh_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_sh_lex_ensure_buffer_stack (yyscanner); \
317
+ YY_CURRENT_BUFFER_LVALUE = \
318
+ langscan_sh_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_sh_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 27
352
+ #define YY_END_OF_BUFFER 28
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[164] =
361
+ { 0,
362
+ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
363
+ 0, 0, 0, 0, 0, 0, 28, 26, 19, 20,
364
+ 20, 26, 4, 26, 26, 26, 14, 22, 26, 26,
365
+ 26, 26, 7, 12, 26, 16, 6, 6, 6, 6,
366
+ 6, 5, 6, 6, 6, 6, 6, 6, 26, 6,
367
+ 6, 26, 8, 19, 11, 11, 11, 11, 11, 11,
368
+ 10, 15, 13, 2, 2, 2, 2, 2, 2, 2,
369
+ 2, 2, 2, 2, 2, 26, 3, 3, 3, 3,
370
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
371
+ 19, 17, 20, 25, 23, 14, 23, 23, 23, 9,
372
+
373
+ 0, 18, 0, 0, 22, 1, 24, 16, 6, 0,
374
+ 6, 6, 6, 6, 6, 6, 6, 6, 6, 0,
375
+ 19, 11, 2, 2, 2, 2, 2, 2, 2, 2,
376
+ 2, 2, 2, 2, 3, 3, 3, 3, 3, 3,
377
+ 3, 3, 3, 3, 3, 3, 3, 17, 23, 0,
378
+ 21, 1, 6, 6, 6, 6, 2, 2, 2, 3,
379
+ 3, 3, 0
380
+ } ;
381
+
382
+ static yyconst flex_int32_t yy_ec[256] =
383
+ { 0,
384
+ 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
385
+ 1, 1, 4, 1, 1, 1, 1, 1, 1, 1,
386
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
387
+ 1, 2, 5, 6, 7, 8, 1, 9, 10, 11,
388
+ 12, 13, 1, 1, 14, 15, 1, 16, 16, 16,
389
+ 16, 16, 16, 16, 16, 16, 16, 1, 17, 18,
390
+ 19, 20, 21, 22, 23, 23, 23, 23, 23, 23,
391
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
392
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
393
+ 1, 24, 1, 1, 25, 26, 23, 23, 23, 23,
394
+
395
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
396
+ 23, 23, 23, 23, 23, 23, 23, 23, 23, 23,
397
+ 23, 23, 27, 28, 29, 1, 1, 1, 1, 1,
398
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
399
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
400
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
401
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
402
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
403
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
404
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
405
+
406
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
407
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
408
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
409
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
410
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
411
+ 1, 1, 1, 1, 1
412
+ } ;
413
+
414
+ static yyconst flex_int32_t yy_meta[30] =
415
+ { 0,
416
+ 1, 2, 3, 1, 1, 4, 1, 4, 1, 1,
417
+ 2, 1, 1, 2, 2, 2, 1, 1, 1, 1,
418
+ 1, 1, 2, 1, 2, 4, 1, 1, 1
419
+ } ;
420
+
421
+ static yyconst flex_int16_t yy_base[175] =
422
+ { 0,
423
+ 0, 386, 29, 0, 41, 53, 78, 0, 50, 54,
424
+ 363, 58, 107, 0, 135, 161, 391, 394, 62, 394,
425
+ 387, 370, 394, 186, 379, 377, 394, 71, 369, 79,
426
+ 65, 0, 394, 394, 357, 0, 360, 136, 358, 78,
427
+ 51, 394, 54, 354, 212, 122, 131, 133, 73, 350,
428
+ 65, 86, 394, 368, 347, 394, 328, 145, 180, 0,
429
+ 394, 394, 394, 0, 332, 233, 334, 0, 257, 325,
430
+ 197, 135, 0, 0, 312, 309, 0, 332, 326, 304,
431
+ 278, 306, 0, 302, 291, 201, 139, 0, 0, 268,
432
+ 210, 0, 394, 394, 394, 394, 394, 206, 209, 394,
433
+
434
+ 285, 394, 190, 231, 0, 234, 394, 0, 269, 258,
435
+ 237, 252, 233, 263, 251, 0, 180, 227, 218, 232,
436
+ 228, 0, 0, 0, 0, 0, 0, 244, 254, 279,
437
+ 276, 0, 200, 0, 0, 193, 0, 0, 0, 0,
438
+ 282, 286, 295, 308, 0, 141, 0, 0, 296, 312,
439
+ 394, 394, 221, 320, 127, 82, 310, 326, 0, 314,
440
+ 329, 0, 394, 344, 88, 348, 352, 356, 359, 363,
441
+ 367, 371, 375, 379
442
+ } ;
443
+
444
+ static yyconst flex_int16_t yy_def[175] =
445
+ { 0,
446
+ 163, 1, 163, 3, 1, 1, 1, 7, 1, 1,
447
+ 1, 1, 163, 13, 1, 163, 163, 163, 163, 163,
448
+ 163, 163, 163, 163, 163, 164, 163, 165, 163, 163,
449
+ 163, 166, 163, 163, 163, 167, 168, 168, 168, 168,
450
+ 168, 163, 168, 168, 168, 168, 168, 168, 169, 168,
451
+ 168, 163, 163, 163, 163, 163, 24, 165, 58, 59,
452
+ 163, 163, 163, 170, 170, 170, 170, 170, 170, 170,
453
+ 170, 170, 171, 170, 170, 24, 172, 172, 172, 172,
454
+ 172, 172, 172, 172, 172, 172, 172, 173, 172, 172,
455
+ 163, 174, 163, 163, 163, 163, 163, 163, 163, 163,
456
+
457
+ 164, 163, 163, 163, 58, 163, 163, 167, 168, 168,
458
+ 168, 168, 168, 168, 168, 45, 168, 168, 168, 163,
459
+ 163, 59, 170, 170, 170, 170, 170, 170, 170, 170,
460
+ 170, 69, 170, 170, 172, 172, 172, 172, 172, 172,
461
+ 172, 172, 172, 172, 84, 172, 172, 174, 163, 163,
462
+ 163, 163, 168, 168, 168, 168, 170, 170, 170, 172,
463
+ 172, 172, 0, 163, 163, 163, 163, 163, 163, 163,
464
+ 163, 163, 163, 163
465
+ } ;
466
+
467
+ static yyconst flex_int16_t yy_nxt[424] =
468
+ { 0,
469
+ 18, 19, 20, 21, 22, 23, 18, 24, 25, 26,
470
+ 27, 18, 18, 18, 18, 28, 29, 30, 18, 31,
471
+ 18, 18, 28, 32, 28, 33, 34, 35, 18, 37,
472
+ 38, 39, 40, 41, 42, 37, 24, 43, 37, 44,
473
+ 37, 37, 37, 37, 45, 46, 47, 37, 48, 37,
474
+ 37, 45, 49, 45, 33, 50, 51, 37, 52, 36,
475
+ 36, 62, 113, 91, 36, 62, 53, 52, 92, 113,
476
+ 52, 52, 103, 94, 110, 109, 119, 110, 53, 54,
477
+ 112, 104, 55, 94, 56, 57, 63, 94, 110, 105,
478
+ 56, 56, 113, 58, 94, 52, 106, 94, 56, 56,
479
+
480
+ 59, 110, 60, 120, 94, 110, 61, 64, 54, 20,
481
+ 21, 65, 64, 64, 66, 67, 64, 68, 64, 64,
482
+ 64, 64, 69, 70, 71, 64, 72, 64, 64, 69,
483
+ 73, 69, 64, 74, 75, 64, 54, 111, 113, 113,
484
+ 18, 113, 76, 124, 18, 110, 103, 137, 117, 113,
485
+ 110, 113, 52, 124, 110, 104, 110, 137, 137, 110,
486
+ 18, 77, 78, 20, 79, 80, 77, 77, 81, 82,
487
+ 77, 83, 77, 77, 77, 77, 84, 85, 86, 77,
488
+ 87, 77, 77, 84, 88, 84, 77, 89, 90, 77,
489
+ 95, 103, 95, 95, 136, 122, 96, 113, 95, 95,
490
+
491
+ 104, 97, 122, 110, 122, 124, 95, 95, 98, 137,
492
+ 99, 91, 100, 114, 133, 124, 92, 124, 146, 137,
493
+ 156, 149, 115, 156, 149, 116, 116, 116, 149, 121,
494
+ 149, 149, 150, 149, 116, 110, 116, 125, 111, 125,
495
+ 125, 110, 151, 126, 110, 125, 125, 152, 127, 94,
496
+ 110, 94, 154, 125, 125, 128, 110, 129, 130, 157,
497
+ 110, 153, 155, 109, 114, 109, 157, 131, 157, 157,
498
+ 132, 132, 132, 115, 110, 110, 157, 158, 157, 132,
499
+ 130, 132, 138, 109, 138, 138, 110, 159, 139, 131,
500
+ 138, 138, 110, 140, 102, 137, 143, 160, 138, 138,
501
+
502
+ 141, 160, 142, 143, 160, 144, 160, 137, 160, 161,
503
+ 160, 149, 144, 150, 137, 145, 145, 145, 149, 162,
504
+ 149, 154, 137, 151, 145, 157, 145, 158, 93, 160,
505
+ 161, 155, 157, 136, 157, 163, 160, 159, 160, 124,
506
+ 162, 124, 124, 110, 101, 101, 101, 101, 107, 107,
507
+ 124, 107, 108, 108, 163, 108, 109, 109, 109, 118,
508
+ 118, 118, 118, 123, 123, 94, 123, 134, 134, 121,
509
+ 134, 135, 135, 110, 135, 147, 147, 110, 147, 148,
510
+ 148, 110, 148, 110, 94, 94, 102, 94, 94, 93,
511
+ 163, 63, 36, 17, 163, 163, 163, 163, 163, 163,
512
+
513
+ 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
514
+ 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
515
+ 163, 163, 163
516
+ } ;
517
+
518
+ static yyconst flex_int16_t yy_chk[424] =
519
+ { 0,
520
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
521
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
522
+ 1, 1, 1, 1, 1, 1, 1, 1, 1, 3,
523
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
524
+ 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
525
+ 3, 3, 3, 3, 3, 3, 3, 3, 5, 6,
526
+ 10, 9, 43, 19, 12, 10, 5, 9, 19, 41,
527
+ 6, 10, 28, 31, 41, 49, 49, 43, 6, 7,
528
+ 40, 28, 7, 31, 7, 7, 12, 30, 51, 165,
529
+ 7, 7, 51, 7, 52, 7, 30, 30, 7, 7,
530
+
531
+ 7, 40, 7, 52, 52, 156, 7, 13, 13, 13,
532
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
533
+ 13, 13, 13, 13, 13, 13, 13, 13, 13, 13,
534
+ 13, 13, 13, 13, 13, 13, 15, 38, 46, 47,
535
+ 15, 48, 15, 72, 15, 46, 58, 87, 47, 47,
536
+ 155, 48, 15, 72, 47, 58, 48, 87, 146, 38,
537
+ 15, 16, 16, 16, 16, 16, 16, 16, 16, 16,
538
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
539
+ 16, 16, 16, 16, 16, 16, 16, 16, 16, 16,
540
+ 24, 103, 24, 24, 136, 59, 24, 117, 24, 24,
541
+
542
+ 103, 24, 59, 117, 59, 71, 24, 24, 24, 86,
543
+ 24, 91, 24, 45, 71, 71, 91, 133, 86, 86,
544
+ 119, 98, 45, 153, 99, 45, 45, 45, 98, 121,
545
+ 98, 99, 104, 99, 45, 45, 45, 66, 111, 66,
546
+ 66, 119, 104, 66, 153, 66, 66, 106, 66, 120,
547
+ 118, 106, 115, 66, 66, 66, 113, 66, 69, 128,
548
+ 111, 110, 115, 110, 114, 110, 128, 69, 128, 129,
549
+ 69, 69, 69, 114, 115, 112, 129, 131, 129, 69,
550
+ 130, 69, 81, 110, 81, 81, 114, 131, 81, 130,
551
+ 81, 81, 109, 81, 101, 90, 143, 141, 81, 81,
552
+
553
+ 81, 142, 81, 84, 141, 143, 141, 85, 142, 144,
554
+ 142, 149, 84, 150, 82, 84, 84, 84, 149, 144,
555
+ 149, 154, 80, 150, 84, 157, 84, 158, 79, 160,
556
+ 161, 154, 157, 78, 157, 76, 160, 158, 160, 75,
557
+ 161, 70, 67, 154, 164, 164, 164, 164, 166, 166,
558
+ 65, 166, 167, 167, 57, 167, 168, 168, 168, 169,
559
+ 169, 169, 169, 170, 170, 55, 170, 171, 171, 54,
560
+ 171, 172, 172, 50, 172, 173, 173, 44, 173, 174,
561
+ 174, 39, 174, 37, 35, 29, 26, 25, 22, 21,
562
+ 17, 11, 2, 163, 163, 163, 163, 163, 163, 163,
563
+
564
+ 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
565
+ 163, 163, 163, 163, 163, 163, 163, 163, 163, 163,
566
+ 163, 163, 163
567
+ } ;
568
+
569
+ /* The intent behind this definition is that it'll catch
570
+ * any uses of REJECT which flex missed.
571
+ */
572
+ #define REJECT reject_used_but_not_detected
573
+ #define yymore() yymore_used_but_not_detected
574
+ #define YY_MORE_ADJ 0
575
+ #define YY_RESTORE_YY_MORE_OFFSET
576
+ /*
577
+ * shtok.l - a lex rule for shell scripts
578
+ *
579
+ * Copyright (C) 2005 Kenichi Ishibashi <bashi at dream.ie.ariake-nct.ac.jp>
580
+ * All rights reserved.
581
+ * This is free software with ABSOLUTELY NO WARRANTY.
582
+ *
583
+ * You can redistribute it and/or modify it under the terms of
584
+ * the GNU General Public License version 2.
585
+ */
586
+
587
+ #include "sh.h"
588
+
589
+ #define YY_EXTRA_TYPE langscan_sh_lex_extra_t *
590
+
591
+ #if YY_NULL != 0
592
+ #error "YY_NULL is not 0."
593
+ #endif
594
+
595
+ #define YY_DECL langscan_sh_token_t langscan_sh_lex_lex(yyscan_t yyscanner)
596
+
597
+ #define YY_INPUT(buf,result,max_size) \
598
+ if (!yyextra->eof) { \
599
+ result = yyextra->user_read(&(yyextra->user_data), (buf), (max_size)); \
600
+ if (result == 0) \
601
+ yyextra->eof = 1; \
602
+ }
603
+
604
+ #define UPD update_pos(yyextra, yytext, yyleng)
605
+ static void update_pos(langscan_sh_lex_extra_t *, char *, int);
606
+
607
+ #define report(token) \
608
+ do { \
609
+ yyextra->text = yytext; \
610
+ yyextra->leng = yyleng; \
611
+ return langscan_sh_##token; \
612
+ } while (0)
613
+
614
+ #define PUSH_STATE(state) yy_push_state(state, yyscanner)
615
+ #define POP_STATE yy_pop_state(yyscanner)
616
+
617
+ static int ident_length(unsigned char *ptr, int max);
618
+
619
+ static char *heredoc_delimiter;
620
+ static enum { HEREDOC_TAB_NO_STRIP, HEREDOC_TAB_STRIP } heredoc_type;
621
+ static int set_heredoc_delimiter(unsigned char *ptr, int max);
622
+
623
+ #define INITIAL 0
624
+ #define DQUOTE 1
625
+ #define BQUOTE 2
626
+ #define BRACE_SUBST 3
627
+ #define PAREN_SUBST 4
628
+ #define IN_BRACE 5
629
+ #define HEREDOC_DELIMITER 6
630
+ #define HEREDOC 7
631
+
632
+ #ifndef YY_NO_UNISTD_H
633
+ /* Special case for "unistd.h", since it is non-ANSI. We include it way
634
+ * down here because we want the user's section 1 to have been scanned first.
635
+ * The user has a chance to override it with an option.
636
+ */
637
+ #include <unistd.h>
638
+ #endif
639
+
640
+ #ifndef YY_EXTRA_TYPE
641
+ #define YY_EXTRA_TYPE void *
642
+ #endif
643
+
644
+ /* Holds the entire state of the reentrant scanner. */
645
+ struct yyguts_t
646
+ {
647
+
648
+ /* User-defined. Not touched by flex. */
649
+ YY_EXTRA_TYPE yyextra_r;
650
+
651
+ /* The rest are the same as the globals declared in the non-reentrant scanner. */
652
+ FILE *yyin_r, *yyout_r;
653
+ size_t yy_buffer_stack_top; /**< index of top of stack. */
654
+ size_t yy_buffer_stack_max; /**< capacity of stack. */
655
+ YY_BUFFER_STATE * yy_buffer_stack; /**< Stack as an array. */
656
+ char yy_hold_char;
657
+ yy_size_t yy_n_chars;
658
+ yy_size_t yyleng_r;
659
+ char *yy_c_buf_p;
660
+ int yy_init;
661
+ int yy_start;
662
+ int yy_did_buffer_switch_on_eof;
663
+ int yy_start_stack_ptr;
664
+ int yy_start_stack_depth;
665
+ int *yy_start_stack;
666
+ yy_state_type yy_last_accepting_state;
667
+ char* yy_last_accepting_cpos;
668
+
669
+ int yylineno_r;
670
+ int yy_flex_debug_r;
671
+
672
+ char *yytext_r;
673
+ int yy_more_flag;
674
+ int yy_more_len;
675
+
676
+ }; /* end struct yyguts_t */
677
+
678
+ static int yy_init_globals (yyscan_t yyscanner );
679
+
680
+ int langscan_sh_lex_lex_init (yyscan_t* scanner);
681
+
682
+ int langscan_sh_lex_lex_init_extra (YY_EXTRA_TYPE user_defined,yyscan_t* scanner);
683
+
684
+ /* Accessor methods to globals.
685
+ These are made visible to non-reentrant scanners for convenience. */
686
+
687
+ int langscan_sh_lex_lex_destroy (yyscan_t yyscanner );
688
+
689
+ int langscan_sh_lex_get_debug (yyscan_t yyscanner );
690
+
691
+ void langscan_sh_lex_set_debug (int debug_flag ,yyscan_t yyscanner );
692
+
693
+ YY_EXTRA_TYPE langscan_sh_lex_get_extra (yyscan_t yyscanner );
694
+
695
+ void langscan_sh_lex_set_extra (YY_EXTRA_TYPE user_defined ,yyscan_t yyscanner );
696
+
697
+ FILE *langscan_sh_lex_get_in (yyscan_t yyscanner );
698
+
699
+ void langscan_sh_lex_set_in (FILE * in_str ,yyscan_t yyscanner );
700
+
701
+ FILE *langscan_sh_lex_get_out (yyscan_t yyscanner );
702
+
703
+ void langscan_sh_lex_set_out (FILE * out_str ,yyscan_t yyscanner );
704
+
705
+ yy_size_t langscan_sh_lex_get_leng (yyscan_t yyscanner );
706
+
707
+ char *langscan_sh_lex_get_text (yyscan_t yyscanner );
708
+
709
+ int langscan_sh_lex_get_lineno (yyscan_t yyscanner );
710
+
711
+ void langscan_sh_lex_set_lineno (int line_number ,yyscan_t yyscanner );
712
+
713
+ /* Macros after this point can all be overridden by user definitions in
714
+ * section 1.
715
+ */
716
+
717
+ #ifndef YY_SKIP_YYWRAP
718
+ #ifdef __cplusplus
719
+ extern "C" int langscan_sh_lex_wrap (yyscan_t yyscanner );
720
+ #else
721
+ extern int langscan_sh_lex_wrap (yyscan_t yyscanner );
722
+ #endif
723
+ #endif
724
+
725
+ static void yyunput (int c,char *buf_ptr ,yyscan_t yyscanner);
726
+
727
+ #ifndef yytext_ptr
728
+ static void yy_flex_strncpy (char *,yyconst char *,int ,yyscan_t yyscanner);
729
+ #endif
730
+
731
+ #ifdef YY_NEED_STRLEN
732
+ static int yy_flex_strlen (yyconst char * ,yyscan_t yyscanner);
733
+ #endif
734
+
735
+ #ifndef YY_NO_INPUT
736
+
737
+ #ifdef __cplusplus
738
+ static int yyinput (yyscan_t yyscanner );
739
+ #else
740
+ static int input (yyscan_t yyscanner );
741
+ #endif
742
+
743
+ #endif
744
+
745
+ static void yy_push_state (int new_state ,yyscan_t yyscanner);
746
+
747
+ static void yy_pop_state (yyscan_t yyscanner );
748
+
749
+ static int yy_top_state (yyscan_t yyscanner );
750
+
751
+ /* Amount of stuff to slurp up with each read. */
752
+ #ifndef YY_READ_BUF_SIZE
753
+ #define YY_READ_BUF_SIZE 8192
754
+ #endif
755
+
756
+ /* Copy whatever the last rule matched to the standard output. */
757
+ #ifndef ECHO
758
+ /* This used to be an fputs(), but since the string might contain NUL's,
759
+ * we now use fwrite().
760
+ */
761
+ #define ECHO fwrite( yytext, yyleng, 1, yyout )
762
+ #endif
763
+
764
+ /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
765
+ * is returned in "result".
766
+ */
767
+ #ifndef YY_INPUT
768
+ #define YY_INPUT(buf,result,max_size) \
769
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
770
+ { \
771
+ int c = '*'; \
772
+ yy_size_t n; \
773
+ for ( n = 0; n < max_size && \
774
+ (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
775
+ buf[n] = (char) c; \
776
+ if ( c == '\n' ) \
777
+ buf[n++] = (char) c; \
778
+ if ( c == EOF && ferror( yyin ) ) \
779
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
780
+ result = n; \
781
+ } \
782
+ else \
783
+ { \
784
+ errno=0; \
785
+ while ( (result = fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
786
+ { \
787
+ if( errno != EINTR) \
788
+ { \
789
+ YY_FATAL_ERROR( "input in flex scanner failed" ); \
790
+ break; \
791
+ } \
792
+ errno=0; \
793
+ clearerr(yyin); \
794
+ } \
795
+ }\
796
+ \
797
+
798
+ #endif
799
+
800
+ /* No semi-colon after return; correct usage is to write "yyterminate();" -
801
+ * we don't want an extra ';' after the "return" because that will cause
802
+ * some compilers to complain about unreachable statements.
803
+ */
804
+ #ifndef yyterminate
805
+ #define yyterminate() return YY_NULL
806
+ #endif
807
+
808
+ /* Number of entries by which start-condition stack grows. */
809
+ #ifndef YY_START_STACK_INCR
810
+ #define YY_START_STACK_INCR 25
811
+ #endif
812
+
813
+ /* Report a fatal error. */
814
+ #ifndef YY_FATAL_ERROR
815
+ #define YY_FATAL_ERROR(msg) yy_fatal_error( msg , yyscanner)
816
+ #endif
817
+
818
+ /* end tables serialization structures and prototypes */
819
+
820
+ /* Default declaration of generated scanner - a define so the user can
821
+ * easily add parameters.
822
+ */
823
+ #ifndef YY_DECL
824
+ #define YY_DECL_IS_OURS 1
825
+
826
+ extern int langscan_sh_lex_lex (yyscan_t yyscanner);
827
+
828
+ #define YY_DECL int langscan_sh_lex_lex (yyscan_t yyscanner)
829
+ #endif /* !YY_DECL */
830
+
831
+ /* Code executed at the beginning of each rule, after yytext and yyleng
832
+ * have been set up.
833
+ */
834
+ #ifndef YY_USER_ACTION
835
+ #define YY_USER_ACTION
836
+ #endif
837
+
838
+ /* Code executed at the end of each rule. */
839
+ #ifndef YY_BREAK
840
+ #define YY_BREAK break;
841
+ #endif
842
+
843
+ #define YY_RULE_SETUP \
844
+ if ( yyleng > 0 ) \
845
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
846
+ (yytext[yyleng - 1] == '\n'); \
847
+ YY_USER_ACTION
848
+
849
+ /** The main scanner function which does all the work.
850
+ */
851
+ YY_DECL
852
+ {
853
+ register yy_state_type yy_current_state;
854
+ register char *yy_cp, *yy_bp;
855
+ register int yy_act;
856
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
857
+
858
+ if ( !yyg->yy_init )
859
+ {
860
+ yyg->yy_init = 1;
861
+
862
+ #ifdef YY_USER_INIT
863
+ YY_USER_INIT;
864
+ #endif
865
+
866
+ if ( ! yyg->yy_start )
867
+ yyg->yy_start = 1; /* first start state */
868
+
869
+ if ( ! yyin )
870
+ yyin = stdin;
871
+
872
+ if ( ! yyout )
873
+ yyout = stdout;
874
+
875
+ if ( ! YY_CURRENT_BUFFER ) {
876
+ langscan_sh_lex_ensure_buffer_stack (yyscanner);
877
+ YY_CURRENT_BUFFER_LVALUE =
878
+ langscan_sh_lex__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
879
+ }
880
+
881
+ langscan_sh_lex__load_buffer_state(yyscanner );
882
+ }
883
+
884
+ while ( 1 ) /* loops until end-of-file is reached */
885
+ {
886
+ yy_cp = yyg->yy_c_buf_p;
887
+
888
+ /* Support of yytext. */
889
+ *yy_cp = yyg->yy_hold_char;
890
+
891
+ /* yy_bp points to the position in yy_ch_buf of the start of
892
+ * the current run.
893
+ */
894
+ yy_bp = yy_cp;
895
+
896
+ yy_current_state = yyg->yy_start;
897
+ yy_current_state += YY_AT_BOL();
898
+ yy_match:
899
+ do
900
+ {
901
+ register YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)];
902
+ if ( yy_accept[yy_current_state] )
903
+ {
904
+ yyg->yy_last_accepting_state = yy_current_state;
905
+ yyg->yy_last_accepting_cpos = yy_cp;
906
+ }
907
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
908
+ {
909
+ yy_current_state = (int) yy_def[yy_current_state];
910
+ if ( yy_current_state >= 164 )
911
+ yy_c = yy_meta[(unsigned int) yy_c];
912
+ }
913
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
914
+ ++yy_cp;
915
+ }
916
+ while ( yy_base[yy_current_state] != 394 );
917
+
918
+ yy_find_action:
919
+ yy_act = yy_accept[yy_current_state];
920
+ if ( yy_act == 0 )
921
+ { /* have to back up */
922
+ yy_cp = yyg->yy_last_accepting_cpos;
923
+ yy_current_state = yyg->yy_last_accepting_state;
924
+ yy_act = yy_accept[yy_current_state];
925
+ }
926
+
927
+ YY_DO_BEFORE_ACTION;
928
+
929
+ do_action: /* This label is used only to access EOF actions. */
930
+
931
+ switch ( yy_act )
932
+ { /* beginning of action switch */
933
+ case 0: /* must back up */
934
+ /* undo the effects of YY_DO_BEFORE_ACTION */
935
+ *yy_cp = yyg->yy_hold_char;
936
+ yy_cp = yyg->yy_last_accepting_cpos;
937
+ yy_current_state = yyg->yy_last_accepting_state;
938
+ goto yy_find_action;
939
+
940
+ case 1:
941
+ YY_RULE_SETUP
942
+ {
943
+ if (yytext[yyleng - 1] == '-')
944
+ heredoc_type = HEREDOC_TAB_STRIP;
945
+ else
946
+ heredoc_type = HEREDOC_TAB_NO_STRIP;
947
+ UPD;
948
+ PUSH_STATE(HEREDOC_DELIMITER);
949
+ report(punct);
950
+ }
951
+ YY_BREAK
952
+ case 2:
953
+ YY_RULE_SETUP
954
+ {
955
+ int delimiter_leng;
956
+ delimiter_leng = set_heredoc_delimiter(yytext, yyleng);
957
+ if (delimiter_leng == -1) YY_FATAL_ERROR("Can't allocate memory");
958
+ yyless(delimiter_leng);
959
+ PUSH_STATE(HEREDOC);
960
+ UPD;
961
+ report(heredoc_beg);
962
+ }
963
+ YY_BREAK
964
+ case 3:
965
+ YY_RULE_SETUP
966
+ {
967
+ int sleng;
968
+ sleng = 0;
969
+ if (heredoc_type == HEREDOC_TAB_STRIP) {
970
+ while (yytext[sleng] == ' ' || yytext[sleng] =='\t') {
971
+ sleng++;
972
+ if (sleng >= yyleng) { UPD; report(space); }
973
+ }
974
+ }
975
+ if (strcmp((yytext + sleng), heredoc_delimiter) == 0) { /* end-of-heredoc */
976
+ free(heredoc_delimiter);
977
+ POP_STATE;
978
+ POP_STATE;
979
+ UPD; report(heredoc_end);
980
+ }
981
+ else {
982
+ UPD; report(string);
983
+ }
984
+ }
985
+ YY_BREAK
986
+ case YY_STATE_EOF(HEREDOC):
987
+ {
988
+ free(heredoc_delimiter);
989
+ BEGIN(INITIAL);
990
+ UPD; report(string);
991
+ }
992
+ YY_BREAK
993
+ case 4:
994
+ YY_RULE_SETUP
995
+ {
996
+ PUSH_STATE(DQUOTE);
997
+ UPD; report(punct);
998
+ }
999
+ YY_BREAK
1000
+ case 5:
1001
+ YY_RULE_SETUP
1002
+ {
1003
+ POP_STATE;
1004
+ UPD; report(punct);
1005
+ }
1006
+ YY_BREAK
1007
+ case YY_STATE_EOF(DQUOTE):
1008
+ { BEGIN(INITIAL); }
1009
+ YY_BREAK
1010
+ case 6:
1011
+ /* rule 6 can match eol */
1012
+ YY_RULE_SETUP
1013
+ { UPD; report(string); }
1014
+ YY_BREAK
1015
+ case 7:
1016
+ YY_RULE_SETUP
1017
+ {
1018
+ PUSH_STATE(BQUOTE);
1019
+ UPD; report(punct);
1020
+ }
1021
+ YY_BREAK
1022
+ case 8:
1023
+ YY_RULE_SETUP
1024
+ {
1025
+ POP_STATE;
1026
+ UPD; report(punct);
1027
+ }
1028
+ YY_BREAK
1029
+ case YY_STATE_EOF(BQUOTE):
1030
+ { BEGIN(INITIAL); }
1031
+ YY_BREAK
1032
+ case 9:
1033
+ YY_RULE_SETUP
1034
+ {
1035
+ PUSH_STATE(BRACE_SUBST);
1036
+ UPD; report(punct);
1037
+ }
1038
+ YY_BREAK
1039
+ case 10:
1040
+ YY_RULE_SETUP
1041
+ {
1042
+ POP_STATE;
1043
+ UPD; report(punct);
1044
+ }
1045
+ YY_BREAK
1046
+ case 11:
1047
+ YY_RULE_SETUP
1048
+ { UPD; report(ident); }
1049
+ YY_BREAK
1050
+ case YY_STATE_EOF(BRACE_SUBST):
1051
+ { BEGIN(INITIAL); }
1052
+ YY_BREAK
1053
+ case 12:
1054
+ YY_RULE_SETUP
1055
+ {
1056
+ PUSH_STATE(IN_BRACE);
1057
+ UPD; report(punct);
1058
+ }
1059
+ YY_BREAK
1060
+ case 13:
1061
+ YY_RULE_SETUP
1062
+ {
1063
+ POP_STATE;
1064
+ UPD; report(punct);
1065
+ }
1066
+ YY_BREAK
1067
+ case YY_STATE_EOF(IN_BRACE):
1068
+ { BEGIN(INITIAL); }
1069
+ YY_BREAK
1070
+ case 14:
1071
+ YY_RULE_SETUP
1072
+ {
1073
+ PUSH_STATE(PAREN_SUBST);
1074
+ UPD; report(punct);
1075
+ }
1076
+ YY_BREAK
1077
+ case 15:
1078
+ YY_RULE_SETUP
1079
+ {
1080
+ POP_STATE;
1081
+ UPD; report(punct);
1082
+ }
1083
+ YY_BREAK
1084
+ case YY_STATE_EOF(PAREN_SUBST):
1085
+ { BEGIN(INITIAL); }
1086
+ YY_BREAK
1087
+ case 16:
1088
+ YY_RULE_SETUP
1089
+ { UPD; report(comment); }
1090
+ YY_BREAK
1091
+ case 17:
1092
+ YY_RULE_SETUP
1093
+ { UPD; report(comment); }
1094
+ YY_BREAK
1095
+ case 18:
1096
+ /* rule 18 can match eol */
1097
+ YY_RULE_SETUP
1098
+ { UPD; report(string); }
1099
+ YY_BREAK
1100
+ case 19:
1101
+ YY_RULE_SETUP
1102
+ { UPD; report(space); }
1103
+ YY_BREAK
1104
+ case 20:
1105
+ /* rule 20 can match eol */
1106
+ YY_RULE_SETUP
1107
+ { UPD; report(space); }
1108
+ YY_BREAK
1109
+ case 21:
1110
+ YY_RULE_SETUP
1111
+ { yyless(ident_length(yytext, yyleng)); UPD; report(fundef); }
1112
+ YY_BREAK
1113
+ case 22:
1114
+ YY_RULE_SETUP
1115
+ { UPD; report(ident); }
1116
+ YY_BREAK
1117
+ case 23:
1118
+ YY_RULE_SETUP
1119
+ { UPD; report(ident); }
1120
+ YY_BREAK
1121
+ case 24:
1122
+ YY_RULE_SETUP
1123
+ { UPD; report(punct); }
1124
+ YY_BREAK
1125
+ case 25:
1126
+ YY_RULE_SETUP
1127
+ { UPD; report(punct); }
1128
+ YY_BREAK
1129
+ case 26:
1130
+ YY_RULE_SETUP
1131
+ { UPD; report(punct); }
1132
+ YY_BREAK
1133
+ case 27:
1134
+ YY_RULE_SETUP
1135
+ YY_FATAL_ERROR( "flex scanner jammed" );
1136
+ YY_BREAK
1137
+ case YY_STATE_EOF(INITIAL):
1138
+ case YY_STATE_EOF(HEREDOC_DELIMITER):
1139
+ yyterminate();
1140
+
1141
+ case YY_END_OF_BUFFER:
1142
+ {
1143
+ /* Amount of text matched not including the EOB char. */
1144
+ int yy_amount_of_matched_text = (int) (yy_cp - yyg->yytext_ptr) - 1;
1145
+
1146
+ /* Undo the effects of YY_DO_BEFORE_ACTION. */
1147
+ *yy_cp = yyg->yy_hold_char;
1148
+ YY_RESTORE_YY_MORE_OFFSET
1149
+
1150
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
1151
+ {
1152
+ /* We're scanning a new file or input source. It's
1153
+ * possible that this happened because the user
1154
+ * just pointed yyin at a new source and called
1155
+ * langscan_sh_lex_lex(). If so, then we have to assure
1156
+ * consistency between YY_CURRENT_BUFFER and our
1157
+ * globals. Here is the right place to do so, because
1158
+ * this is the first action (other than possibly a
1159
+ * back-up) that will match for the new input source.
1160
+ */
1161
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1162
+ YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
1163
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
1164
+ }
1165
+
1166
+ /* Note that here we test for yy_c_buf_p "<=" to the position
1167
+ * of the first EOB in the buffer, since yy_c_buf_p will
1168
+ * already have been incremented past the NUL character
1169
+ * (since all states make transitions on EOB to the
1170
+ * end-of-buffer state). Contrast this with the test
1171
+ * in input().
1172
+ */
1173
+ if ( yyg->yy_c_buf_p <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1174
+ { /* This was really a NUL. */
1175
+ yy_state_type yy_next_state;
1176
+
1177
+ yyg->yy_c_buf_p = yyg->yytext_ptr + yy_amount_of_matched_text;
1178
+
1179
+ yy_current_state = yy_get_previous_state( yyscanner );
1180
+
1181
+ /* Okay, we're now positioned to make the NUL
1182
+ * transition. We couldn't have
1183
+ * yy_get_previous_state() go ahead and do it
1184
+ * for us because it doesn't know how to deal
1185
+ * with the possibility of jamming (and we don't
1186
+ * want to build jamming into it because then it
1187
+ * will run more slowly).
1188
+ */
1189
+
1190
+ yy_next_state = yy_try_NUL_trans( yy_current_state , yyscanner);
1191
+
1192
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1193
+
1194
+ if ( yy_next_state )
1195
+ {
1196
+ /* Consume the NUL. */
1197
+ yy_cp = ++yyg->yy_c_buf_p;
1198
+ yy_current_state = yy_next_state;
1199
+ goto yy_match;
1200
+ }
1201
+
1202
+ else
1203
+ {
1204
+ yy_cp = yyg->yy_c_buf_p;
1205
+ goto yy_find_action;
1206
+ }
1207
+ }
1208
+
1209
+ else switch ( yy_get_next_buffer( yyscanner ) )
1210
+ {
1211
+ case EOB_ACT_END_OF_FILE:
1212
+ {
1213
+ yyg->yy_did_buffer_switch_on_eof = 0;
1214
+
1215
+ if ( langscan_sh_lex_wrap(yyscanner ) )
1216
+ {
1217
+ /* Note: because we've taken care in
1218
+ * yy_get_next_buffer() to have set up
1219
+ * yytext, we can now set up
1220
+ * yy_c_buf_p so that if some total
1221
+ * hoser (like flex itself) wants to
1222
+ * call the scanner after we return the
1223
+ * YY_NULL, it'll still work - another
1224
+ * YY_NULL will get returned.
1225
+ */
1226
+ yyg->yy_c_buf_p = yyg->yytext_ptr + YY_MORE_ADJ;
1227
+
1228
+ yy_act = YY_STATE_EOF(YY_START);
1229
+ goto do_action;
1230
+ }
1231
+
1232
+ else
1233
+ {
1234
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
1235
+ YY_NEW_FILE;
1236
+ }
1237
+ break;
1238
+ }
1239
+
1240
+ case EOB_ACT_CONTINUE_SCAN:
1241
+ yyg->yy_c_buf_p =
1242
+ yyg->yytext_ptr + yy_amount_of_matched_text;
1243
+
1244
+ yy_current_state = yy_get_previous_state( yyscanner );
1245
+
1246
+ yy_cp = yyg->yy_c_buf_p;
1247
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1248
+ goto yy_match;
1249
+
1250
+ case EOB_ACT_LAST_MATCH:
1251
+ yyg->yy_c_buf_p =
1252
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars];
1253
+
1254
+ yy_current_state = yy_get_previous_state( yyscanner );
1255
+
1256
+ yy_cp = yyg->yy_c_buf_p;
1257
+ yy_bp = yyg->yytext_ptr + YY_MORE_ADJ;
1258
+ goto yy_find_action;
1259
+ }
1260
+ break;
1261
+ }
1262
+
1263
+ default:
1264
+ YY_FATAL_ERROR(
1265
+ "fatal flex scanner internal error--no action found" );
1266
+ } /* end of action switch */
1267
+ } /* end of scanning one token */
1268
+ } /* end of langscan_sh_lex_lex */
1269
+
1270
+ /* yy_get_next_buffer - try to read in a new buffer
1271
+ *
1272
+ * Returns a code representing an action:
1273
+ * EOB_ACT_LAST_MATCH -
1274
+ * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
1275
+ * EOB_ACT_END_OF_FILE - end of file
1276
+ */
1277
+ static int yy_get_next_buffer (yyscan_t yyscanner)
1278
+ {
1279
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1280
+ register char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
1281
+ register char *source = yyg->yytext_ptr;
1282
+ register int number_to_move, i;
1283
+ int ret_val;
1284
+
1285
+ if ( yyg->yy_c_buf_p > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] )
1286
+ YY_FATAL_ERROR(
1287
+ "fatal flex scanner internal error--end of buffer missed" );
1288
+
1289
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
1290
+ { /* Don't try to fill the buffer, so this is an EOF. */
1291
+ if ( yyg->yy_c_buf_p - yyg->yytext_ptr - YY_MORE_ADJ == 1 )
1292
+ {
1293
+ /* We matched a single character, the EOB, so
1294
+ * treat this as a final EOF.
1295
+ */
1296
+ return EOB_ACT_END_OF_FILE;
1297
+ }
1298
+
1299
+ else
1300
+ {
1301
+ /* We matched some text prior to the EOB, first
1302
+ * process it.
1303
+ */
1304
+ return EOB_ACT_LAST_MATCH;
1305
+ }
1306
+ }
1307
+
1308
+ /* Try to read more data. */
1309
+
1310
+ /* First move last chars to start of buffer. */
1311
+ number_to_move = (int) (yyg->yy_c_buf_p - yyg->yytext_ptr) - 1;
1312
+
1313
+ for ( i = 0; i < number_to_move; ++i )
1314
+ *(dest++) = *(source++);
1315
+
1316
+ if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
1317
+ /* don't do the read, it's not guaranteed to return an EOF,
1318
+ * just force an EOF
1319
+ */
1320
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars = 0;
1321
+
1322
+ else
1323
+ {
1324
+ yy_size_t num_to_read =
1325
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
1326
+
1327
+ while ( num_to_read <= 0 )
1328
+ { /* Not enough room in the buffer - grow it. */
1329
+
1330
+ /* just a shorter name for the current buffer */
1331
+ YY_BUFFER_STATE b = YY_CURRENT_BUFFER;
1332
+
1333
+ int yy_c_buf_p_offset =
1334
+ (int) (yyg->yy_c_buf_p - b->yy_ch_buf);
1335
+
1336
+ if ( b->yy_is_our_buffer )
1337
+ {
1338
+ yy_size_t new_size = b->yy_buf_size * 2;
1339
+
1340
+ if ( new_size <= 0 )
1341
+ b->yy_buf_size += b->yy_buf_size / 8;
1342
+ else
1343
+ b->yy_buf_size *= 2;
1344
+
1345
+ b->yy_ch_buf = (char *)
1346
+ /* Include room in for 2 EOB chars. */
1347
+ langscan_sh_lex_realloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 ,yyscanner );
1348
+ }
1349
+ else
1350
+ /* Can't grow it, we don't own it. */
1351
+ b->yy_ch_buf = 0;
1352
+
1353
+ if ( ! b->yy_ch_buf )
1354
+ YY_FATAL_ERROR(
1355
+ "fatal error - scanner input buffer overflow" );
1356
+
1357
+ yyg->yy_c_buf_p = &b->yy_ch_buf[yy_c_buf_p_offset];
1358
+
1359
+ num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
1360
+ number_to_move - 1;
1361
+
1362
+ }
1363
+
1364
+ if ( num_to_read > YY_READ_BUF_SIZE )
1365
+ num_to_read = YY_READ_BUF_SIZE;
1366
+
1367
+ /* Read in more data. */
1368
+ YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
1369
+ yyg->yy_n_chars, num_to_read );
1370
+
1371
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1372
+ }
1373
+
1374
+ if ( yyg->yy_n_chars == 0 )
1375
+ {
1376
+ if ( number_to_move == YY_MORE_ADJ )
1377
+ {
1378
+ ret_val = EOB_ACT_END_OF_FILE;
1379
+ langscan_sh_lex_restart(yyin ,yyscanner);
1380
+ }
1381
+
1382
+ else
1383
+ {
1384
+ ret_val = EOB_ACT_LAST_MATCH;
1385
+ YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
1386
+ YY_BUFFER_EOF_PENDING;
1387
+ }
1388
+ }
1389
+
1390
+ else
1391
+ ret_val = EOB_ACT_CONTINUE_SCAN;
1392
+
1393
+ if ((yy_size_t) (yyg->yy_n_chars + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
1394
+ /* Extend the array by 50%, plus the number we really need. */
1395
+ yy_size_t new_size = yyg->yy_n_chars + number_to_move + (yyg->yy_n_chars >> 1);
1396
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) langscan_sh_lex_realloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size ,yyscanner );
1397
+ if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1398
+ YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
1399
+ }
1400
+
1401
+ yyg->yy_n_chars += number_to_move;
1402
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] = YY_END_OF_BUFFER_CHAR;
1403
+ YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars + 1] = YY_END_OF_BUFFER_CHAR;
1404
+
1405
+ yyg->yytext_ptr = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
1406
+
1407
+ return ret_val;
1408
+ }
1409
+
1410
+ /* yy_get_previous_state - get the state just before the EOB char was reached */
1411
+
1412
+ static yy_state_type yy_get_previous_state (yyscan_t yyscanner)
1413
+ {
1414
+ register yy_state_type yy_current_state;
1415
+ register char *yy_cp;
1416
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1417
+
1418
+ yy_current_state = yyg->yy_start;
1419
+ yy_current_state += YY_AT_BOL();
1420
+
1421
+ for ( yy_cp = yyg->yytext_ptr + YY_MORE_ADJ; yy_cp < yyg->yy_c_buf_p; ++yy_cp )
1422
+ {
1423
+ register YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
1424
+ if ( yy_accept[yy_current_state] )
1425
+ {
1426
+ yyg->yy_last_accepting_state = yy_current_state;
1427
+ yyg->yy_last_accepting_cpos = yy_cp;
1428
+ }
1429
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1430
+ {
1431
+ yy_current_state = (int) yy_def[yy_current_state];
1432
+ if ( yy_current_state >= 164 )
1433
+ yy_c = yy_meta[(unsigned int) yy_c];
1434
+ }
1435
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1436
+ }
1437
+
1438
+ return yy_current_state;
1439
+ }
1440
+
1441
+ /* yy_try_NUL_trans - try to make a transition on the NUL character
1442
+ *
1443
+ * synopsis
1444
+ * next_state = yy_try_NUL_trans( current_state );
1445
+ */
1446
+ static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state , yyscan_t yyscanner)
1447
+ {
1448
+ register int yy_is_jam;
1449
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner; /* This var may be unused depending upon options. */
1450
+ register char *yy_cp = yyg->yy_c_buf_p;
1451
+
1452
+ register YY_CHAR yy_c = 1;
1453
+ if ( yy_accept[yy_current_state] )
1454
+ {
1455
+ yyg->yy_last_accepting_state = yy_current_state;
1456
+ yyg->yy_last_accepting_cpos = yy_cp;
1457
+ }
1458
+ while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
1459
+ {
1460
+ yy_current_state = (int) yy_def[yy_current_state];
1461
+ if ( yy_current_state >= 164 )
1462
+ yy_c = yy_meta[(unsigned int) yy_c];
1463
+ }
1464
+ yy_current_state = yy_nxt[yy_base[yy_current_state] + (unsigned int) yy_c];
1465
+ yy_is_jam = (yy_current_state == 163);
1466
+
1467
+ return yy_is_jam ? 0 : yy_current_state;
1468
+ }
1469
+
1470
+ static void yyunput (int c, register char * yy_bp , yyscan_t yyscanner)
1471
+ {
1472
+ register char *yy_cp;
1473
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1474
+
1475
+ yy_cp = yyg->yy_c_buf_p;
1476
+
1477
+ /* undo effects of setting up yytext */
1478
+ *yy_cp = yyg->yy_hold_char;
1479
+
1480
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1481
+ { /* need to shift things up to make room */
1482
+ /* +2 for EOB chars. */
1483
+ register yy_size_t number_to_move = yyg->yy_n_chars + 2;
1484
+ register char *dest = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[
1485
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_size + 2];
1486
+ register char *source =
1487
+ &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move];
1488
+
1489
+ while ( source > YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
1490
+ *--dest = *--source;
1491
+
1492
+ yy_cp += (int) (dest - source);
1493
+ yy_bp += (int) (dest - source);
1494
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars =
1495
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_buf_size;
1496
+
1497
+ if ( yy_cp < YY_CURRENT_BUFFER_LVALUE->yy_ch_buf + 2 )
1498
+ YY_FATAL_ERROR( "flex scanner push-back overflow" );
1499
+ }
1500
+
1501
+ *--yy_cp = (char) c;
1502
+
1503
+ yyg->yytext_ptr = yy_bp;
1504
+ yyg->yy_hold_char = *yy_cp;
1505
+ yyg->yy_c_buf_p = yy_cp;
1506
+ }
1507
+
1508
+ #ifndef YY_NO_INPUT
1509
+ #ifdef __cplusplus
1510
+ static int yyinput (yyscan_t yyscanner)
1511
+ #else
1512
+ static int input (yyscan_t yyscanner)
1513
+ #endif
1514
+
1515
+ {
1516
+ int c;
1517
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1518
+
1519
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1520
+
1521
+ if ( *yyg->yy_c_buf_p == YY_END_OF_BUFFER_CHAR )
1522
+ {
1523
+ /* yy_c_buf_p now points to the character we want to return.
1524
+ * If this occurs *before* the EOB characters, then it's a
1525
+ * valid NUL; if not, then we've hit the end of the buffer.
1526
+ */
1527
+ if ( yyg->yy_c_buf_p < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[yyg->yy_n_chars] )
1528
+ /* This was really a NUL. */
1529
+ *yyg->yy_c_buf_p = '\0';
1530
+
1531
+ else
1532
+ { /* need more input */
1533
+ yy_size_t offset = yyg->yy_c_buf_p - yyg->yytext_ptr;
1534
+ ++yyg->yy_c_buf_p;
1535
+
1536
+ switch ( yy_get_next_buffer( yyscanner ) )
1537
+ {
1538
+ case EOB_ACT_LAST_MATCH:
1539
+ /* This happens because yy_g_n_b()
1540
+ * sees that we've accumulated a
1541
+ * token and flags that we need to
1542
+ * try matching the token before
1543
+ * proceeding. But for input(),
1544
+ * there's no matching to consider.
1545
+ * So convert the EOB_ACT_LAST_MATCH
1546
+ * to EOB_ACT_END_OF_FILE.
1547
+ */
1548
+
1549
+ /* Reset buffer status. */
1550
+ langscan_sh_lex_restart(yyin ,yyscanner);
1551
+
1552
+ /*FALLTHROUGH*/
1553
+
1554
+ case EOB_ACT_END_OF_FILE:
1555
+ {
1556
+ if ( langscan_sh_lex_wrap(yyscanner ) )
1557
+ return 0;
1558
+
1559
+ if ( ! yyg->yy_did_buffer_switch_on_eof )
1560
+ YY_NEW_FILE;
1561
+ #ifdef __cplusplus
1562
+ return yyinput(yyscanner);
1563
+ #else
1564
+ return input(yyscanner);
1565
+ #endif
1566
+ }
1567
+
1568
+ case EOB_ACT_CONTINUE_SCAN:
1569
+ yyg->yy_c_buf_p = yyg->yytext_ptr + offset;
1570
+ break;
1571
+ }
1572
+ }
1573
+ }
1574
+
1575
+ c = *(unsigned char *) yyg->yy_c_buf_p; /* cast for 8-bit char's */
1576
+ *yyg->yy_c_buf_p = '\0'; /* preserve yytext */
1577
+ yyg->yy_hold_char = *++yyg->yy_c_buf_p;
1578
+
1579
+ YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
1580
+
1581
+ return c;
1582
+ }
1583
+ #endif /* ifndef YY_NO_INPUT */
1584
+
1585
+ /** Immediately switch to a different input stream.
1586
+ * @param input_file A readable stream.
1587
+ * @param yyscanner The scanner object.
1588
+ * @note This function does not reset the start condition to @c INITIAL .
1589
+ */
1590
+ void langscan_sh_lex_restart (FILE * input_file , yyscan_t yyscanner)
1591
+ {
1592
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1593
+
1594
+ if ( ! YY_CURRENT_BUFFER ){
1595
+ langscan_sh_lex_ensure_buffer_stack (yyscanner);
1596
+ YY_CURRENT_BUFFER_LVALUE =
1597
+ langscan_sh_lex__create_buffer(yyin,YY_BUF_SIZE ,yyscanner);
1598
+ }
1599
+
1600
+ langscan_sh_lex__init_buffer(YY_CURRENT_BUFFER,input_file ,yyscanner);
1601
+ langscan_sh_lex__load_buffer_state(yyscanner );
1602
+ }
1603
+
1604
+ /** Switch to a different input buffer.
1605
+ * @param new_buffer The new input buffer.
1606
+ * @param yyscanner The scanner object.
1607
+ */
1608
+ void langscan_sh_lex__switch_to_buffer (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1609
+ {
1610
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1611
+
1612
+ /* TODO. We should be able to replace this entire function body
1613
+ * with
1614
+ * langscan_sh_lex_pop_buffer_state();
1615
+ * langscan_sh_lex_push_buffer_state(new_buffer);
1616
+ */
1617
+ langscan_sh_lex_ensure_buffer_stack (yyscanner);
1618
+ if ( YY_CURRENT_BUFFER == new_buffer )
1619
+ return;
1620
+
1621
+ if ( YY_CURRENT_BUFFER )
1622
+ {
1623
+ /* Flush out information for old buffer. */
1624
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1625
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1626
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1627
+ }
1628
+
1629
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
1630
+ langscan_sh_lex__load_buffer_state(yyscanner );
1631
+
1632
+ /* We don't actually know whether we did this switch during
1633
+ * EOF (langscan_sh_lex_wrap()) processing, but the only time this flag
1634
+ * is looked at is after langscan_sh_lex_wrap() is called, so it's safe
1635
+ * to go ahead and always set it.
1636
+ */
1637
+ yyg->yy_did_buffer_switch_on_eof = 1;
1638
+ }
1639
+
1640
+ static void langscan_sh_lex__load_buffer_state (yyscan_t yyscanner)
1641
+ {
1642
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1643
+ yyg->yy_n_chars = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
1644
+ yyg->yytext_ptr = yyg->yy_c_buf_p = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
1645
+ yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
1646
+ yyg->yy_hold_char = *yyg->yy_c_buf_p;
1647
+ }
1648
+
1649
+ /** Allocate and initialize an input buffer state.
1650
+ * @param file A readable stream.
1651
+ * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
1652
+ * @param yyscanner The scanner object.
1653
+ * @return the allocated buffer state.
1654
+ */
1655
+ YY_BUFFER_STATE langscan_sh_lex__create_buffer (FILE * file, int size , yyscan_t yyscanner)
1656
+ {
1657
+ YY_BUFFER_STATE b;
1658
+
1659
+ b = (YY_BUFFER_STATE) langscan_sh_lex_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1660
+ if ( ! b )
1661
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_sh_lex__create_buffer()" );
1662
+
1663
+ b->yy_buf_size = size;
1664
+
1665
+ /* yy_ch_buf has to be 2 characters longer than the size given because
1666
+ * we need to put in 2 end-of-buffer characters.
1667
+ */
1668
+ b->yy_ch_buf = (char *) langscan_sh_lex_alloc(b->yy_buf_size + 2 ,yyscanner );
1669
+ if ( ! b->yy_ch_buf )
1670
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_sh_lex__create_buffer()" );
1671
+
1672
+ b->yy_is_our_buffer = 1;
1673
+
1674
+ langscan_sh_lex__init_buffer(b,file ,yyscanner);
1675
+
1676
+ return b;
1677
+ }
1678
+
1679
+ /** Destroy the buffer.
1680
+ * @param b a buffer created with langscan_sh_lex__create_buffer()
1681
+ * @param yyscanner The scanner object.
1682
+ */
1683
+ void langscan_sh_lex__delete_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1684
+ {
1685
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1686
+
1687
+ if ( ! b )
1688
+ return;
1689
+
1690
+ if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
1691
+ YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
1692
+
1693
+ if ( b->yy_is_our_buffer )
1694
+ langscan_sh_lex_free((void *) b->yy_ch_buf ,yyscanner );
1695
+
1696
+ langscan_sh_lex_free((void *) b ,yyscanner );
1697
+ }
1698
+
1699
+ #ifndef __cplusplus
1700
+ extern int isatty (int );
1701
+ #endif /* __cplusplus */
1702
+
1703
+ /* Initializes or reinitializes a buffer.
1704
+ * This function is sometimes called more than once on the same buffer,
1705
+ * such as during a langscan_sh_lex_restart() or at EOF.
1706
+ */
1707
+ static void langscan_sh_lex__init_buffer (YY_BUFFER_STATE b, FILE * file , yyscan_t yyscanner)
1708
+
1709
+ {
1710
+ int oerrno = errno;
1711
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1712
+
1713
+ langscan_sh_lex__flush_buffer(b ,yyscanner);
1714
+
1715
+ b->yy_input_file = file;
1716
+ b->yy_fill_buffer = 1;
1717
+
1718
+ /* If b is the current buffer, then langscan_sh_lex__init_buffer was _probably_
1719
+ * called from langscan_sh_lex_restart() or through yy_get_next_buffer.
1720
+ * In that case, we don't want to reset the lineno or column.
1721
+ */
1722
+ if (b != YY_CURRENT_BUFFER){
1723
+ b->yy_bs_lineno = 1;
1724
+ b->yy_bs_column = 0;
1725
+ }
1726
+
1727
+ b->yy_is_interactive = file ? (isatty( fileno(file) ) > 0) : 0;
1728
+
1729
+ errno = oerrno;
1730
+ }
1731
+
1732
+ /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
1733
+ * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
1734
+ * @param yyscanner The scanner object.
1735
+ */
1736
+ void langscan_sh_lex__flush_buffer (YY_BUFFER_STATE b , yyscan_t yyscanner)
1737
+ {
1738
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1739
+ if ( ! b )
1740
+ return;
1741
+
1742
+ b->yy_n_chars = 0;
1743
+
1744
+ /* We always need two end-of-buffer characters. The first causes
1745
+ * a transition to the end-of-buffer state. The second causes
1746
+ * a jam in that state.
1747
+ */
1748
+ b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
1749
+ b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
1750
+
1751
+ b->yy_buf_pos = &b->yy_ch_buf[0];
1752
+
1753
+ b->yy_at_bol = 1;
1754
+ b->yy_buffer_status = YY_BUFFER_NEW;
1755
+
1756
+ if ( b == YY_CURRENT_BUFFER )
1757
+ langscan_sh_lex__load_buffer_state(yyscanner );
1758
+ }
1759
+
1760
+ /** Pushes the new state onto the stack. The new state becomes
1761
+ * the current state. This function will allocate the stack
1762
+ * if necessary.
1763
+ * @param new_buffer The new state.
1764
+ * @param yyscanner The scanner object.
1765
+ */
1766
+ void langscan_sh_lex_push_buffer_state (YY_BUFFER_STATE new_buffer , yyscan_t yyscanner)
1767
+ {
1768
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1769
+ if (new_buffer == NULL)
1770
+ return;
1771
+
1772
+ langscan_sh_lex_ensure_buffer_stack(yyscanner);
1773
+
1774
+ /* This block is copied from langscan_sh_lex__switch_to_buffer. */
1775
+ if ( YY_CURRENT_BUFFER )
1776
+ {
1777
+ /* Flush out information for old buffer. */
1778
+ *yyg->yy_c_buf_p = yyg->yy_hold_char;
1779
+ YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = yyg->yy_c_buf_p;
1780
+ YY_CURRENT_BUFFER_LVALUE->yy_n_chars = yyg->yy_n_chars;
1781
+ }
1782
+
1783
+ /* Only push if top exists. Otherwise, replace top. */
1784
+ if (YY_CURRENT_BUFFER)
1785
+ yyg->yy_buffer_stack_top++;
1786
+ YY_CURRENT_BUFFER_LVALUE = new_buffer;
1787
+
1788
+ /* copied from langscan_sh_lex__switch_to_buffer. */
1789
+ langscan_sh_lex__load_buffer_state(yyscanner );
1790
+ yyg->yy_did_buffer_switch_on_eof = 1;
1791
+ }
1792
+
1793
+ /** Removes and deletes the top of the stack, if present.
1794
+ * The next element becomes the new top.
1795
+ * @param yyscanner The scanner object.
1796
+ */
1797
+ void langscan_sh_lex_pop_buffer_state (yyscan_t yyscanner)
1798
+ {
1799
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1800
+ if (!YY_CURRENT_BUFFER)
1801
+ return;
1802
+
1803
+ langscan_sh_lex__delete_buffer(YY_CURRENT_BUFFER ,yyscanner);
1804
+ YY_CURRENT_BUFFER_LVALUE = NULL;
1805
+ if (yyg->yy_buffer_stack_top > 0)
1806
+ --yyg->yy_buffer_stack_top;
1807
+
1808
+ if (YY_CURRENT_BUFFER) {
1809
+ langscan_sh_lex__load_buffer_state(yyscanner );
1810
+ yyg->yy_did_buffer_switch_on_eof = 1;
1811
+ }
1812
+ }
1813
+
1814
+ /* Allocates the stack if it does not exist.
1815
+ * Guarantees space for at least one push.
1816
+ */
1817
+ static void langscan_sh_lex_ensure_buffer_stack (yyscan_t yyscanner)
1818
+ {
1819
+ yy_size_t num_to_alloc;
1820
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1821
+
1822
+ if (!yyg->yy_buffer_stack) {
1823
+
1824
+ /* First allocation is just for 2 elements, since we don't know if this
1825
+ * scanner will even need a stack. We use 2 instead of 1 to avoid an
1826
+ * immediate realloc on the next call.
1827
+ */
1828
+ num_to_alloc = 1;
1829
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)langscan_sh_lex_alloc
1830
+ (num_to_alloc * sizeof(struct yy_buffer_state*)
1831
+ , yyscanner);
1832
+ if ( ! yyg->yy_buffer_stack )
1833
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_sh_lex_ensure_buffer_stack()" );
1834
+
1835
+ memset(yyg->yy_buffer_stack, 0, num_to_alloc * sizeof(struct yy_buffer_state*));
1836
+
1837
+ yyg->yy_buffer_stack_max = num_to_alloc;
1838
+ yyg->yy_buffer_stack_top = 0;
1839
+ return;
1840
+ }
1841
+
1842
+ if (yyg->yy_buffer_stack_top >= (yyg->yy_buffer_stack_max) - 1){
1843
+
1844
+ /* Increase the buffer to prepare for a possible push. */
1845
+ int grow_size = 8 /* arbitrary grow size */;
1846
+
1847
+ num_to_alloc = yyg->yy_buffer_stack_max + grow_size;
1848
+ yyg->yy_buffer_stack = (struct yy_buffer_state**)langscan_sh_lex_realloc
1849
+ (yyg->yy_buffer_stack,
1850
+ num_to_alloc * sizeof(struct yy_buffer_state*)
1851
+ , yyscanner);
1852
+ if ( ! yyg->yy_buffer_stack )
1853
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_sh_lex_ensure_buffer_stack()" );
1854
+
1855
+ /* zero only the new slots.*/
1856
+ memset(yyg->yy_buffer_stack + yyg->yy_buffer_stack_max, 0, grow_size * sizeof(struct yy_buffer_state*));
1857
+ yyg->yy_buffer_stack_max = num_to_alloc;
1858
+ }
1859
+ }
1860
+
1861
+ /** Setup the input buffer state to scan directly from a user-specified character buffer.
1862
+ * @param base the character buffer
1863
+ * @param size the size in bytes of the character buffer
1864
+ * @param yyscanner The scanner object.
1865
+ * @return the newly allocated buffer state object.
1866
+ */
1867
+ YY_BUFFER_STATE langscan_sh_lex__scan_buffer (char * base, yy_size_t size , yyscan_t yyscanner)
1868
+ {
1869
+ YY_BUFFER_STATE b;
1870
+
1871
+ if ( size < 2 ||
1872
+ base[size-2] != YY_END_OF_BUFFER_CHAR ||
1873
+ base[size-1] != YY_END_OF_BUFFER_CHAR )
1874
+ /* They forgot to leave room for the EOB's. */
1875
+ return 0;
1876
+
1877
+ b = (YY_BUFFER_STATE) langscan_sh_lex_alloc(sizeof( struct yy_buffer_state ) ,yyscanner );
1878
+ if ( ! b )
1879
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_sh_lex__scan_buffer()" );
1880
+
1881
+ b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
1882
+ b->yy_buf_pos = b->yy_ch_buf = base;
1883
+ b->yy_is_our_buffer = 0;
1884
+ b->yy_input_file = 0;
1885
+ b->yy_n_chars = b->yy_buf_size;
1886
+ b->yy_is_interactive = 0;
1887
+ b->yy_at_bol = 1;
1888
+ b->yy_fill_buffer = 0;
1889
+ b->yy_buffer_status = YY_BUFFER_NEW;
1890
+
1891
+ langscan_sh_lex__switch_to_buffer(b ,yyscanner );
1892
+
1893
+ return b;
1894
+ }
1895
+
1896
+ /** Setup the input buffer state to scan a string. The next call to langscan_sh_lex_lex() will
1897
+ * scan from a @e copy of @a str.
1898
+ * @param yystr a NUL-terminated string to scan
1899
+ * @param yyscanner The scanner object.
1900
+ * @return the newly allocated buffer state object.
1901
+ * @note If you want to scan bytes that may contain NUL values, then use
1902
+ * langscan_sh_lex__scan_bytes() instead.
1903
+ */
1904
+ YY_BUFFER_STATE langscan_sh_lex__scan_string (yyconst char * yystr , yyscan_t yyscanner)
1905
+ {
1906
+
1907
+ return langscan_sh_lex__scan_bytes(yystr,strlen(yystr) ,yyscanner);
1908
+ }
1909
+
1910
+ /** Setup the input buffer state to scan the given bytes. The next call to langscan_sh_lex_lex() will
1911
+ * scan from a @e copy of @a bytes.
1912
+ * @param bytes the byte buffer to scan
1913
+ * @param len the number of bytes in the buffer pointed to by @a bytes.
1914
+ * @param yyscanner The scanner object.
1915
+ * @return the newly allocated buffer state object.
1916
+ */
1917
+ YY_BUFFER_STATE langscan_sh_lex__scan_bytes (yyconst char * yybytes, yy_size_t _yybytes_len , yyscan_t yyscanner)
1918
+ {
1919
+ YY_BUFFER_STATE b;
1920
+ char *buf;
1921
+ yy_size_t n, i;
1922
+
1923
+ /* Get memory for full buffer, including space for trailing EOB's. */
1924
+ n = _yybytes_len + 2;
1925
+ buf = (char *) langscan_sh_lex_alloc(n ,yyscanner );
1926
+ if ( ! buf )
1927
+ YY_FATAL_ERROR( "out of dynamic memory in langscan_sh_lex__scan_bytes()" );
1928
+
1929
+ for ( i = 0; i < _yybytes_len; ++i )
1930
+ buf[i] = yybytes[i];
1931
+
1932
+ buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
1933
+
1934
+ b = langscan_sh_lex__scan_buffer(buf,n ,yyscanner);
1935
+ if ( ! b )
1936
+ YY_FATAL_ERROR( "bad buffer in langscan_sh_lex__scan_bytes()" );
1937
+
1938
+ /* It's okay to grow etc. this buffer, and we should throw it
1939
+ * away when we're done.
1940
+ */
1941
+ b->yy_is_our_buffer = 1;
1942
+
1943
+ return b;
1944
+ }
1945
+
1946
+ static void yy_push_state (int new_state , yyscan_t yyscanner)
1947
+ {
1948
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1949
+ if ( yyg->yy_start_stack_ptr >= yyg->yy_start_stack_depth )
1950
+ {
1951
+ yy_size_t new_size;
1952
+
1953
+ yyg->yy_start_stack_depth += YY_START_STACK_INCR;
1954
+ new_size = yyg->yy_start_stack_depth * sizeof( int );
1955
+
1956
+ if ( ! yyg->yy_start_stack )
1957
+ yyg->yy_start_stack = (int *) langscan_sh_lex_alloc(new_size ,yyscanner );
1958
+
1959
+ else
1960
+ yyg->yy_start_stack = (int *) langscan_sh_lex_realloc((void *) yyg->yy_start_stack,new_size ,yyscanner );
1961
+
1962
+ if ( ! yyg->yy_start_stack )
1963
+ YY_FATAL_ERROR( "out of memory expanding start-condition stack" );
1964
+ }
1965
+
1966
+ yyg->yy_start_stack[yyg->yy_start_stack_ptr++] = YY_START;
1967
+
1968
+ BEGIN(new_state);
1969
+ }
1970
+
1971
+ static void yy_pop_state (yyscan_t yyscanner)
1972
+ {
1973
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1974
+ if ( --yyg->yy_start_stack_ptr < 0 )
1975
+ YY_FATAL_ERROR( "start-condition stack underflow" );
1976
+
1977
+ BEGIN(yyg->yy_start_stack[yyg->yy_start_stack_ptr]);
1978
+ }
1979
+
1980
+ static int yy_top_state (yyscan_t yyscanner)
1981
+ {
1982
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
1983
+ return yyg->yy_start_stack[yyg->yy_start_stack_ptr - 1];
1984
+ }
1985
+
1986
+ #ifndef YY_EXIT_FAILURE
1987
+ #define YY_EXIT_FAILURE 2
1988
+ #endif
1989
+
1990
+ static void yy_fatal_error (yyconst char* msg , yyscan_t yyscanner)
1991
+ {
1992
+ (void) fprintf( stderr, "%s\n", msg );
1993
+ exit( YY_EXIT_FAILURE );
1994
+ }
1995
+
1996
+ /* Redefine yyless() so it works in section 3 code. */
1997
+
1998
+ #undef yyless
1999
+ #define yyless(n) \
2000
+ do \
2001
+ { \
2002
+ /* Undo effects of setting up yytext. */ \
2003
+ int yyless_macro_arg = (n); \
2004
+ YY_LESS_LINENO(yyless_macro_arg);\
2005
+ yytext[yyleng] = yyg->yy_hold_char; \
2006
+ yyg->yy_c_buf_p = yytext + yyless_macro_arg; \
2007
+ yyg->yy_hold_char = *yyg->yy_c_buf_p; \
2008
+ *yyg->yy_c_buf_p = '\0'; \
2009
+ yyleng = yyless_macro_arg; \
2010
+ } \
2011
+ while ( 0 )
2012
+
2013
+ /* Accessor methods (get/set functions) to struct members. */
2014
+
2015
+ /** Get the user-defined data for this scanner.
2016
+ * @param yyscanner The scanner object.
2017
+ */
2018
+ YY_EXTRA_TYPE langscan_sh_lex_get_extra (yyscan_t yyscanner)
2019
+ {
2020
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2021
+ return yyextra;
2022
+ }
2023
+
2024
+ /** Get the current line number.
2025
+ * @param yyscanner The scanner object.
2026
+ */
2027
+ int langscan_sh_lex_get_lineno (yyscan_t yyscanner)
2028
+ {
2029
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2030
+
2031
+ if (! YY_CURRENT_BUFFER)
2032
+ return 0;
2033
+
2034
+ return yylineno;
2035
+ }
2036
+
2037
+ /** Get the current column number.
2038
+ * @param yyscanner The scanner object.
2039
+ */
2040
+ int langscan_sh_lex_get_column (yyscan_t yyscanner)
2041
+ {
2042
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2043
+
2044
+ if (! YY_CURRENT_BUFFER)
2045
+ return 0;
2046
+
2047
+ return yycolumn;
2048
+ }
2049
+
2050
+ /** Get the input stream.
2051
+ * @param yyscanner The scanner object.
2052
+ */
2053
+ FILE *langscan_sh_lex_get_in (yyscan_t yyscanner)
2054
+ {
2055
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2056
+ return yyin;
2057
+ }
2058
+
2059
+ /** Get the output stream.
2060
+ * @param yyscanner The scanner object.
2061
+ */
2062
+ FILE *langscan_sh_lex_get_out (yyscan_t yyscanner)
2063
+ {
2064
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2065
+ return yyout;
2066
+ }
2067
+
2068
+ /** Get the length of the current token.
2069
+ * @param yyscanner The scanner object.
2070
+ */
2071
+ yy_size_t langscan_sh_lex_get_leng (yyscan_t yyscanner)
2072
+ {
2073
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2074
+ return yyleng;
2075
+ }
2076
+
2077
+ /** Get the current token.
2078
+ * @param yyscanner The scanner object.
2079
+ */
2080
+
2081
+ char *langscan_sh_lex_get_text (yyscan_t yyscanner)
2082
+ {
2083
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2084
+ return yytext;
2085
+ }
2086
+
2087
+ /** Set the user-defined data. This data is never touched by the scanner.
2088
+ * @param user_defined The data to be associated with this scanner.
2089
+ * @param yyscanner The scanner object.
2090
+ */
2091
+ void langscan_sh_lex_set_extra (YY_EXTRA_TYPE user_defined , yyscan_t yyscanner)
2092
+ {
2093
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2094
+ yyextra = user_defined ;
2095
+ }
2096
+
2097
+ /** Set the current line number.
2098
+ * @param line_number
2099
+ * @param yyscanner The scanner object.
2100
+ */
2101
+ void langscan_sh_lex_set_lineno (int line_number , yyscan_t yyscanner)
2102
+ {
2103
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2104
+
2105
+ /* lineno is only valid if an input buffer exists. */
2106
+ if (! YY_CURRENT_BUFFER )
2107
+ yy_fatal_error( "langscan_sh_lex_set_lineno called with no buffer" , yyscanner);
2108
+
2109
+ yylineno = line_number;
2110
+ }
2111
+
2112
+ /** Set the current column.
2113
+ * @param line_number
2114
+ * @param yyscanner The scanner object.
2115
+ */
2116
+ void langscan_sh_lex_set_column (int column_no , yyscan_t yyscanner)
2117
+ {
2118
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2119
+
2120
+ /* column is only valid if an input buffer exists. */
2121
+ if (! YY_CURRENT_BUFFER )
2122
+ yy_fatal_error( "langscan_sh_lex_set_column called with no buffer" , yyscanner);
2123
+
2124
+ yycolumn = column_no;
2125
+ }
2126
+
2127
+ /** Set the input stream. This does not discard the current
2128
+ * input buffer.
2129
+ * @param in_str A readable stream.
2130
+ * @param yyscanner The scanner object.
2131
+ * @see langscan_sh_lex__switch_to_buffer
2132
+ */
2133
+ void langscan_sh_lex_set_in (FILE * in_str , yyscan_t yyscanner)
2134
+ {
2135
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2136
+ yyin = in_str ;
2137
+ }
2138
+
2139
+ void langscan_sh_lex_set_out (FILE * out_str , yyscan_t yyscanner)
2140
+ {
2141
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2142
+ yyout = out_str ;
2143
+ }
2144
+
2145
+ int langscan_sh_lex_get_debug (yyscan_t yyscanner)
2146
+ {
2147
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2148
+ return yy_flex_debug;
2149
+ }
2150
+
2151
+ void langscan_sh_lex_set_debug (int bdebug , yyscan_t yyscanner)
2152
+ {
2153
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2154
+ yy_flex_debug = bdebug ;
2155
+ }
2156
+
2157
+ /* Accessor methods for yylval and yylloc */
2158
+
2159
+ /* User-visible API */
2160
+
2161
+ /* langscan_sh_lex_lex_init is special because it creates the scanner itself, so it is
2162
+ * the ONLY reentrant function that doesn't take the scanner as the last argument.
2163
+ * That's why we explicitly handle the declaration, instead of using our macros.
2164
+ */
2165
+
2166
+ int langscan_sh_lex_lex_init(yyscan_t* ptr_yy_globals)
2167
+
2168
+ {
2169
+ if (ptr_yy_globals == NULL){
2170
+ errno = EINVAL;
2171
+ return 1;
2172
+ }
2173
+
2174
+ *ptr_yy_globals = (yyscan_t) langscan_sh_lex_alloc ( sizeof( struct yyguts_t ), NULL );
2175
+
2176
+ if (*ptr_yy_globals == NULL){
2177
+ errno = ENOMEM;
2178
+ return 1;
2179
+ }
2180
+
2181
+ /* By setting to 0xAA, we expose bugs in yy_init_globals. Leave at 0x00 for releases. */
2182
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2183
+
2184
+ return yy_init_globals ( *ptr_yy_globals );
2185
+ }
2186
+
2187
+ /* langscan_sh_lex_lex_init_extra has the same functionality as langscan_sh_lex_lex_init, but follows the
2188
+ * convention of taking the scanner as the last argument. Note however, that
2189
+ * this is a *pointer* to a scanner, as it will be allocated by this call (and
2190
+ * is the reason, too, why this function also must handle its own declaration).
2191
+ * The user defined value in the first argument will be available to langscan_sh_lex_alloc in
2192
+ * the yyextra field.
2193
+ */
2194
+
2195
+ int langscan_sh_lex_lex_init_extra(YY_EXTRA_TYPE yy_user_defined,yyscan_t* ptr_yy_globals )
2196
+
2197
+ {
2198
+ struct yyguts_t dummy_yyguts;
2199
+
2200
+ langscan_sh_lex_set_extra (yy_user_defined, &dummy_yyguts);
2201
+
2202
+ if (ptr_yy_globals == NULL){
2203
+ errno = EINVAL;
2204
+ return 1;
2205
+ }
2206
+
2207
+ *ptr_yy_globals = (yyscan_t) langscan_sh_lex_alloc ( sizeof( struct yyguts_t ), &dummy_yyguts );
2208
+
2209
+ if (*ptr_yy_globals == NULL){
2210
+ errno = ENOMEM;
2211
+ return 1;
2212
+ }
2213
+
2214
+ /* By setting to 0xAA, we expose bugs in
2215
+ yy_init_globals. Leave at 0x00 for releases. */
2216
+ memset(*ptr_yy_globals,0x00,sizeof(struct yyguts_t));
2217
+
2218
+ langscan_sh_lex_set_extra (yy_user_defined, *ptr_yy_globals);
2219
+
2220
+ return yy_init_globals ( *ptr_yy_globals );
2221
+ }
2222
+
2223
+ static int yy_init_globals (yyscan_t yyscanner)
2224
+ {
2225
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2226
+ /* Initialization is the same as for the non-reentrant scanner.
2227
+ * This function is called from langscan_sh_lex_lex_destroy(), so don't allocate here.
2228
+ */
2229
+
2230
+ yyg->yy_buffer_stack = 0;
2231
+ yyg->yy_buffer_stack_top = 0;
2232
+ yyg->yy_buffer_stack_max = 0;
2233
+ yyg->yy_c_buf_p = (char *) 0;
2234
+ yyg->yy_init = 0;
2235
+ yyg->yy_start = 0;
2236
+
2237
+ yyg->yy_start_stack_ptr = 0;
2238
+ yyg->yy_start_stack_depth = 0;
2239
+ yyg->yy_start_stack = NULL;
2240
+
2241
+ /* Defined in main.c */
2242
+ #ifdef YY_STDINIT
2243
+ yyin = stdin;
2244
+ yyout = stdout;
2245
+ #else
2246
+ yyin = (FILE *) 0;
2247
+ yyout = (FILE *) 0;
2248
+ #endif
2249
+
2250
+ /* For future reference: Set errno on error, since we are called by
2251
+ * langscan_sh_lex_lex_init()
2252
+ */
2253
+ return 0;
2254
+ }
2255
+
2256
+ /* langscan_sh_lex_lex_destroy is for both reentrant and non-reentrant scanners. */
2257
+ int langscan_sh_lex_lex_destroy (yyscan_t yyscanner)
2258
+ {
2259
+ struct yyguts_t * yyg = (struct yyguts_t*)yyscanner;
2260
+
2261
+ /* Pop the buffer stack, destroying each element. */
2262
+ while(YY_CURRENT_BUFFER){
2263
+ langscan_sh_lex__delete_buffer(YY_CURRENT_BUFFER ,yyscanner );
2264
+ YY_CURRENT_BUFFER_LVALUE = NULL;
2265
+ langscan_sh_lex_pop_buffer_state(yyscanner);
2266
+ }
2267
+
2268
+ /* Destroy the stack itself. */
2269
+ langscan_sh_lex_free(yyg->yy_buffer_stack ,yyscanner);
2270
+ yyg->yy_buffer_stack = NULL;
2271
+
2272
+ /* Destroy the start condition stack. */
2273
+ langscan_sh_lex_free(yyg->yy_start_stack ,yyscanner );
2274
+ yyg->yy_start_stack = NULL;
2275
+
2276
+ /* Reset the globals. This is important in a non-reentrant scanner so the next time
2277
+ * langscan_sh_lex_lex() is called, initialization will occur. */
2278
+ yy_init_globals( yyscanner);
2279
+
2280
+ /* Destroy the main struct (reentrant only). */
2281
+ langscan_sh_lex_free ( yyscanner , yyscanner );
2282
+ yyscanner = NULL;
2283
+ return 0;
2284
+ }
2285
+
2286
+ /*
2287
+ * Internal utility routines.
2288
+ */
2289
+
2290
+ #ifndef yytext_ptr
2291
+ static void yy_flex_strncpy (char* s1, yyconst char * s2, int n , yyscan_t yyscanner)
2292
+ {
2293
+ register int i;
2294
+ for ( i = 0; i < n; ++i )
2295
+ s1[i] = s2[i];
2296
+ }
2297
+ #endif
2298
+
2299
+ #ifdef YY_NEED_STRLEN
2300
+ static int yy_flex_strlen (yyconst char * s , yyscan_t yyscanner)
2301
+ {
2302
+ register int n;
2303
+ for ( n = 0; s[n]; ++n )
2304
+ ;
2305
+
2306
+ return n;
2307
+ }
2308
+ #endif
2309
+
2310
+ void *langscan_sh_lex_alloc (yy_size_t size , yyscan_t yyscanner)
2311
+ {
2312
+ return (void *) malloc( size );
2313
+ }
2314
+
2315
+ void *langscan_sh_lex_realloc (void * ptr, yy_size_t size , yyscan_t yyscanner)
2316
+ {
2317
+ /* The cast to (char *) in the following accommodates both
2318
+ * implementations that use char* generic pointers, and those
2319
+ * that use void* generic pointers. It works with the latter
2320
+ * because both ANSI C and C++ allow castless assignment from
2321
+ * any pointer type to void*, and deal with argument conversions
2322
+ * as though doing an assignment.
2323
+ */
2324
+ return (void *) realloc( (char *) ptr, size );
2325
+ }
2326
+
2327
+ void langscan_sh_lex_free (void * ptr , yyscan_t yyscanner)
2328
+ {
2329
+ free( (char *) ptr ); /* see langscan_sh_lex_realloc() for (char *) cast */
2330
+ }
2331
+
2332
+ #define YYTABLES_NAME "yytables"
2333
+
2334
+ static void update_pos(
2335
+ langscan_sh_lex_extra_t *extra,
2336
+ char *text,
2337
+ int leng)
2338
+ {
2339
+ int i, j;
2340
+ extra->beg_byteno = extra->end_byteno;
2341
+ extra->beg_lineno = extra->end_lineno;
2342
+ extra->beg_columnno = extra->end_columnno;
2343
+ j = 0;
2344
+ for (i = 0; i < leng; i++) {
2345
+ if (text[i] == '\n') {
2346
+ extra->end_lineno++;
2347
+ j = i + 1;
2348
+ extra->end_columnno = 0;
2349
+ }
2350
+ }
2351
+ extra->end_columnno += leng - j;
2352
+ extra->end_byteno += leng;
2353
+ }
2354
+
2355
+ static int ident_length(unsigned char *ptr, int max)
2356
+ {
2357
+ int len = 0;
2358
+ while (0 < max &&
2359
+ (('0' <= *ptr && *ptr <= '9') ||
2360
+ ('A' <= *ptr && *ptr <= 'Z') ||
2361
+ ('a' <= *ptr && *ptr <= 'z') ||
2362
+ *ptr == '_' || *ptr == '-' || *ptr == '.')) {
2363
+ ptr++;
2364
+ len++;
2365
+ max--;
2366
+ }
2367
+ return len;
2368
+ }
2369
+
2370
+ static int set_heredoc_delimiter(unsigned char *ptr, int max)
2371
+ {
2372
+ char *dst, quote_char;
2373
+ int in_quote, len;
2374
+ heredoc_delimiter = malloc(max + 1);
2375
+ if (heredoc_delimiter == NULL) return -1;
2376
+ dst = heredoc_delimiter;
2377
+ len = 0;
2378
+ in_quote = 0;
2379
+ while (len < max) {
2380
+ if (in_quote == 0) { /* unquoted delimiter */
2381
+ if (*ptr == '\'' || *ptr == '\"') {
2382
+ quote_char = *ptr;
2383
+ in_quote = 1;
2384
+ ptr++;
2385
+ if (++len >= max) break;
2386
+ continue;
2387
+ }
2388
+ if (*ptr == ' ' || *ptr == '\t') break;
2389
+ if (*ptr == '\\') {
2390
+ ptr++;
2391
+ if (++len >= max) break;
2392
+ }
2393
+ }
2394
+ else { /* quoted delimiter */
2395
+ if (*ptr == quote_char) {
2396
+ in_quote = 0;
2397
+ ptr++;
2398
+ if (len++ >= max) break;
2399
+ continue;
2400
+ }
2401
+ }
2402
+ *dst++ = *ptr++;
2403
+ len++;
2404
+ }
2405
+ *dst = '\0';
2406
+ return len;
2407
+ }
2408
+
2409
+ langscan_sh_tokenizer_t *langscan_sh_make_tokenizer(
2410
+ size_t (*user_read)(void **user_data_p, char *buf, size_t maxlen),
2411
+ void *user_data)
2412
+ {
2413
+ langscan_sh_tokenizer_t *tokenizer;
2414
+ langscan_sh_lex_extra_t *extra;
2415
+ tokenizer = (langscan_sh_tokenizer_t *)malloc(sizeof(langscan_sh_tokenizer_t));
2416
+ if (tokenizer == NULL)
2417
+ return NULL;
2418
+ extra = (langscan_sh_lex_extra_t *)malloc(sizeof(langscan_sh_lex_extra_t));
2419
+ if (extra == NULL)
2420
+ return NULL;
2421
+ extra->user_read = user_read;
2422
+ extra->user_data = user_data;
2423
+ extra->beg_lineno = 1;
2424
+ extra->beg_columnno = 0;
2425
+ extra->beg_byteno = 0;
2426
+ extra->end_lineno = 1;
2427
+ extra->end_columnno = 0;
2428
+ extra->end_byteno = 0;
2429
+ extra->eof = 0;
2430
+ tokenizer->extra = extra;
2431
+ langscan_sh_lex_lex_init(&tokenizer->scanner);
2432
+ langscan_sh_lex_set_extra(extra, tokenizer->scanner);
2433
+ return tokenizer;
2434
+ }
2435
+
2436
+ langscan_sh_token_t langscan_sh_get_token(langscan_sh_tokenizer_t *tokenizer)
2437
+ {
2438
+ return langscan_sh_lex_lex(tokenizer->scanner);
2439
+ }
2440
+
2441
+ void langscan_sh_free_tokenizer(langscan_sh_tokenizer_t *tokenizer)
2442
+ {
2443
+ langscan_sh_lex_extra_t *extra = langscan_sh_lex_get_extra(tokenizer->scanner);
2444
+ free((void *)extra);
2445
+ langscan_sh_lex_lex_destroy(tokenizer->scanner);
2446
+ free((void *)tokenizer);
2447
+ }
2448
+
2449
+ user_read_t langscan_sh_tokenizer_get_user_read(langscan_sh_tokenizer_t *tokenizer)
2450
+ {
2451
+ return tokenizer->extra->user_read;
2452
+ }
2453
+
2454
+ void *langscan_sh_tokenizer_get_user_data(langscan_sh_tokenizer_t *tokenizer)
2455
+ {
2456
+ return tokenizer->extra->user_data;
2457
+ }
2458
+
2459
+ const char *langscan_sh_token_name(langscan_sh_token_t token)
2460
+ {
2461
+ static char *token_names[] = {
2462
+ "*eof*",
2463
+ #define LANGSCAN_SH_TOKEN(name) #name,
2464
+ LANGSCAN_SH_TOKEN_LIST
2465
+ #undef LANGSCAN_SH_TOKEN
2466
+ };
2467
+
2468
+ return token_names[token];
2469
+ }
2470
+