ast_expr2f.c 69 KB

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