ast_expr2f.c 70 KB

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