dtc-lexer.lex.c_shipped 59 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173117411751176117711781179118011811182118311841185118611871188118911901191119211931194119511961197119811991200120112021203120412051206120712081209121012111212121312141215121612171218121912201221122212231224122512261227122812291230123112321233123412351236123712381239124012411242124312441245124612471248124912501251125212531254125512561257125812591260126112621263126412651266126712681269127012711272127312741275127612771278127912801281128212831284128512861287128812891290129112921293129412951296129712981299130013011302130313041305130613071308130913101311131213131314131513161317131813191320132113221323132413251326132713281329133013311332133313341335133613371338133913401341134213431344134513461347134813491350135113521353135413551356135713581359136013611362136313641365136613671368136913701371137213731374137513761377137813791380138113821383138413851386138713881389139013911392139313941395139613971398139914001401140214031404140514061407140814091410141114121413141414151416141714181419142014211422142314241425142614271428142914301431143214331434143514361437143814391440144114421443144414451446144714481449145014511452145314541455145614571458145914601461146214631464146514661467146814691470147114721473147414751476147714781479148014811482148314841485148614871488148914901491149214931494149514961497149814991500150115021503150415051506150715081509151015111512151315141515151615171518151915201521152215231524152515261527152815291530153115321533153415351536153715381539154015411542154315441545154615471548154915501551155215531554155515561557155815591560156115621563156415651566156715681569157015711572157315741575157615771578157915801581158215831584158515861587158815891590159115921593159415951596159715981599160016011602160316041605160616071608160916101611161216131614161516161617161816191620162116221623162416251626162716281629163016311632163316341635163616371638163916401641164216431644164516461647164816491650165116521653165416551656165716581659166016611662166316641665166616671668166916701671167216731674167516761677167816791680168116821683168416851686168716881689169016911692169316941695169616971698169917001701170217031704170517061707170817091710171117121713171417151716171717181719172017211722172317241725172617271728172917301731173217331734173517361737173817391740174117421743174417451746174717481749175017511752175317541755175617571758175917601761176217631764176517661767176817691770177117721773177417751776177717781779178017811782178317841785178617871788178917901791179217931794179517961797179817991800180118021803180418051806180718081809181018111812181318141815181618171818181918201821182218231824182518261827182818291830183118321833183418351836183718381839184018411842184318441845184618471848184918501851185218531854185518561857185818591860186118621863186418651866186718681869187018711872187318741875187618771878187918801881188218831884188518861887188818891890189118921893189418951896189718981899190019011902190319041905190619071908190919101911191219131914191519161917191819191920192119221923192419251926192719281929193019311932193319341935193619371938193919401941194219431944194519461947194819491950195119521953195419551956195719581959196019611962196319641965196619671968196919701971197219731974197519761977197819791980198119821983198419851986198719881989199019911992199319941995199619971998199920002001200220032004200520062007200820092010201120122013201420152016201720182019202020212022202320242025202620272028202920302031203220332034203520362037203820392040204120422043204420452046204720482049205020512052205320542055205620572058205920602061206220632064206520662067206820692070207120722073207420752076207720782079208020812082208320842085208620872088208920902091209220932094209520962097209820992100210121022103210421052106210721082109211021112112211321142115211621172118211921202121212221232124212521262127212821292130213121322133213421352136213721382139214021412142214321442145214621472148214921502151215221532154215521562157215821592160216121622163216421652166216721682169217021712172217321742175217621772178217921802181218221832184218521862187218821892190219121922193219421952196219721982199220022012202220322042205220622072208220922102211221222132214221522162217221822192220222122222223222422252226222722282229223022312232223322342235223622372238223922402241224222432244224522462247224822492250225122522253225422552256225722582259
  1. #line 2 "dtc-lexer.lex.c"
  2. #line 4 "dtc-lexer.lex.c"
  3. #define YY_INT_ALIGNED short int
  4. /* A lexical scanner generated by flex */
  5. #define FLEX_SCANNER
  6. #define YY_FLEX_MAJOR_VERSION 2
  7. #define YY_FLEX_MINOR_VERSION 6
  8. #define YY_FLEX_SUBMINOR_VERSION 1
  9. #if YY_FLEX_SUBMINOR_VERSION > 0
  10. #define FLEX_BETA
  11. #endif
  12. /* First, we deal with platform-specific or compiler-specific issues. */
  13. /* begin standard C headers. */
  14. #include <stdio.h>
  15. #include <string.h>
  16. #include <errno.h>
  17. #include <stdlib.h>
  18. /* end standard C headers. */
  19. /* flex integer type definitions */
  20. #ifndef FLEXINT_H
  21. #define FLEXINT_H
  22. /* C99 systems have <inttypes.h>. Non-C99 systems may or may not. */
  23. #if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
  24. /* C99 says to define __STDC_LIMIT_MACROS before including stdint.h,
  25. * if you want the limit (max/min) macros for int types.
  26. */
  27. #ifndef __STDC_LIMIT_MACROS
  28. #define __STDC_LIMIT_MACROS 1
  29. #endif
  30. #include <inttypes.h>
  31. typedef int8_t flex_int8_t;
  32. typedef uint8_t flex_uint8_t;
  33. typedef int16_t flex_int16_t;
  34. typedef uint16_t flex_uint16_t;
  35. typedef int32_t flex_int32_t;
  36. typedef uint32_t flex_uint32_t;
  37. #else
  38. typedef signed char flex_int8_t;
  39. typedef short int flex_int16_t;
  40. typedef int flex_int32_t;
  41. typedef unsigned char flex_uint8_t;
  42. typedef unsigned short int flex_uint16_t;
  43. typedef unsigned int flex_uint32_t;
  44. /* Limits of integral types. */
  45. #ifndef INT8_MIN
  46. #define INT8_MIN (-128)
  47. #endif
  48. #ifndef INT16_MIN
  49. #define INT16_MIN (-32767-1)
  50. #endif
  51. #ifndef INT32_MIN
  52. #define INT32_MIN (-2147483647-1)
  53. #endif
  54. #ifndef INT8_MAX
  55. #define INT8_MAX (127)
  56. #endif
  57. #ifndef INT16_MAX
  58. #define INT16_MAX (32767)
  59. #endif
  60. #ifndef INT32_MAX
  61. #define INT32_MAX (2147483647)
  62. #endif
  63. #ifndef UINT8_MAX
  64. #define UINT8_MAX (255U)
  65. #endif
  66. #ifndef UINT16_MAX
  67. #define UINT16_MAX (65535U)
  68. #endif
  69. #ifndef UINT32_MAX
  70. #define UINT32_MAX (4294967295U)
  71. #endif
  72. #endif /* ! C99 */
  73. #endif /* ! FLEXINT_H */
  74. /* TODO: this is always defined, so inline it */
  75. #define yyconst const
  76. #if defined(__GNUC__) && __GNUC__ >= 3
  77. #define yynoreturn __attribute__((__noreturn__))
  78. #else
  79. #define yynoreturn
  80. #endif
  81. /* Returned upon end-of-file. */
  82. #define YY_NULL 0
  83. /* Promotes a possibly negative, possibly signed char to an unsigned
  84. * integer for use as an array index. If the signed char is negative,
  85. * we want to instead treat it as an 8-bit unsigned char, hence the
  86. * double cast.
  87. */
  88. #define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
  89. /* Enter a start condition. This macro really ought to take a parameter,
  90. * but we do it the disgusting crufty way forced on us by the ()-less
  91. * definition of BEGIN.
  92. */
  93. #define BEGIN (yy_start) = 1 + 2 *
  94. /* Translate the current start state into a value that can be later handed
  95. * to BEGIN to return to the state. The YYSTATE alias is for lex
  96. * compatibility.
  97. */
  98. #define YY_START (((yy_start) - 1) / 2)
  99. #define YYSTATE YY_START
  100. /* Action number for EOF rule of a given start state. */
  101. #define YY_STATE_EOF(state) (YY_END_OF_BUFFER + state + 1)
  102. /* Special action meaning "start processing a new file". */
  103. #define YY_NEW_FILE yyrestart(yyin )
  104. #define YY_END_OF_BUFFER_CHAR 0
  105. /* Size of default input buffer. */
  106. #ifndef YY_BUF_SIZE
  107. #ifdef __ia64__
  108. /* On IA-64, the buffer size is 16k, not 8k.
  109. * Moreover, YY_BUF_SIZE is 2*YY_READ_BUF_SIZE in the general case.
  110. * Ditto for the __ia64__ case accordingly.
  111. */
  112. #define YY_BUF_SIZE 32768
  113. #else
  114. #define YY_BUF_SIZE 16384
  115. #endif /* __ia64__ */
  116. #endif
  117. /* The state buf must be large enough to hold one state per character in the main buffer.
  118. */
  119. #define YY_STATE_BUF_SIZE ((YY_BUF_SIZE + 2) * sizeof(yy_state_type))
  120. #ifndef YY_TYPEDEF_YY_BUFFER_STATE
  121. #define YY_TYPEDEF_YY_BUFFER_STATE
  122. typedef struct yy_buffer_state *YY_BUFFER_STATE;
  123. #endif
  124. #ifndef YY_TYPEDEF_YY_SIZE_T
  125. #define YY_TYPEDEF_YY_SIZE_T
  126. typedef size_t yy_size_t;
  127. #endif
  128. extern int yyleng;
  129. extern FILE *yyin, *yyout;
  130. #define EOB_ACT_CONTINUE_SCAN 0
  131. #define EOB_ACT_END_OF_FILE 1
  132. #define EOB_ACT_LAST_MATCH 2
  133. #define YY_LESS_LINENO(n)
  134. #define YY_LINENO_REWIND_TO(ptr)
  135. /* Return all but the first "n" matched characters back to the input stream. */
  136. #define yyless(n) \
  137. do \
  138. { \
  139. /* Undo effects of setting up yytext. */ \
  140. int yyless_macro_arg = (n); \
  141. YY_LESS_LINENO(yyless_macro_arg);\
  142. *yy_cp = (yy_hold_char); \
  143. YY_RESTORE_YY_MORE_OFFSET \
  144. (yy_c_buf_p) = yy_cp = yy_bp + yyless_macro_arg - YY_MORE_ADJ; \
  145. YY_DO_BEFORE_ACTION; /* set up yytext again */ \
  146. } \
  147. while ( 0 )
  148. #define unput(c) yyunput( c, (yytext_ptr) )
  149. #ifndef YY_STRUCT_YY_BUFFER_STATE
  150. #define YY_STRUCT_YY_BUFFER_STATE
  151. struct yy_buffer_state
  152. {
  153. FILE *yy_input_file;
  154. char *yy_ch_buf; /* input buffer */
  155. char *yy_buf_pos; /* current position in input buffer */
  156. /* Size of input buffer in bytes, not including room for EOB
  157. * characters.
  158. */
  159. int yy_buf_size;
  160. /* Number of characters read into yy_ch_buf, not including EOB
  161. * characters.
  162. */
  163. int yy_n_chars;
  164. /* Whether we "own" the buffer - i.e., we know we created it,
  165. * and can realloc() it to grow it, and should free() it to
  166. * delete it.
  167. */
  168. int yy_is_our_buffer;
  169. /* Whether this is an "interactive" input source; if so, and
  170. * if we're using stdio for input, then we want to use getc()
  171. * instead of fread(), to make sure we stop fetching input after
  172. * each newline.
  173. */
  174. int yy_is_interactive;
  175. /* Whether we're considered to be at the beginning of a line.
  176. * If so, '^' rules will be active on the next match, otherwise
  177. * not.
  178. */
  179. int yy_at_bol;
  180. int yy_bs_lineno; /**< The line count. */
  181. int yy_bs_column; /**< The column count. */
  182. /* Whether to try to fill the input buffer when we reach the
  183. * end of it.
  184. */
  185. int yy_fill_buffer;
  186. int yy_buffer_status;
  187. #define YY_BUFFER_NEW 0
  188. #define YY_BUFFER_NORMAL 1
  189. /* When an EOF's been seen but there's still some text to process
  190. * then we mark the buffer as YY_EOF_PENDING, to indicate that we
  191. * shouldn't try reading from the input source any more. We might
  192. * still have a bunch of tokens to match, though, because of
  193. * possible backing-up.
  194. *
  195. * When we actually see the EOF, we change the status to "new"
  196. * (via yyrestart()), so that the user can continue scanning by
  197. * just pointing yyin at a new input file.
  198. */
  199. #define YY_BUFFER_EOF_PENDING 2
  200. };
  201. #endif /* !YY_STRUCT_YY_BUFFER_STATE */
  202. /* Stack of input buffers. */
  203. static size_t yy_buffer_stack_top = 0; /**< index of top of stack. */
  204. static size_t yy_buffer_stack_max = 0; /**< capacity of stack. */
  205. static YY_BUFFER_STATE * yy_buffer_stack = NULL; /**< Stack as an array. */
  206. /* We provide macros for accessing buffer states in case in the
  207. * future we want to put the buffer states in a more general
  208. * "scanner state".
  209. *
  210. * Returns the top of the stack, or NULL.
  211. */
  212. #define YY_CURRENT_BUFFER ( (yy_buffer_stack) \
  213. ? (yy_buffer_stack)[(yy_buffer_stack_top)] \
  214. : NULL)
  215. /* Same as previous macro, but useful when we know that the buffer stack is not
  216. * NULL or when we need an lvalue. For internal use only.
  217. */
  218. #define YY_CURRENT_BUFFER_LVALUE (yy_buffer_stack)[(yy_buffer_stack_top)]
  219. /* yy_hold_char holds the character lost when yytext is formed. */
  220. static char yy_hold_char;
  221. static int yy_n_chars; /* number of characters read into yy_ch_buf */
  222. int yyleng;
  223. /* Points to current character in buffer. */
  224. static char *yy_c_buf_p = NULL;
  225. static int yy_init = 0; /* whether we need to initialize */
  226. static int yy_start = 0; /* start state number */
  227. /* Flag which is used to allow yywrap()'s to do buffer switches
  228. * instead of setting up a fresh yyin. A bit of a hack ...
  229. */
  230. static int yy_did_buffer_switch_on_eof;
  231. void yyrestart (FILE *input_file );
  232. void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer );
  233. YY_BUFFER_STATE yy_create_buffer (FILE *file,int size );
  234. void yy_delete_buffer (YY_BUFFER_STATE b );
  235. void yy_flush_buffer (YY_BUFFER_STATE b );
  236. void yypush_buffer_state (YY_BUFFER_STATE new_buffer );
  237. void yypop_buffer_state (void );
  238. static void yyensure_buffer_stack (void );
  239. static void yy_load_buffer_state (void );
  240. static void yy_init_buffer (YY_BUFFER_STATE b,FILE *file );
  241. #define YY_FLUSH_BUFFER yy_flush_buffer(YY_CURRENT_BUFFER )
  242. YY_BUFFER_STATE yy_scan_buffer (char *base,yy_size_t size );
  243. YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str );
  244. YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len );
  245. void *yyalloc (yy_size_t );
  246. void *yyrealloc (void *,yy_size_t );
  247. void yyfree (void * );
  248. #define yy_new_buffer yy_create_buffer
  249. #define yy_set_interactive(is_interactive) \
  250. { \
  251. if ( ! YY_CURRENT_BUFFER ){ \
  252. yyensure_buffer_stack (); \
  253. YY_CURRENT_BUFFER_LVALUE = \
  254. yy_create_buffer(yyin,YY_BUF_SIZE ); \
  255. } \
  256. YY_CURRENT_BUFFER_LVALUE->yy_is_interactive = is_interactive; \
  257. }
  258. #define yy_set_bol(at_bol) \
  259. { \
  260. if ( ! YY_CURRENT_BUFFER ){\
  261. yyensure_buffer_stack (); \
  262. YY_CURRENT_BUFFER_LVALUE = \
  263. yy_create_buffer(yyin,YY_BUF_SIZE ); \
  264. } \
  265. YY_CURRENT_BUFFER_LVALUE->yy_at_bol = at_bol; \
  266. }
  267. #define YY_AT_BOL() (YY_CURRENT_BUFFER_LVALUE->yy_at_bol)
  268. /* Begin user sect3 */
  269. #define yywrap() (/*CONSTCOND*/1)
  270. #define YY_SKIP_YYWRAP
  271. typedef unsigned char YY_CHAR;
  272. FILE *yyin = NULL, *yyout = NULL;
  273. typedef int yy_state_type;
  274. extern int yylineno;
  275. int yylineno = 1;
  276. extern char *yytext;
  277. #ifdef yytext_ptr
  278. #undef yytext_ptr
  279. #endif
  280. #define yytext_ptr yytext
  281. static yy_state_type yy_get_previous_state (void );
  282. static yy_state_type yy_try_NUL_trans (yy_state_type current_state );
  283. static int yy_get_next_buffer (void );
  284. static void yynoreturn yy_fatal_error (yyconst char* msg );
  285. /* Done after the current pattern has been matched and before the
  286. * corresponding action - sets up yytext.
  287. */
  288. #define YY_DO_BEFORE_ACTION \
  289. (yytext_ptr) = yy_bp; \
  290. yyleng = (int) (yy_cp - yy_bp); \
  291. (yy_hold_char) = *yy_cp; \
  292. *yy_cp = '\0'; \
  293. (yy_c_buf_p) = yy_cp;
  294. #define YY_NUM_RULES 31
  295. #define YY_END_OF_BUFFER 32
  296. /* This struct is not used in this scanner,
  297. but its presence is necessary. */
  298. struct yy_trans_info
  299. {
  300. flex_int32_t yy_verify;
  301. flex_int32_t yy_nxt;
  302. };
  303. static yyconst flex_int16_t yy_accept[166] =
  304. { 0,
  305. 0, 0, 0, 0, 0, 0, 0, 0, 32, 30,
  306. 19, 19, 30, 30, 30, 30, 30, 30, 30, 30,
  307. 30, 30, 30, 30, 30, 30, 16, 17, 17, 30,
  308. 17, 11, 11, 19, 27, 0, 3, 0, 28, 13,
  309. 0, 0, 12, 0, 0, 0, 0, 0, 0, 0,
  310. 0, 22, 24, 26, 25, 23, 0, 10, 29, 0,
  311. 0, 0, 15, 15, 17, 17, 17, 11, 11, 11,
  312. 0, 13, 0, 12, 0, 0, 0, 21, 0, 0,
  313. 0, 0, 0, 0, 0, 0, 0, 17, 11, 11,
  314. 11, 0, 14, 20, 0, 0, 0, 0, 0, 0,
  315. 0, 0, 0, 0, 17, 0, 0, 0, 0, 0,
  316. 0, 0, 0, 0, 0, 17, 7, 0, 0, 0,
  317. 0, 0, 0, 0, 2, 0, 0, 0, 0, 0,
  318. 0, 0, 0, 0, 4, 18, 0, 0, 5, 2,
  319. 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
  320. 0, 0, 1, 0, 0, 0, 0, 6, 9, 0,
  321. 0, 0, 0, 8, 0
  322. } ;
  323. static yyconst YY_CHAR yy_ec[256] =
  324. { 0,
  325. 1, 1, 1, 1, 1, 1, 1, 1, 2, 3,
  326. 4, 4, 4, 1, 1, 1, 1, 1, 1, 1,
  327. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  328. 1, 2, 5, 6, 7, 1, 1, 8, 9, 1,
  329. 1, 10, 11, 11, 12, 11, 13, 14, 15, 16,
  330. 16, 16, 16, 16, 16, 16, 16, 17, 1, 18,
  331. 19, 20, 11, 11, 21, 21, 21, 21, 21, 21,
  332. 22, 22, 22, 22, 22, 23, 22, 22, 22, 22,
  333. 22, 22, 22, 22, 24, 22, 22, 25, 22, 22,
  334. 1, 26, 27, 1, 22, 1, 21, 28, 29, 30,
  335. 31, 21, 32, 22, 33, 22, 22, 34, 35, 36,
  336. 37, 38, 22, 39, 40, 41, 42, 43, 22, 25,
  337. 44, 22, 45, 46, 47, 1, 1, 1, 1, 1,
  338. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  339. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  340. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  341. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  342. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  343. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  344. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  345. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  346. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  347. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  348. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  349. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  350. 1, 1, 1, 1, 1
  351. } ;
  352. static yyconst YY_CHAR yy_meta[48] =
  353. { 0,
  354. 1, 1, 1, 1, 1, 1, 2, 3, 1, 2,
  355. 2, 2, 4, 5, 5, 5, 6, 1, 1, 1,
  356. 7, 8, 8, 8, 8, 1, 1, 7, 7, 7,
  357. 7, 8, 8, 8, 8, 8, 8, 8, 8, 8,
  358. 8, 8, 8, 8, 3, 1, 4
  359. } ;
  360. static yyconst flex_uint16_t yy_base[180] =
  361. { 0,
  362. 0, 393, 35, 392, 66, 391, 38, 107, 397, 401,
  363. 55, 113, 377, 112, 111, 111, 114, 42, 376, 106,
  364. 377, 347, 126, 120, 0, 147, 401, 0, 124, 0,
  365. 137, 158, 170, 163, 401, 153, 401, 389, 401, 0,
  366. 378, 120, 401, 131, 380, 386, 355, 139, 351, 355,
  367. 351, 401, 401, 401, 401, 401, 367, 401, 401, 185,
  368. 350, 346, 401, 364, 0, 185, 347, 189, 356, 355,
  369. 0, 0, 330, 180, 366, 141, 372, 361, 332, 338,
  370. 331, 341, 334, 326, 205, 331, 337, 329, 401, 341,
  371. 167, 316, 401, 349, 348, 320, 328, 346, 180, 318,
  372. 324, 209, 324, 320, 322, 342, 338, 309, 306, 315,
  373. 305, 315, 312, 192, 342, 341, 401, 293, 306, 282,
  374. 268, 252, 255, 203, 285, 282, 272, 268, 252, 233,
  375. 232, 239, 208, 107, 401, 401, 238, 211, 401, 211,
  376. 212, 208, 228, 203, 215, 207, 233, 222, 212, 211,
  377. 203, 227, 401, 237, 225, 204, 185, 401, 401, 149,
  378. 128, 88, 42, 401, 401, 253, 259, 267, 271, 275,
  379. 281, 288, 292, 300, 308, 312, 318, 326, 334
  380. } ;
  381. static yyconst flex_int16_t yy_def[180] =
  382. { 0,
  383. 165, 1, 1, 3, 165, 5, 1, 1, 165, 165,
  384. 165, 165, 165, 166, 167, 168, 165, 165, 165, 165,
  385. 169, 165, 165, 165, 170, 169, 165, 171, 172, 171,
  386. 171, 165, 165, 165, 165, 166, 165, 166, 165, 173,
  387. 165, 168, 165, 168, 174, 175, 165, 165, 165, 165,
  388. 165, 165, 165, 165, 165, 165, 169, 165, 165, 165,
  389. 165, 165, 165, 169, 171, 172, 171, 165, 165, 165,
  390. 176, 173, 177, 168, 174, 174, 175, 165, 165, 165,
  391. 165, 165, 165, 165, 165, 165, 165, 171, 165, 165,
  392. 176, 177, 165, 165, 165, 165, 165, 165, 165, 165,
  393. 165, 165, 165, 165, 171, 165, 165, 165, 165, 165,
  394. 165, 165, 165, 178, 165, 171, 165, 165, 165, 165,
  395. 165, 165, 165, 178, 165, 178, 165, 165, 165, 165,
  396. 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  397. 165, 165, 165, 165, 165, 165, 165, 179, 165, 165,
  398. 165, 179, 165, 179, 165, 165, 165, 165, 165, 165,
  399. 165, 165, 165, 165, 0, 165, 165, 165, 165, 165,
  400. 165, 165, 165, 165, 165, 165, 165, 165, 165
  401. } ;
  402. static yyconst flex_uint16_t yy_nxt[449] =
  403. { 0,
  404. 10, 11, 12, 11, 13, 14, 10, 15, 16, 10,
  405. 10, 10, 17, 10, 10, 10, 10, 18, 19, 20,
  406. 21, 21, 21, 21, 21, 10, 10, 21, 21, 21,
  407. 21, 21, 21, 21, 21, 21, 21, 21, 21, 21,
  408. 21, 21, 21, 21, 10, 22, 10, 24, 25, 25,
  409. 25, 32, 33, 33, 164, 26, 34, 34, 34, 52,
  410. 53, 27, 26, 26, 26, 26, 10, 11, 12, 11,
  411. 13, 14, 28, 15, 16, 28, 28, 28, 24, 28,
  412. 28, 28, 10, 18, 19, 20, 29, 29, 29, 29,
  413. 29, 30, 10, 29, 29, 29, 29, 29, 29, 29,
  414. 29, 29, 29, 29, 29, 29, 29, 29, 29, 29,
  415. 10, 22, 10, 23, 34, 34, 34, 37, 39, 43,
  416. 32, 33, 33, 45, 55, 56, 46, 60, 43, 45,
  417. 65, 163, 46, 65, 65, 65, 44, 38, 60, 74,
  418. 58, 47, 141, 48, 142, 44, 49, 47, 50, 48,
  419. 76, 51, 62, 94, 50, 41, 44, 51, 37, 61,
  420. 64, 64, 64, 58, 34, 34, 34, 64, 162, 80,
  421. 67, 68, 68, 68, 64, 64, 64, 64, 38, 81,
  422. 69, 70, 71, 68, 68, 68, 60, 161, 43, 69,
  423. 70, 65, 69, 70, 65, 65, 65, 125, 85, 85,
  424. 85, 58, 68, 68, 68, 44, 102, 110, 125, 133,
  425. 102, 69, 70, 111, 114, 160, 159, 126, 85, 85,
  426. 85, 140, 140, 140, 140, 140, 140, 153, 126, 147,
  427. 147, 147, 153, 148, 147, 147, 147, 158, 148, 165,
  428. 157, 156, 155, 151, 150, 149, 146, 154, 145, 144,
  429. 143, 139, 154, 36, 36, 36, 36, 36, 36, 36,
  430. 36, 40, 138, 137, 136, 40, 40, 42, 42, 42,
  431. 42, 42, 42, 42, 42, 57, 57, 57, 57, 63,
  432. 135, 63, 65, 134, 165, 65, 133, 65, 65, 66,
  433. 132, 131, 66, 66, 66, 66, 72, 130, 72, 72,
  434. 75, 75, 75, 75, 75, 75, 75, 75, 77, 77,
  435. 77, 77, 77, 77, 77, 77, 91, 129, 91, 92,
  436. 128, 92, 92, 127, 92, 92, 124, 124, 124, 124,
  437. 124, 124, 124, 124, 152, 152, 152, 152, 152, 152,
  438. 152, 152, 60, 60, 123, 122, 121, 120, 119, 118,
  439. 117, 45, 116, 111, 115, 113, 112, 109, 108, 107,
  440. 46, 106, 93, 89, 105, 104, 103, 101, 100, 99,
  441. 98, 97, 96, 95, 78, 76, 93, 90, 89, 88,
  442. 58, 87, 86, 58, 84, 83, 82, 79, 78, 76,
  443. 73, 165, 59, 58, 54, 35, 165, 31, 23, 23,
  444. 9, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  445. 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  446. 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  447. 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  448. 165, 165, 165, 165, 165, 165, 165, 165
  449. } ;
  450. static yyconst flex_int16_t yy_chk[449] =
  451. { 0,
  452. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  453. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  454. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  455. 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
  456. 1, 1, 1, 1, 1, 1, 1, 3, 3, 3,
  457. 3, 7, 7, 7, 163, 3, 11, 11, 11, 18,
  458. 18, 3, 3, 3, 3, 3, 5, 5, 5, 5,
  459. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  460. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  461. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  462. 5, 5, 5, 5, 5, 5, 5, 5, 5, 5,
  463. 5, 5, 5, 8, 12, 12, 12, 14, 15, 16,
  464. 8, 8, 8, 17, 20, 20, 17, 23, 42, 24,
  465. 29, 162, 24, 29, 29, 29, 16, 14, 31, 44,
  466. 29, 17, 134, 17, 134, 42, 17, 24, 17, 24,
  467. 76, 17, 24, 76, 24, 15, 44, 24, 36, 23,
  468. 26, 26, 26, 26, 34, 34, 34, 26, 161, 48,
  469. 31, 32, 32, 32, 26, 26, 26, 26, 36, 48,
  470. 32, 32, 32, 33, 33, 33, 60, 160, 74, 91,
  471. 91, 66, 33, 33, 66, 66, 66, 114, 60, 60,
  472. 60, 66, 68, 68, 68, 74, 85, 99, 124, 133,
  473. 102, 68, 68, 99, 102, 157, 156, 114, 85, 85,
  474. 85, 133, 133, 133, 140, 140, 140, 148, 124, 143,
  475. 143, 143, 152, 143, 147, 147, 147, 155, 147, 154,
  476. 151, 150, 149, 146, 145, 144, 142, 148, 141, 138,
  477. 137, 132, 152, 166, 166, 166, 166, 166, 166, 166,
  478. 166, 167, 131, 130, 129, 167, 167, 168, 168, 168,
  479. 168, 168, 168, 168, 168, 169, 169, 169, 169, 170,
  480. 128, 170, 171, 127, 126, 171, 125, 171, 171, 172,
  481. 123, 122, 172, 172, 172, 172, 173, 121, 173, 173,
  482. 174, 174, 174, 174, 174, 174, 174, 174, 175, 175,
  483. 175, 175, 175, 175, 175, 175, 176, 120, 176, 177,
  484. 119, 177, 177, 118, 177, 177, 178, 178, 178, 178,
  485. 178, 178, 178, 178, 179, 179, 179, 179, 179, 179,
  486. 179, 179, 116, 115, 113, 112, 111, 110, 109, 108,
  487. 107, 106, 105, 104, 103, 101, 100, 98, 97, 96,
  488. 95, 94, 92, 90, 88, 87, 86, 84, 83, 82,
  489. 81, 80, 79, 78, 77, 75, 73, 70, 69, 67,
  490. 64, 62, 61, 57, 51, 50, 49, 47, 46, 45,
  491. 41, 38, 22, 21, 19, 13, 9, 6, 4, 2,
  492. 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  493. 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  494. 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  495. 165, 165, 165, 165, 165, 165, 165, 165, 165, 165,
  496. 165, 165, 165, 165, 165, 165, 165, 165
  497. } ;
  498. static yy_state_type yy_last_accepting_state;
  499. static char *yy_last_accepting_cpos;
  500. extern int yy_flex_debug;
  501. int yy_flex_debug = 0;
  502. /* The intent behind this definition is that it'll catch
  503. * any uses of REJECT which flex missed.
  504. */
  505. #define REJECT reject_used_but_not_detected
  506. #define yymore() yymore_used_but_not_detected
  507. #define YY_MORE_ADJ 0
  508. #define YY_RESTORE_YY_MORE_OFFSET
  509. char *yytext;
  510. #line 1 "dtc-lexer.l"
  511. /*
  512. * (C) Copyright David Gibson <dwg@au1.ibm.com>, IBM Corporation. 2005.
  513. *
  514. *
  515. * This program is free software; you can redistribute it and/or
  516. * modify it under the terms of the GNU General Public License as
  517. * published by the Free Software Foundation; either version 2 of the
  518. * License, or (at your option) any later version.
  519. *
  520. * This program is distributed in the hope that it will be useful,
  521. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  522. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  523. * General Public License for more details.
  524. *
  525. * You should have received a copy of the GNU General Public License
  526. * along with this program; if not, write to the Free Software
  527. * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
  528. * USA
  529. */
  530. #define YY_NO_INPUT 1
  531. #line 37 "dtc-lexer.l"
  532. #include "dtc.h"
  533. #include "srcpos.h"
  534. #include "dtc-parser.tab.h"
  535. extern bool treesource_error;
  536. /* CAUTION: this will stop working if we ever use yyless() or yyunput() */
  537. #define YY_USER_ACTION \
  538. { \
  539. srcpos_update(&yylloc, yytext, yyleng); \
  540. }
  541. /*#define LEXDEBUG 1*/
  542. #ifdef LEXDEBUG
  543. #define DPRINT(fmt, ...) fprintf(stderr, fmt, ##__VA_ARGS__)
  544. #else
  545. #define DPRINT(fmt, ...) do { } while (0)
  546. #endif
  547. static int dts_version = 1;
  548. #define BEGIN_DEFAULT() DPRINT("<V1>\n"); \
  549. BEGIN(V1); \
  550. static void push_input_file(const char *filename);
  551. static bool pop_input_file(void);
  552. static void PRINTF(1, 2) lexical_error(const char *fmt, ...);
  553. #line 661 "dtc-lexer.lex.c"
  554. #define INITIAL 0
  555. #define BYTESTRING 1
  556. #define PROPNODENAME 2
  557. #define V1 3
  558. #ifndef YY_NO_UNISTD_H
  559. /* Special case for "unistd.h", since it is non-ANSI. We include it way
  560. * down here because we want the user's section 1 to have been scanned first.
  561. * The user has a chance to override it with an option.
  562. */
  563. #include <unistd.h>
  564. #endif
  565. #ifndef YY_EXTRA_TYPE
  566. #define YY_EXTRA_TYPE void *
  567. #endif
  568. static int yy_init_globals (void );
  569. /* Accessor methods to globals.
  570. These are made visible to non-reentrant scanners for convenience. */
  571. int yylex_destroy (void );
  572. int yyget_debug (void );
  573. void yyset_debug (int debug_flag );
  574. YY_EXTRA_TYPE yyget_extra (void );
  575. void yyset_extra (YY_EXTRA_TYPE user_defined );
  576. FILE *yyget_in (void );
  577. void yyset_in (FILE * _in_str );
  578. FILE *yyget_out (void );
  579. void yyset_out (FILE * _out_str );
  580. int yyget_leng (void );
  581. char *yyget_text (void );
  582. int yyget_lineno (void );
  583. void yyset_lineno (int _line_number );
  584. /* Macros after this point can all be overridden by user definitions in
  585. * section 1.
  586. */
  587. #ifndef YY_SKIP_YYWRAP
  588. #ifdef __cplusplus
  589. extern "C" int yywrap (void );
  590. #else
  591. extern int yywrap (void );
  592. #endif
  593. #endif
  594. #ifndef YY_NO_UNPUT
  595. #endif
  596. #ifndef yytext_ptr
  597. static void yy_flex_strncpy (char *,yyconst char *,int );
  598. #endif
  599. #ifdef YY_NEED_STRLEN
  600. static int yy_flex_strlen (yyconst char * );
  601. #endif
  602. #ifndef YY_NO_INPUT
  603. #ifdef __cplusplus
  604. static int yyinput (void );
  605. #else
  606. static int input (void );
  607. #endif
  608. #endif
  609. /* Amount of stuff to slurp up with each read. */
  610. #ifndef YY_READ_BUF_SIZE
  611. #ifdef __ia64__
  612. /* On IA-64, the buffer size is 16k, not 8k */
  613. #define YY_READ_BUF_SIZE 16384
  614. #else
  615. #define YY_READ_BUF_SIZE 8192
  616. #endif /* __ia64__ */
  617. #endif
  618. /* Copy whatever the last rule matched to the standard output. */
  619. #ifndef ECHO
  620. /* This used to be an fputs(), but since the string might contain NUL's,
  621. * we now use fwrite().
  622. */
  623. #define ECHO do { if (fwrite( yytext, (size_t) yyleng, 1, yyout )) {} } while (0)
  624. #endif
  625. /* Gets input and stuffs it into "buf". number of characters read, or YY_NULL,
  626. * is returned in "result".
  627. */
  628. #ifndef YY_INPUT
  629. #define YY_INPUT(buf,result,max_size) \
  630. if ( YY_CURRENT_BUFFER_LVALUE->yy_is_interactive ) \
  631. { \
  632. int c = '*'; \
  633. size_t n; \
  634. for ( n = 0; n < max_size && \
  635. (c = getc( yyin )) != EOF && c != '\n'; ++n ) \
  636. buf[n] = (char) c; \
  637. if ( c == '\n' ) \
  638. buf[n++] = (char) c; \
  639. if ( c == EOF && ferror( yyin ) ) \
  640. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  641. result = n; \
  642. } \
  643. else \
  644. { \
  645. errno=0; \
  646. while ( (result = (int) fread(buf, 1, max_size, yyin))==0 && ferror(yyin)) \
  647. { \
  648. if( errno != EINTR) \
  649. { \
  650. YY_FATAL_ERROR( "input in flex scanner failed" ); \
  651. break; \
  652. } \
  653. errno=0; \
  654. clearerr(yyin); \
  655. } \
  656. }\
  657. \
  658. #endif
  659. /* No semi-colon after return; correct usage is to write "yyterminate();" -
  660. * we don't want an extra ';' after the "return" because that will cause
  661. * some compilers to complain about unreachable statements.
  662. */
  663. #ifndef yyterminate
  664. #define yyterminate() return YY_NULL
  665. #endif
  666. /* Number of entries by which start-condition stack grows. */
  667. #ifndef YY_START_STACK_INCR
  668. #define YY_START_STACK_INCR 25
  669. #endif
  670. /* Report a fatal error. */
  671. #ifndef YY_FATAL_ERROR
  672. #define YY_FATAL_ERROR(msg) yy_fatal_error( msg )
  673. #endif
  674. /* end tables serialization structures and prototypes */
  675. /* Default declaration of generated scanner - a define so the user can
  676. * easily add parameters.
  677. */
  678. #ifndef YY_DECL
  679. #define YY_DECL_IS_OURS 1
  680. extern int yylex (void);
  681. #define YY_DECL int yylex (void)
  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 /*LINTED*/break;
  692. #endif
  693. #define YY_RULE_SETUP \
  694. if ( yyleng > 0 ) \
  695. YY_CURRENT_BUFFER_LVALUE->yy_at_bol = \
  696. (yytext[yyleng - 1] == '\n'); \
  697. YY_USER_ACTION
  698. /** The main scanner function which does all the work.
  699. */
  700. YY_DECL
  701. {
  702. yy_state_type yy_current_state;
  703. char *yy_cp, *yy_bp;
  704. int yy_act;
  705. if ( !(yy_init) )
  706. {
  707. (yy_init) = 1;
  708. #ifdef YY_USER_INIT
  709. YY_USER_INIT;
  710. #endif
  711. if ( ! (yy_start) )
  712. (yy_start) = 1; /* first start state */
  713. if ( ! yyin )
  714. yyin = stdin;
  715. if ( ! yyout )
  716. yyout = stdout;
  717. if ( ! YY_CURRENT_BUFFER ) {
  718. yyensure_buffer_stack ();
  719. YY_CURRENT_BUFFER_LVALUE =
  720. yy_create_buffer(yyin,YY_BUF_SIZE );
  721. }
  722. yy_load_buffer_state( );
  723. }
  724. {
  725. #line 69 "dtc-lexer.l"
  726. #line 885 "dtc-lexer.lex.c"
  727. while ( /*CONSTCOND*/1 ) /* loops until end-of-file is reached */
  728. {
  729. yy_cp = (yy_c_buf_p);
  730. /* Support of yytext. */
  731. *yy_cp = (yy_hold_char);
  732. /* yy_bp points to the position in yy_ch_buf of the start of
  733. * the current run.
  734. */
  735. yy_bp = yy_cp;
  736. yy_current_state = (yy_start);
  737. yy_current_state += YY_AT_BOL();
  738. yy_match:
  739. do
  740. {
  741. YY_CHAR yy_c = yy_ec[YY_SC_TO_UI(*yy_cp)] ;
  742. if ( yy_accept[yy_current_state] )
  743. {
  744. (yy_last_accepting_state) = yy_current_state;
  745. (yy_last_accepting_cpos) = yy_cp;
  746. }
  747. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  748. {
  749. yy_current_state = (int) yy_def[yy_current_state];
  750. if ( yy_current_state >= 166 )
  751. yy_c = yy_meta[(unsigned int) yy_c];
  752. }
  753. yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
  754. ++yy_cp;
  755. }
  756. while ( yy_current_state != 165 );
  757. yy_cp = (yy_last_accepting_cpos);
  758. yy_current_state = (yy_last_accepting_state);
  759. yy_find_action:
  760. yy_act = yy_accept[yy_current_state];
  761. YY_DO_BEFORE_ACTION;
  762. do_action: /* This label is used only to access EOF actions. */
  763. switch ( yy_act )
  764. { /* beginning of action switch */
  765. case 0: /* must back up */
  766. /* undo the effects of YY_DO_BEFORE_ACTION */
  767. *yy_cp = (yy_hold_char);
  768. yy_cp = (yy_last_accepting_cpos);
  769. yy_current_state = (yy_last_accepting_state);
  770. goto yy_find_action;
  771. case 1:
  772. /* rule 1 can match eol */
  773. YY_RULE_SETUP
  774. #line 70 "dtc-lexer.l"
  775. {
  776. char *name = strchr(yytext, '\"') + 1;
  777. yytext[yyleng-1] = '\0';
  778. push_input_file(name);
  779. }
  780. YY_BREAK
  781. case 2:
  782. /* rule 2 can match eol */
  783. YY_RULE_SETUP
  784. #line 76 "dtc-lexer.l"
  785. {
  786. char *line, *fnstart, *fnend;
  787. struct data fn;
  788. /* skip text before line # */
  789. line = yytext;
  790. while (!isdigit((unsigned char)*line))
  791. line++;
  792. /* regexp ensures that first and list "
  793. * in the whole yytext are those at
  794. * beginning and end of the filename string */
  795. fnstart = memchr(yytext, '"', yyleng);
  796. for (fnend = yytext + yyleng - 1;
  797. *fnend != '"'; fnend--)
  798. ;
  799. assert(fnstart && fnend && (fnend > fnstart));
  800. fn = data_copy_escape_string(fnstart + 1,
  801. fnend - fnstart - 1);
  802. /* Don't allow nuls in filenames */
  803. if (memchr(fn.val, '\0', fn.len - 1))
  804. lexical_error("nul in line number directive");
  805. /* -1 since #line is the number of the next line */
  806. srcpos_set_line(xstrdup(fn.val), atoi(line) - 1);
  807. data_free(fn);
  808. }
  809. YY_BREAK
  810. case YY_STATE_EOF(INITIAL):
  811. case YY_STATE_EOF(BYTESTRING):
  812. case YY_STATE_EOF(PROPNODENAME):
  813. case YY_STATE_EOF(V1):
  814. #line 105 "dtc-lexer.l"
  815. {
  816. if (!pop_input_file()) {
  817. yyterminate();
  818. }
  819. }
  820. YY_BREAK
  821. case 3:
  822. /* rule 3 can match eol */
  823. YY_RULE_SETUP
  824. #line 111 "dtc-lexer.l"
  825. {
  826. DPRINT("String: %s\n", yytext);
  827. yylval.data = data_copy_escape_string(yytext+1,
  828. yyleng-2);
  829. return DT_STRING;
  830. }
  831. YY_BREAK
  832. case 4:
  833. YY_RULE_SETUP
  834. #line 118 "dtc-lexer.l"
  835. {
  836. DPRINT("Keyword: /dts-v1/\n");
  837. dts_version = 1;
  838. BEGIN_DEFAULT();
  839. return DT_V1;
  840. }
  841. YY_BREAK
  842. case 5:
  843. YY_RULE_SETUP
  844. #line 125 "dtc-lexer.l"
  845. {
  846. DPRINT("Keyword: /plugin/\n");
  847. return DT_PLUGIN;
  848. }
  849. YY_BREAK
  850. case 6:
  851. YY_RULE_SETUP
  852. #line 130 "dtc-lexer.l"
  853. {
  854. DPRINT("Keyword: /memreserve/\n");
  855. BEGIN_DEFAULT();
  856. return DT_MEMRESERVE;
  857. }
  858. YY_BREAK
  859. case 7:
  860. YY_RULE_SETUP
  861. #line 136 "dtc-lexer.l"
  862. {
  863. DPRINT("Keyword: /bits/\n");
  864. BEGIN_DEFAULT();
  865. return DT_BITS;
  866. }
  867. YY_BREAK
  868. case 8:
  869. YY_RULE_SETUP
  870. #line 142 "dtc-lexer.l"
  871. {
  872. DPRINT("Keyword: /delete-property/\n");
  873. DPRINT("<PROPNODENAME>\n");
  874. BEGIN(PROPNODENAME);
  875. return DT_DEL_PROP;
  876. }
  877. YY_BREAK
  878. case 9:
  879. YY_RULE_SETUP
  880. #line 149 "dtc-lexer.l"
  881. {
  882. DPRINT("Keyword: /delete-node/\n");
  883. DPRINT("<PROPNODENAME>\n");
  884. BEGIN(PROPNODENAME);
  885. return DT_DEL_NODE;
  886. }
  887. YY_BREAK
  888. case 10:
  889. YY_RULE_SETUP
  890. #line 156 "dtc-lexer.l"
  891. {
  892. DPRINT("Label: %s\n", yytext);
  893. yylval.labelref = xstrdup(yytext);
  894. yylval.labelref[yyleng-1] = '\0';
  895. return DT_LABEL;
  896. }
  897. YY_BREAK
  898. case 11:
  899. YY_RULE_SETUP
  900. #line 163 "dtc-lexer.l"
  901. {
  902. char *e;
  903. DPRINT("Integer Literal: '%s'\n", yytext);
  904. errno = 0;
  905. yylval.integer = strtoull(yytext, &e, 0);
  906. if (*e && e[strspn(e, "UL")]) {
  907. lexical_error("Bad integer literal '%s'",
  908. yytext);
  909. }
  910. if (errno == ERANGE)
  911. lexical_error("Integer literal '%s' out of range",
  912. yytext);
  913. else
  914. /* ERANGE is the only strtoull error triggerable
  915. * by strings matching the pattern */
  916. assert(errno == 0);
  917. return DT_LITERAL;
  918. }
  919. YY_BREAK
  920. case 12:
  921. /* rule 12 can match eol */
  922. YY_RULE_SETUP
  923. #line 185 "dtc-lexer.l"
  924. {
  925. struct data d;
  926. DPRINT("Character literal: %s\n", yytext);
  927. d = data_copy_escape_string(yytext+1, yyleng-2);
  928. if (d.len == 1) {
  929. lexical_error("Empty character literal");
  930. yylval.integer = 0;
  931. } else {
  932. yylval.integer = (unsigned char)d.val[0];
  933. if (d.len > 2)
  934. lexical_error("Character literal has %d"
  935. " characters instead of 1",
  936. d.len - 1);
  937. }
  938. data_free(d);
  939. return DT_CHAR_LITERAL;
  940. }
  941. YY_BREAK
  942. case 13:
  943. YY_RULE_SETUP
  944. #line 206 "dtc-lexer.l"
  945. { /* label reference */
  946. DPRINT("Ref: %s\n", yytext+1);
  947. yylval.labelref = xstrdup(yytext+1);
  948. return DT_REF;
  949. }
  950. YY_BREAK
  951. case 14:
  952. YY_RULE_SETUP
  953. #line 212 "dtc-lexer.l"
  954. { /* new-style path reference */
  955. yytext[yyleng-1] = '\0';
  956. DPRINT("Ref: %s\n", yytext+2);
  957. yylval.labelref = xstrdup(yytext+2);
  958. return DT_REF;
  959. }
  960. YY_BREAK
  961. case 15:
  962. YY_RULE_SETUP
  963. #line 219 "dtc-lexer.l"
  964. {
  965. yylval.byte = strtol(yytext, NULL, 16);
  966. DPRINT("Byte: %02x\n", (int)yylval.byte);
  967. return DT_BYTE;
  968. }
  969. YY_BREAK
  970. case 16:
  971. YY_RULE_SETUP
  972. #line 225 "dtc-lexer.l"
  973. {
  974. DPRINT("/BYTESTRING\n");
  975. BEGIN_DEFAULT();
  976. return ']';
  977. }
  978. YY_BREAK
  979. case 17:
  980. YY_RULE_SETUP
  981. #line 231 "dtc-lexer.l"
  982. {
  983. DPRINT("PropNodeName: %s\n", yytext);
  984. yylval.propnodename = xstrdup((yytext[0] == '\\') ?
  985. yytext + 1 : yytext);
  986. BEGIN_DEFAULT();
  987. return DT_PROPNODENAME;
  988. }
  989. YY_BREAK
  990. case 18:
  991. YY_RULE_SETUP
  992. #line 239 "dtc-lexer.l"
  993. {
  994. DPRINT("Binary Include\n");
  995. return DT_INCBIN;
  996. }
  997. YY_BREAK
  998. case 19:
  999. /* rule 19 can match eol */
  1000. YY_RULE_SETUP
  1001. #line 244 "dtc-lexer.l"
  1002. /* eat whitespace */
  1003. YY_BREAK
  1004. case 20:
  1005. /* rule 20 can match eol */
  1006. YY_RULE_SETUP
  1007. #line 245 "dtc-lexer.l"
  1008. /* eat C-style comments */
  1009. YY_BREAK
  1010. case 21:
  1011. /* rule 21 can match eol */
  1012. YY_RULE_SETUP
  1013. #line 246 "dtc-lexer.l"
  1014. /* eat C++-style comments */
  1015. YY_BREAK
  1016. case 22:
  1017. YY_RULE_SETUP
  1018. #line 248 "dtc-lexer.l"
  1019. { return DT_LSHIFT; };
  1020. YY_BREAK
  1021. case 23:
  1022. YY_RULE_SETUP
  1023. #line 249 "dtc-lexer.l"
  1024. { return DT_RSHIFT; };
  1025. YY_BREAK
  1026. case 24:
  1027. YY_RULE_SETUP
  1028. #line 250 "dtc-lexer.l"
  1029. { return DT_LE; };
  1030. YY_BREAK
  1031. case 25:
  1032. YY_RULE_SETUP
  1033. #line 251 "dtc-lexer.l"
  1034. { return DT_GE; };
  1035. YY_BREAK
  1036. case 26:
  1037. YY_RULE_SETUP
  1038. #line 252 "dtc-lexer.l"
  1039. { return DT_EQ; };
  1040. YY_BREAK
  1041. case 27:
  1042. YY_RULE_SETUP
  1043. #line 253 "dtc-lexer.l"
  1044. { return DT_NE; };
  1045. YY_BREAK
  1046. case 28:
  1047. YY_RULE_SETUP
  1048. #line 254 "dtc-lexer.l"
  1049. { return DT_AND; };
  1050. YY_BREAK
  1051. case 29:
  1052. YY_RULE_SETUP
  1053. #line 255 "dtc-lexer.l"
  1054. { return DT_OR; };
  1055. YY_BREAK
  1056. case 30:
  1057. YY_RULE_SETUP
  1058. #line 257 "dtc-lexer.l"
  1059. {
  1060. DPRINT("Char: %c (\\x%02x)\n", yytext[0],
  1061. (unsigned)yytext[0]);
  1062. if (yytext[0] == '[') {
  1063. DPRINT("<BYTESTRING>\n");
  1064. BEGIN(BYTESTRING);
  1065. }
  1066. if ((yytext[0] == '{')
  1067. || (yytext[0] == ';')) {
  1068. DPRINT("<PROPNODENAME>\n");
  1069. BEGIN(PROPNODENAME);
  1070. }
  1071. return yytext[0];
  1072. }
  1073. YY_BREAK
  1074. case 31:
  1075. YY_RULE_SETUP
  1076. #line 272 "dtc-lexer.l"
  1077. ECHO;
  1078. YY_BREAK
  1079. #line 1257 "dtc-lexer.lex.c"
  1080. case YY_END_OF_BUFFER:
  1081. {
  1082. /* Amount of text matched not including the EOB char. */
  1083. int yy_amount_of_matched_text = (int) (yy_cp - (yytext_ptr)) - 1;
  1084. /* Undo the effects of YY_DO_BEFORE_ACTION. */
  1085. *yy_cp = (yy_hold_char);
  1086. YY_RESTORE_YY_MORE_OFFSET
  1087. if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_NEW )
  1088. {
  1089. /* We're scanning a new file or input source. It's
  1090. * possible that this happened because the user
  1091. * just pointed yyin at a new source and called
  1092. * yylex(). If so, then we have to assure
  1093. * consistency between YY_CURRENT_BUFFER and our
  1094. * globals. Here is the right place to do so, because
  1095. * this is the first action (other than possibly a
  1096. * back-up) that will match for the new input source.
  1097. */
  1098. (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
  1099. YY_CURRENT_BUFFER_LVALUE->yy_input_file = yyin;
  1100. YY_CURRENT_BUFFER_LVALUE->yy_buffer_status = YY_BUFFER_NORMAL;
  1101. }
  1102. /* Note that here we test for yy_c_buf_p "<=" to the position
  1103. * of the first EOB in the buffer, since yy_c_buf_p will
  1104. * already have been incremented past the NUL character
  1105. * (since all states make transitions on EOB to the
  1106. * end-of-buffer state). Contrast this with the test
  1107. * in input().
  1108. */
  1109. if ( (yy_c_buf_p) <= &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
  1110. { /* This was really a NUL. */
  1111. yy_state_type yy_next_state;
  1112. (yy_c_buf_p) = (yytext_ptr) + yy_amount_of_matched_text;
  1113. yy_current_state = yy_get_previous_state( );
  1114. /* Okay, we're now positioned to make the NUL
  1115. * transition. We couldn't have
  1116. * yy_get_previous_state() go ahead and do it
  1117. * for us because it doesn't know how to deal
  1118. * with the possibility of jamming (and we don't
  1119. * want to build jamming into it because then it
  1120. * will run more slowly).
  1121. */
  1122. yy_next_state = yy_try_NUL_trans( yy_current_state );
  1123. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  1124. if ( yy_next_state )
  1125. {
  1126. /* Consume the NUL. */
  1127. yy_cp = ++(yy_c_buf_p);
  1128. yy_current_state = yy_next_state;
  1129. goto yy_match;
  1130. }
  1131. else
  1132. {
  1133. yy_cp = (yy_last_accepting_cpos);
  1134. yy_current_state = (yy_last_accepting_state);
  1135. goto yy_find_action;
  1136. }
  1137. }
  1138. else switch ( yy_get_next_buffer( ) )
  1139. {
  1140. case EOB_ACT_END_OF_FILE:
  1141. {
  1142. (yy_did_buffer_switch_on_eof) = 0;
  1143. if ( yywrap( ) )
  1144. {
  1145. /* Note: because we've taken care in
  1146. * yy_get_next_buffer() to have set up
  1147. * yytext, we can now set up
  1148. * yy_c_buf_p so that if some total
  1149. * hoser (like flex itself) wants to
  1150. * call the scanner after we return the
  1151. * YY_NULL, it'll still work - another
  1152. * YY_NULL will get returned.
  1153. */
  1154. (yy_c_buf_p) = (yytext_ptr) + YY_MORE_ADJ;
  1155. yy_act = YY_STATE_EOF(YY_START);
  1156. goto do_action;
  1157. }
  1158. else
  1159. {
  1160. if ( ! (yy_did_buffer_switch_on_eof) )
  1161. YY_NEW_FILE;
  1162. }
  1163. break;
  1164. }
  1165. case EOB_ACT_CONTINUE_SCAN:
  1166. (yy_c_buf_p) =
  1167. (yytext_ptr) + yy_amount_of_matched_text;
  1168. yy_current_state = yy_get_previous_state( );
  1169. yy_cp = (yy_c_buf_p);
  1170. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  1171. goto yy_match;
  1172. case EOB_ACT_LAST_MATCH:
  1173. (yy_c_buf_p) =
  1174. &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)];
  1175. yy_current_state = yy_get_previous_state( );
  1176. yy_cp = (yy_c_buf_p);
  1177. yy_bp = (yytext_ptr) + YY_MORE_ADJ;
  1178. goto yy_find_action;
  1179. }
  1180. break;
  1181. }
  1182. default:
  1183. YY_FATAL_ERROR(
  1184. "fatal flex scanner internal error--no action found" );
  1185. } /* end of action switch */
  1186. } /* end of scanning one token */
  1187. } /* end of user's declarations */
  1188. } /* end of yylex */
  1189. /* yy_get_next_buffer - try to read in a new buffer
  1190. *
  1191. * Returns a code representing an action:
  1192. * EOB_ACT_LAST_MATCH -
  1193. * EOB_ACT_CONTINUE_SCAN - continue scanning from current position
  1194. * EOB_ACT_END_OF_FILE - end of file
  1195. */
  1196. static int yy_get_next_buffer (void)
  1197. {
  1198. char *dest = YY_CURRENT_BUFFER_LVALUE->yy_ch_buf;
  1199. char *source = (yytext_ptr);
  1200. int number_to_move, i;
  1201. int ret_val;
  1202. if ( (yy_c_buf_p) > &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] )
  1203. YY_FATAL_ERROR(
  1204. "fatal flex scanner internal error--end of buffer missed" );
  1205. if ( YY_CURRENT_BUFFER_LVALUE->yy_fill_buffer == 0 )
  1206. { /* Don't try to fill the buffer, so this is an EOF. */
  1207. if ( (yy_c_buf_p) - (yytext_ptr) - YY_MORE_ADJ == 1 )
  1208. {
  1209. /* We matched a single character, the EOB, so
  1210. * treat this as a final EOF.
  1211. */
  1212. return EOB_ACT_END_OF_FILE;
  1213. }
  1214. else
  1215. {
  1216. /* We matched some text prior to the EOB, first
  1217. * process it.
  1218. */
  1219. return EOB_ACT_LAST_MATCH;
  1220. }
  1221. }
  1222. /* Try to read more data. */
  1223. /* First move last chars to start of buffer. */
  1224. number_to_move = (int) ((yy_c_buf_p) - (yytext_ptr) - 1);
  1225. for ( i = 0; i < number_to_move; ++i )
  1226. *(dest++) = *(source++);
  1227. if ( YY_CURRENT_BUFFER_LVALUE->yy_buffer_status == YY_BUFFER_EOF_PENDING )
  1228. /* don't do the read, it's not guaranteed to return an EOF,
  1229. * just force an EOF
  1230. */
  1231. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars) = 0;
  1232. else
  1233. {
  1234. int num_to_read =
  1235. YY_CURRENT_BUFFER_LVALUE->yy_buf_size - number_to_move - 1;
  1236. while ( num_to_read <= 0 )
  1237. { /* Not enough room in the buffer - grow it. */
  1238. /* just a shorter name for the current buffer */
  1239. YY_BUFFER_STATE b = YY_CURRENT_BUFFER_LVALUE;
  1240. int yy_c_buf_p_offset =
  1241. (int) ((yy_c_buf_p) - b->yy_ch_buf);
  1242. if ( b->yy_is_our_buffer )
  1243. {
  1244. int new_size = b->yy_buf_size * 2;
  1245. if ( new_size <= 0 )
  1246. b->yy_buf_size += b->yy_buf_size / 8;
  1247. else
  1248. b->yy_buf_size *= 2;
  1249. b->yy_ch_buf = (char *)
  1250. /* Include room in for 2 EOB chars. */
  1251. yyrealloc((void *) b->yy_ch_buf,b->yy_buf_size + 2 );
  1252. }
  1253. else
  1254. /* Can't grow it, we don't own it. */
  1255. b->yy_ch_buf = NULL;
  1256. if ( ! b->yy_ch_buf )
  1257. YY_FATAL_ERROR(
  1258. "fatal error - scanner input buffer overflow" );
  1259. (yy_c_buf_p) = &b->yy_ch_buf[yy_c_buf_p_offset];
  1260. num_to_read = YY_CURRENT_BUFFER_LVALUE->yy_buf_size -
  1261. number_to_move - 1;
  1262. }
  1263. if ( num_to_read > YY_READ_BUF_SIZE )
  1264. num_to_read = YY_READ_BUF_SIZE;
  1265. /* Read in more data. */
  1266. YY_INPUT( (&YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[number_to_move]),
  1267. (yy_n_chars), num_to_read );
  1268. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1269. }
  1270. if ( (yy_n_chars) == 0 )
  1271. {
  1272. if ( number_to_move == YY_MORE_ADJ )
  1273. {
  1274. ret_val = EOB_ACT_END_OF_FILE;
  1275. yyrestart(yyin );
  1276. }
  1277. else
  1278. {
  1279. ret_val = EOB_ACT_LAST_MATCH;
  1280. YY_CURRENT_BUFFER_LVALUE->yy_buffer_status =
  1281. YY_BUFFER_EOF_PENDING;
  1282. }
  1283. }
  1284. else
  1285. ret_val = EOB_ACT_CONTINUE_SCAN;
  1286. if (((yy_n_chars) + number_to_move) > YY_CURRENT_BUFFER_LVALUE->yy_buf_size) {
  1287. /* Extend the array by 50%, plus the number we really need. */
  1288. int new_size = (yy_n_chars) + number_to_move + ((yy_n_chars) >> 1);
  1289. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf = (char *) yyrealloc((void *) YY_CURRENT_BUFFER_LVALUE->yy_ch_buf,new_size );
  1290. if ( ! YY_CURRENT_BUFFER_LVALUE->yy_ch_buf )
  1291. YY_FATAL_ERROR( "out of dynamic memory in yy_get_next_buffer()" );
  1292. }
  1293. (yy_n_chars) += number_to_move;
  1294. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] = YY_END_OF_BUFFER_CHAR;
  1295. YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars) + 1] = YY_END_OF_BUFFER_CHAR;
  1296. (yytext_ptr) = &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[0];
  1297. return ret_val;
  1298. }
  1299. /* yy_get_previous_state - get the state just before the EOB char was reached */
  1300. static yy_state_type yy_get_previous_state (void)
  1301. {
  1302. yy_state_type yy_current_state;
  1303. char *yy_cp;
  1304. yy_current_state = (yy_start);
  1305. yy_current_state += YY_AT_BOL();
  1306. for ( yy_cp = (yytext_ptr) + YY_MORE_ADJ; yy_cp < (yy_c_buf_p); ++yy_cp )
  1307. {
  1308. YY_CHAR yy_c = (*yy_cp ? yy_ec[YY_SC_TO_UI(*yy_cp)] : 1);
  1309. if ( yy_accept[yy_current_state] )
  1310. {
  1311. (yy_last_accepting_state) = yy_current_state;
  1312. (yy_last_accepting_cpos) = yy_cp;
  1313. }
  1314. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1315. {
  1316. yy_current_state = (int) yy_def[yy_current_state];
  1317. if ( yy_current_state >= 166 )
  1318. yy_c = yy_meta[(unsigned int) yy_c];
  1319. }
  1320. yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
  1321. }
  1322. return yy_current_state;
  1323. }
  1324. /* yy_try_NUL_trans - try to make a transition on the NUL character
  1325. *
  1326. * synopsis
  1327. * next_state = yy_try_NUL_trans( current_state );
  1328. */
  1329. static yy_state_type yy_try_NUL_trans (yy_state_type yy_current_state )
  1330. {
  1331. int yy_is_jam;
  1332. char *yy_cp = (yy_c_buf_p);
  1333. YY_CHAR yy_c = 1;
  1334. if ( yy_accept[yy_current_state] )
  1335. {
  1336. (yy_last_accepting_state) = yy_current_state;
  1337. (yy_last_accepting_cpos) = yy_cp;
  1338. }
  1339. while ( yy_chk[yy_base[yy_current_state] + yy_c] != yy_current_state )
  1340. {
  1341. yy_current_state = (int) yy_def[yy_current_state];
  1342. if ( yy_current_state >= 166 )
  1343. yy_c = yy_meta[(unsigned int) yy_c];
  1344. }
  1345. yy_current_state = yy_nxt[yy_base[yy_current_state] + (flex_int16_t) yy_c];
  1346. yy_is_jam = (yy_current_state == 165);
  1347. return yy_is_jam ? 0 : yy_current_state;
  1348. }
  1349. #ifndef YY_NO_UNPUT
  1350. #endif
  1351. #ifndef YY_NO_INPUT
  1352. #ifdef __cplusplus
  1353. static int yyinput (void)
  1354. #else
  1355. static int input (void)
  1356. #endif
  1357. {
  1358. int c;
  1359. *(yy_c_buf_p) = (yy_hold_char);
  1360. if ( *(yy_c_buf_p) == YY_END_OF_BUFFER_CHAR )
  1361. {
  1362. /* yy_c_buf_p now points to the character we want to return.
  1363. * If this occurs *before* the EOB characters, then it's a
  1364. * valid NUL; if not, then we've hit the end of the buffer.
  1365. */
  1366. if ( (yy_c_buf_p) < &YY_CURRENT_BUFFER_LVALUE->yy_ch_buf[(yy_n_chars)] )
  1367. /* This was really a NUL. */
  1368. *(yy_c_buf_p) = '\0';
  1369. else
  1370. { /* need more input */
  1371. int offset = (yy_c_buf_p) - (yytext_ptr);
  1372. ++(yy_c_buf_p);
  1373. switch ( yy_get_next_buffer( ) )
  1374. {
  1375. case EOB_ACT_LAST_MATCH:
  1376. /* This happens because yy_g_n_b()
  1377. * sees that we've accumulated a
  1378. * token and flags that we need to
  1379. * try matching the token before
  1380. * proceeding. But for input(),
  1381. * there's no matching to consider.
  1382. * So convert the EOB_ACT_LAST_MATCH
  1383. * to EOB_ACT_END_OF_FILE.
  1384. */
  1385. /* Reset buffer status. */
  1386. yyrestart(yyin );
  1387. /*FALLTHROUGH*/
  1388. case EOB_ACT_END_OF_FILE:
  1389. {
  1390. if ( yywrap( ) )
  1391. return 0;
  1392. if ( ! (yy_did_buffer_switch_on_eof) )
  1393. YY_NEW_FILE;
  1394. #ifdef __cplusplus
  1395. return yyinput();
  1396. #else
  1397. return input();
  1398. #endif
  1399. }
  1400. case EOB_ACT_CONTINUE_SCAN:
  1401. (yy_c_buf_p) = (yytext_ptr) + offset;
  1402. break;
  1403. }
  1404. }
  1405. }
  1406. c = *(unsigned char *) (yy_c_buf_p); /* cast for 8-bit char's */
  1407. *(yy_c_buf_p) = '\0'; /* preserve yytext */
  1408. (yy_hold_char) = *++(yy_c_buf_p);
  1409. YY_CURRENT_BUFFER_LVALUE->yy_at_bol = (c == '\n');
  1410. return c;
  1411. }
  1412. #endif /* ifndef YY_NO_INPUT */
  1413. /** Immediately switch to a different input stream.
  1414. * @param input_file A readable stream.
  1415. *
  1416. * @note This function does not reset the start condition to @c INITIAL .
  1417. */
  1418. void yyrestart (FILE * input_file )
  1419. {
  1420. if ( ! YY_CURRENT_BUFFER ){
  1421. yyensure_buffer_stack ();
  1422. YY_CURRENT_BUFFER_LVALUE =
  1423. yy_create_buffer(yyin,YY_BUF_SIZE );
  1424. }
  1425. yy_init_buffer(YY_CURRENT_BUFFER,input_file );
  1426. yy_load_buffer_state( );
  1427. }
  1428. /** Switch to a different input buffer.
  1429. * @param new_buffer The new input buffer.
  1430. *
  1431. */
  1432. void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer )
  1433. {
  1434. /* TODO. We should be able to replace this entire function body
  1435. * with
  1436. * yypop_buffer_state();
  1437. * yypush_buffer_state(new_buffer);
  1438. */
  1439. yyensure_buffer_stack ();
  1440. if ( YY_CURRENT_BUFFER == new_buffer )
  1441. return;
  1442. if ( YY_CURRENT_BUFFER )
  1443. {
  1444. /* Flush out information for old buffer. */
  1445. *(yy_c_buf_p) = (yy_hold_char);
  1446. YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
  1447. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1448. }
  1449. YY_CURRENT_BUFFER_LVALUE = new_buffer;
  1450. yy_load_buffer_state( );
  1451. /* We don't actually know whether we did this switch during
  1452. * EOF (yywrap()) processing, but the only time this flag
  1453. * is looked at is after yywrap() is called, so it's safe
  1454. * to go ahead and always set it.
  1455. */
  1456. (yy_did_buffer_switch_on_eof) = 1;
  1457. }
  1458. static void yy_load_buffer_state (void)
  1459. {
  1460. (yy_n_chars) = YY_CURRENT_BUFFER_LVALUE->yy_n_chars;
  1461. (yytext_ptr) = (yy_c_buf_p) = YY_CURRENT_BUFFER_LVALUE->yy_buf_pos;
  1462. yyin = YY_CURRENT_BUFFER_LVALUE->yy_input_file;
  1463. (yy_hold_char) = *(yy_c_buf_p);
  1464. }
  1465. /** Allocate and initialize an input buffer state.
  1466. * @param file A readable stream.
  1467. * @param size The character buffer size in bytes. When in doubt, use @c YY_BUF_SIZE.
  1468. *
  1469. * @return the allocated buffer state.
  1470. */
  1471. YY_BUFFER_STATE yy_create_buffer (FILE * file, int size )
  1472. {
  1473. YY_BUFFER_STATE b;
  1474. b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
  1475. if ( ! b )
  1476. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1477. b->yy_buf_size = (yy_size_t)size;
  1478. /* yy_ch_buf has to be 2 characters longer than the size given because
  1479. * we need to put in 2 end-of-buffer characters.
  1480. */
  1481. b->yy_ch_buf = (char *) yyalloc(b->yy_buf_size + 2 );
  1482. if ( ! b->yy_ch_buf )
  1483. YY_FATAL_ERROR( "out of dynamic memory in yy_create_buffer()" );
  1484. b->yy_is_our_buffer = 1;
  1485. yy_init_buffer(b,file );
  1486. return b;
  1487. }
  1488. /** Destroy the buffer.
  1489. * @param b a buffer created with yy_create_buffer()
  1490. *
  1491. */
  1492. void yy_delete_buffer (YY_BUFFER_STATE b )
  1493. {
  1494. if ( ! b )
  1495. return;
  1496. if ( b == YY_CURRENT_BUFFER ) /* Not sure if we should pop here. */
  1497. YY_CURRENT_BUFFER_LVALUE = (YY_BUFFER_STATE) 0;
  1498. if ( b->yy_is_our_buffer )
  1499. yyfree((void *) b->yy_ch_buf );
  1500. yyfree((void *) b );
  1501. }
  1502. /* Initializes or reinitializes a buffer.
  1503. * This function is sometimes called more than once on the same buffer,
  1504. * such as during a yyrestart() or at EOF.
  1505. */
  1506. static void yy_init_buffer (YY_BUFFER_STATE b, FILE * file )
  1507. {
  1508. int oerrno = errno;
  1509. yy_flush_buffer(b );
  1510. b->yy_input_file = file;
  1511. b->yy_fill_buffer = 1;
  1512. /* If b is the current buffer, then yy_init_buffer was _probably_
  1513. * called from yyrestart() or through yy_get_next_buffer.
  1514. * In that case, we don't want to reset the lineno or column.
  1515. */
  1516. if (b != YY_CURRENT_BUFFER){
  1517. b->yy_bs_lineno = 1;
  1518. b->yy_bs_column = 0;
  1519. }
  1520. b->yy_is_interactive = 0;
  1521. errno = oerrno;
  1522. }
  1523. /** Discard all buffered characters. On the next scan, YY_INPUT will be called.
  1524. * @param b the buffer state to be flushed, usually @c YY_CURRENT_BUFFER.
  1525. *
  1526. */
  1527. void yy_flush_buffer (YY_BUFFER_STATE b )
  1528. {
  1529. if ( ! b )
  1530. return;
  1531. b->yy_n_chars = 0;
  1532. /* We always need two end-of-buffer characters. The first causes
  1533. * a transition to the end-of-buffer state. The second causes
  1534. * a jam in that state.
  1535. */
  1536. b->yy_ch_buf[0] = YY_END_OF_BUFFER_CHAR;
  1537. b->yy_ch_buf[1] = YY_END_OF_BUFFER_CHAR;
  1538. b->yy_buf_pos = &b->yy_ch_buf[0];
  1539. b->yy_at_bol = 1;
  1540. b->yy_buffer_status = YY_BUFFER_NEW;
  1541. if ( b == YY_CURRENT_BUFFER )
  1542. yy_load_buffer_state( );
  1543. }
  1544. /** Pushes the new state onto the stack. The new state becomes
  1545. * the current state. This function will allocate the stack
  1546. * if necessary.
  1547. * @param new_buffer The new state.
  1548. *
  1549. */
  1550. void yypush_buffer_state (YY_BUFFER_STATE new_buffer )
  1551. {
  1552. if (new_buffer == NULL)
  1553. return;
  1554. yyensure_buffer_stack();
  1555. /* This block is copied from yy_switch_to_buffer. */
  1556. if ( YY_CURRENT_BUFFER )
  1557. {
  1558. /* Flush out information for old buffer. */
  1559. *(yy_c_buf_p) = (yy_hold_char);
  1560. YY_CURRENT_BUFFER_LVALUE->yy_buf_pos = (yy_c_buf_p);
  1561. YY_CURRENT_BUFFER_LVALUE->yy_n_chars = (yy_n_chars);
  1562. }
  1563. /* Only push if top exists. Otherwise, replace top. */
  1564. if (YY_CURRENT_BUFFER)
  1565. (yy_buffer_stack_top)++;
  1566. YY_CURRENT_BUFFER_LVALUE = new_buffer;
  1567. /* copied from yy_switch_to_buffer. */
  1568. yy_load_buffer_state( );
  1569. (yy_did_buffer_switch_on_eof) = 1;
  1570. }
  1571. /** Removes and deletes the top of the stack, if present.
  1572. * The next element becomes the new top.
  1573. *
  1574. */
  1575. void yypop_buffer_state (void)
  1576. {
  1577. if (!YY_CURRENT_BUFFER)
  1578. return;
  1579. yy_delete_buffer(YY_CURRENT_BUFFER );
  1580. YY_CURRENT_BUFFER_LVALUE = NULL;
  1581. if ((yy_buffer_stack_top) > 0)
  1582. --(yy_buffer_stack_top);
  1583. if (YY_CURRENT_BUFFER) {
  1584. yy_load_buffer_state( );
  1585. (yy_did_buffer_switch_on_eof) = 1;
  1586. }
  1587. }
  1588. /* Allocates the stack if it does not exist.
  1589. * Guarantees space for at least one push.
  1590. */
  1591. static void yyensure_buffer_stack (void)
  1592. {
  1593. int num_to_alloc;
  1594. if (!(yy_buffer_stack)) {
  1595. /* First allocation is just for 2 elements, since we don't know if this
  1596. * scanner will even need a stack. We use 2 instead of 1 to avoid an
  1597. * immediate realloc on the next call.
  1598. */
  1599. num_to_alloc = 1; /* After all that talk, this was set to 1 anyways... */
  1600. (yy_buffer_stack) = (struct yy_buffer_state**)yyalloc
  1601. (num_to_alloc * sizeof(struct yy_buffer_state*)
  1602. );
  1603. if ( ! (yy_buffer_stack) )
  1604. YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
  1605. memset((yy_buffer_stack), 0, num_to_alloc * sizeof(struct yy_buffer_state*));
  1606. (yy_buffer_stack_max) = num_to_alloc;
  1607. (yy_buffer_stack_top) = 0;
  1608. return;
  1609. }
  1610. if ((yy_buffer_stack_top) >= ((yy_buffer_stack_max)) - 1){
  1611. /* Increase the buffer to prepare for a possible push. */
  1612. yy_size_t grow_size = 8 /* arbitrary grow size */;
  1613. num_to_alloc = (yy_buffer_stack_max) + grow_size;
  1614. (yy_buffer_stack) = (struct yy_buffer_state**)yyrealloc
  1615. ((yy_buffer_stack),
  1616. num_to_alloc * sizeof(struct yy_buffer_state*)
  1617. );
  1618. if ( ! (yy_buffer_stack) )
  1619. YY_FATAL_ERROR( "out of dynamic memory in yyensure_buffer_stack()" );
  1620. /* zero only the new slots.*/
  1621. memset((yy_buffer_stack) + (yy_buffer_stack_max), 0, grow_size * sizeof(struct yy_buffer_state*));
  1622. (yy_buffer_stack_max) = num_to_alloc;
  1623. }
  1624. }
  1625. /** Setup the input buffer state to scan directly from a user-specified character buffer.
  1626. * @param base the character buffer
  1627. * @param size the size in bytes of the character buffer
  1628. *
  1629. * @return the newly allocated buffer state object.
  1630. */
  1631. YY_BUFFER_STATE yy_scan_buffer (char * base, yy_size_t size )
  1632. {
  1633. YY_BUFFER_STATE b;
  1634. if ( size < 2 ||
  1635. base[size-2] != YY_END_OF_BUFFER_CHAR ||
  1636. base[size-1] != YY_END_OF_BUFFER_CHAR )
  1637. /* They forgot to leave room for the EOB's. */
  1638. return NULL;
  1639. b = (YY_BUFFER_STATE) yyalloc(sizeof( struct yy_buffer_state ) );
  1640. if ( ! b )
  1641. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_buffer()" );
  1642. b->yy_buf_size = size - 2; /* "- 2" to take care of EOB's */
  1643. b->yy_buf_pos = b->yy_ch_buf = base;
  1644. b->yy_is_our_buffer = 0;
  1645. b->yy_input_file = NULL;
  1646. b->yy_n_chars = b->yy_buf_size;
  1647. b->yy_is_interactive = 0;
  1648. b->yy_at_bol = 1;
  1649. b->yy_fill_buffer = 0;
  1650. b->yy_buffer_status = YY_BUFFER_NEW;
  1651. yy_switch_to_buffer(b );
  1652. return b;
  1653. }
  1654. /** Setup the input buffer state to scan a string. The next call to yylex() will
  1655. * scan from a @e copy of @a str.
  1656. * @param yystr a NUL-terminated string to scan
  1657. *
  1658. * @return the newly allocated buffer state object.
  1659. * @note If you want to scan bytes that may contain NUL values, then use
  1660. * yy_scan_bytes() instead.
  1661. */
  1662. YY_BUFFER_STATE yy_scan_string (yyconst char * yystr )
  1663. {
  1664. return yy_scan_bytes(yystr,(int) strlen(yystr) );
  1665. }
  1666. /** Setup the input buffer state to scan the given bytes. The next call to yylex() will
  1667. * scan from a @e copy of @a bytes.
  1668. * @param yybytes the byte buffer to scan
  1669. * @param _yybytes_len the number of bytes in the buffer pointed to by @a bytes.
  1670. *
  1671. * @return the newly allocated buffer state object.
  1672. */
  1673. YY_BUFFER_STATE yy_scan_bytes (yyconst char * yybytes, int _yybytes_len )
  1674. {
  1675. YY_BUFFER_STATE b;
  1676. char *buf;
  1677. yy_size_t n;
  1678. int i;
  1679. /* Get memory for full buffer, including space for trailing EOB's. */
  1680. n = (yy_size_t) (_yybytes_len + 2);
  1681. buf = (char *) yyalloc(n );
  1682. if ( ! buf )
  1683. YY_FATAL_ERROR( "out of dynamic memory in yy_scan_bytes()" );
  1684. for ( i = 0; i < _yybytes_len; ++i )
  1685. buf[i] = yybytes[i];
  1686. buf[_yybytes_len] = buf[_yybytes_len+1] = YY_END_OF_BUFFER_CHAR;
  1687. b = yy_scan_buffer(buf,n );
  1688. if ( ! b )
  1689. YY_FATAL_ERROR( "bad buffer in yy_scan_bytes()" );
  1690. /* It's okay to grow etc. this buffer, and we should throw it
  1691. * away when we're done.
  1692. */
  1693. b->yy_is_our_buffer = 1;
  1694. return b;
  1695. }
  1696. #ifndef YY_EXIT_FAILURE
  1697. #define YY_EXIT_FAILURE 2
  1698. #endif
  1699. static void yynoreturn yy_fatal_error (yyconst char* msg )
  1700. {
  1701. (void) fprintf( stderr, "%s\n", msg );
  1702. exit( YY_EXIT_FAILURE );
  1703. }
  1704. /* Redefine yyless() so it works in section 3 code. */
  1705. #undef yyless
  1706. #define yyless(n) \
  1707. do \
  1708. { \
  1709. /* Undo effects of setting up yytext. */ \
  1710. int yyless_macro_arg = (n); \
  1711. YY_LESS_LINENO(yyless_macro_arg);\
  1712. yytext[yyleng] = (yy_hold_char); \
  1713. (yy_c_buf_p) = yytext + yyless_macro_arg; \
  1714. (yy_hold_char) = *(yy_c_buf_p); \
  1715. *(yy_c_buf_p) = '\0'; \
  1716. yyleng = yyless_macro_arg; \
  1717. } \
  1718. while ( 0 )
  1719. /* Accessor methods (get/set functions) to struct members. */
  1720. /** Get the current line number.
  1721. *
  1722. */
  1723. int yyget_lineno (void)
  1724. {
  1725. return yylineno;
  1726. }
  1727. /** Get the input stream.
  1728. *
  1729. */
  1730. FILE *yyget_in (void)
  1731. {
  1732. return yyin;
  1733. }
  1734. /** Get the output stream.
  1735. *
  1736. */
  1737. FILE *yyget_out (void)
  1738. {
  1739. return yyout;
  1740. }
  1741. /** Get the length of the current token.
  1742. *
  1743. */
  1744. int yyget_leng (void)
  1745. {
  1746. return yyleng;
  1747. }
  1748. /** Get the current token.
  1749. *
  1750. */
  1751. char *yyget_text (void)
  1752. {
  1753. return yytext;
  1754. }
  1755. /** Set the current line number.
  1756. * @param _line_number line number
  1757. *
  1758. */
  1759. void yyset_lineno (int _line_number )
  1760. {
  1761. yylineno = _line_number;
  1762. }
  1763. /** Set the input stream. This does not discard the current
  1764. * input buffer.
  1765. * @param _in_str A readable stream.
  1766. *
  1767. * @see yy_switch_to_buffer
  1768. */
  1769. void yyset_in (FILE * _in_str )
  1770. {
  1771. yyin = _in_str ;
  1772. }
  1773. void yyset_out (FILE * _out_str )
  1774. {
  1775. yyout = _out_str ;
  1776. }
  1777. int yyget_debug (void)
  1778. {
  1779. return yy_flex_debug;
  1780. }
  1781. void yyset_debug (int _bdebug )
  1782. {
  1783. yy_flex_debug = _bdebug ;
  1784. }
  1785. static int yy_init_globals (void)
  1786. {
  1787. /* Initialization is the same as for the non-reentrant scanner.
  1788. * This function is called from yylex_destroy(), so don't allocate here.
  1789. */
  1790. (yy_buffer_stack) = NULL;
  1791. (yy_buffer_stack_top) = 0;
  1792. (yy_buffer_stack_max) = 0;
  1793. (yy_c_buf_p) = NULL;
  1794. (yy_init) = 0;
  1795. (yy_start) = 0;
  1796. /* Defined in main.c */
  1797. #ifdef YY_STDINIT
  1798. yyin = stdin;
  1799. yyout = stdout;
  1800. #else
  1801. yyin = NULL;
  1802. yyout = NULL;
  1803. #endif
  1804. /* For future reference: Set errno on error, since we are called by
  1805. * yylex_init()
  1806. */
  1807. return 0;
  1808. }
  1809. /* yylex_destroy is for both reentrant and non-reentrant scanners. */
  1810. int yylex_destroy (void)
  1811. {
  1812. /* Pop the buffer stack, destroying each element. */
  1813. while(YY_CURRENT_BUFFER){
  1814. yy_delete_buffer(YY_CURRENT_BUFFER );
  1815. YY_CURRENT_BUFFER_LVALUE = NULL;
  1816. yypop_buffer_state();
  1817. }
  1818. /* Destroy the stack itself. */
  1819. yyfree((yy_buffer_stack) );
  1820. (yy_buffer_stack) = NULL;
  1821. /* Reset the globals. This is important in a non-reentrant scanner so the next time
  1822. * yylex() is called, initialization will occur. */
  1823. yy_init_globals( );
  1824. return 0;
  1825. }
  1826. /*
  1827. * Internal utility routines.
  1828. */
  1829. #ifndef yytext_ptr
  1830. static void yy_flex_strncpy (char* s1, yyconst char * s2, int n )
  1831. {
  1832. int i;
  1833. for ( i = 0; i < n; ++i )
  1834. s1[i] = s2[i];
  1835. }
  1836. #endif
  1837. #ifdef YY_NEED_STRLEN
  1838. static int yy_flex_strlen (yyconst char * s )
  1839. {
  1840. int n;
  1841. for ( n = 0; s[n]; ++n )
  1842. ;
  1843. return n;
  1844. }
  1845. #endif
  1846. void *yyalloc (yy_size_t size )
  1847. {
  1848. return malloc(size);
  1849. }
  1850. void *yyrealloc (void * ptr, yy_size_t size )
  1851. {
  1852. /* The cast to (char *) in the following accommodates both
  1853. * implementations that use char* generic pointers, and those
  1854. * that use void* generic pointers. It works with the latter
  1855. * because both ANSI C and C++ allow castless assignment from
  1856. * any pointer type to void*, and deal with argument conversions
  1857. * as though doing an assignment.
  1858. */
  1859. return realloc(ptr, size);
  1860. }
  1861. void yyfree (void * ptr )
  1862. {
  1863. free( (char *) ptr ); /* see yyrealloc() for (char *) cast */
  1864. }
  1865. #define YYTABLES_NAME "yytables"
  1866. #line 272 "dtc-lexer.l"
  1867. static void push_input_file(const char *filename)
  1868. {
  1869. assert(filename);
  1870. srcfile_push(filename);
  1871. yyin = current_srcfile->f;
  1872. yypush_buffer_state(yy_create_buffer(yyin,YY_BUF_SIZE));
  1873. }
  1874. static bool pop_input_file(void)
  1875. {
  1876. if (srcfile_pop() == 0)
  1877. return false;
  1878. yypop_buffer_state();
  1879. yyin = current_srcfile->f;
  1880. return true;
  1881. }
  1882. static void lexical_error(const char *fmt, ...)
  1883. {
  1884. va_list ap;
  1885. va_start(ap, fmt);
  1886. srcpos_verror(&yylloc, "Lexical error", fmt, ap);
  1887. va_end(ap);
  1888. treesource_error = true;
  1889. }