langscan 1.2-x86-mswin32-60

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