Subversion Repositories Kolibri OS

Rev

Blame | Last modification | View Log | RSS feed

  1. %{
  2. /*
  3.  * Copyright © 2009 Intel Corporation
  4.  *
  5.  * Permission is hereby granted, free of charge, to any person obtaining a
  6.  * copy of this software and associated documentation files (the "Software"),
  7.  * to deal in the Software without restriction, including without limitation
  8.  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  9.  * and/or sell copies of the Software, and to permit persons to whom the
  10.  * Software is furnished to do so, subject to the following conditions:
  11.  *
  12.  * The above copyright notice and this permission notice (including the next
  13.  * paragraph) shall be included in all copies or substantial portions of the
  14.  * Software.
  15.  *
  16.  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  17.  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  18.  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
  19.  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  20.  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
  21.  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
  22.  * DEALINGS IN THE SOFTWARE.
  23.  */
  24. #include "main/glheader.h"
  25. #include "main/imports.h"
  26. #include "program/prog_instruction.h"
  27. #include "program/prog_statevars.h"
  28. #include "program/symbol_table.h"
  29. #include "program/program_parser.h"
  30. #include "program/program_parse.tab.h"
  31. #include "util/strtod.h"
  32.  
  33. #define require_ARB_vp (yyextra->mode == ARB_vertex)
  34. #define require_ARB_fp (yyextra->mode == ARB_fragment)
  35. #define require_NV_fp  (yyextra->option.NV_fragment)
  36. #define require_shadow (yyextra->option.Shadow)
  37. #define require_rect   (yyextra->option.TexRect)
  38. #define require_texarray        (yyextra->option.TexArray)
  39.  
  40. #ifndef HAVE_UNISTD_H
  41. #define YY_NO_UNISTD_H
  42. #endif
  43.  
  44. #define return_token_or_IDENTIFIER(condition, token)    \
  45.    do {                                                 \
  46.       if (condition) {                                  \
  47.          return token;                                  \
  48.       } else {                                          \
  49.          return handle_ident(yyextra, yytext, yylval);  \
  50.       }                                                 \
  51.    } while (0)
  52.  
  53. #define return_token_or_DOT(condition, token)           \
  54.    do {                                                 \
  55.       if (condition) {                                  \
  56.          return token;                                  \
  57.       } else {                                          \
  58.          yyless(1);                                     \
  59.          return DOT;                                    \
  60.       }                                                 \
  61.    } while (0)
  62.  
  63.  
  64. #define return_opcode(condition, token, opcode, len)    \
  65.    do {                                                 \
  66.       if (condition &&                                  \
  67.           _mesa_parse_instruction_suffix(yyextra,       \
  68.                                          yytext + len,  \
  69.                                          & yylval->temp_inst)) {        \
  70.          yylval->temp_inst.Opcode = OPCODE_ ## opcode;  \
  71.          return token;                                  \
  72.       } else {                                          \
  73.          return handle_ident(yyextra, yytext, yylval);  \
  74.       }                                                 \
  75.    } while (0)
  76.  
  77. #define SWIZZLE_INVAL  MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \
  78.                                      SWIZZLE_NIL, SWIZZLE_NIL)
  79.  
  80. static unsigned
  81. mask_from_char(char c)
  82. {
  83.    switch (c) {
  84.    case 'x':
  85.    case 'r':
  86.       return WRITEMASK_X;
  87.    case 'y':
  88.    case 'g':
  89.       return WRITEMASK_Y;
  90.    case 'z':
  91.    case 'b':
  92.       return WRITEMASK_Z;
  93.    case 'w':
  94.    case 'a':
  95.       return WRITEMASK_W;
  96.    }
  97.  
  98.    return 0;
  99. }
  100.  
  101. static unsigned
  102. swiz_from_char(char c)
  103. {
  104.    switch (c) {
  105.    case 'x':
  106.    case 'r':
  107.       return SWIZZLE_X;
  108.    case 'y':
  109.    case 'g':
  110.       return SWIZZLE_Y;
  111.    case 'z':
  112.    case 'b':
  113.       return SWIZZLE_Z;
  114.    case 'w':
  115.    case 'a':
  116.       return SWIZZLE_W;
  117.    }
  118.  
  119.    return 0;
  120. }
  121.  
  122. static int
  123. handle_ident(struct asm_parser_state *state, const char *text, YYSTYPE *lval)
  124. {
  125.    lval->string = strdup(text);
  126.  
  127.    return (_mesa_symbol_table_find_symbol(state->st, 0, text) == NULL)
  128.       ? IDENTIFIER : USED_IDENTIFIER;
  129. }
  130.  
  131. #define YY_USER_ACTION                                                  \
  132.    do {                                                                 \
  133.       yylloc->first_column = yylloc->last_column;                       \
  134.       yylloc->last_column += yyleng;                                    \
  135.       if ((yylloc->first_line == 1)                                     \
  136.           && (yylloc->first_column == 1)) {                             \
  137.          yylloc->position = 1;                                          \
  138.       } else {                                                          \
  139.          yylloc->position += yylloc->last_column - yylloc->first_column; \
  140.       }                                                                 \
  141.    } while(0);
  142.  
  143. #define YY_NO_INPUT
  144.  
  145. /* Yes, this is intentionally doing nothing. We have this line of code
  146. here only to avoid the compiler complaining about an unput function
  147. that is defined, but never called. */
  148. #define YY_USER_INIT while (0) { unput(0); }
  149.  
  150. #define YY_EXTRA_TYPE struct asm_parser_state *
  151.  
  152. /* Flex defines a couple of functions with no declarations nor the
  153. static keyword. Declare them here to avoid a compiler warning. */
  154. int yyget_column  (yyscan_t yyscanner);
  155. void yyset_column (int  column_no , yyscan_t yyscanner);
  156.  
  157. %}
  158.  
  159. num    [0-9]+
  160. exp    [Ee][-+]?[0-9]+
  161. frac   "."[0-9]+
  162. dot    "."[ \t]*
  163.  
  164. sz     [HRX]?
  165. szf    [HR]?
  166. cc     C?
  167. sat    (_SAT)?
  168.  
  169. %option prefix="_mesa_program_lexer_"
  170. %option bison-bridge bison-locations reentrant noyywrap
  171. %%
  172.  
  173. "!!ARBvp1.0"              { return ARBvp_10; }
  174. "!!ARBfp1.0"              { return ARBfp_10; }
  175. ADDRESS                   {
  176.    yylval->integer = at_address;
  177.    return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS);
  178. }
  179. ALIAS                     { return ALIAS; }
  180. ATTRIB                    { return ATTRIB; }
  181. END                       { return END; }
  182. OPTION                    { return OPTION; }
  183. OUTPUT                    { return OUTPUT; }
  184. PARAM                     { return PARAM; }
  185. TEMP                      { yylval->integer = at_temp; return TEMP; }
  186.  
  187. ABS{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, ABS, 3); }
  188. ADD{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, ADD, 3); }
  189. ARL                { return_opcode(require_ARB_vp, ARL, ARL, 3); }
  190.  
  191. CMP{sat}           { return_opcode(require_ARB_fp, TRI_OP, CMP, 3); }
  192. COS{szf}{cc}{sat}  { return_opcode(require_ARB_fp, SCALAR_OP, COS, 3); }
  193.  
  194. DDX{szf}{cc}{sat}  { return_opcode(require_NV_fp,  VECTOR_OP, DDX, 3); }
  195. DDY{szf}{cc}{sat}  { return_opcode(require_NV_fp,  VECTOR_OP, DDY, 3); }
  196. DP3{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, DP3, 3); }
  197. DP4{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, DP4, 3); }
  198. DPH{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, DPH, 3); }
  199. DST{szf}{cc}{sat}  { return_opcode(             1, BIN_OP, DST, 3); }
  200.  
  201. EX2{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, EX2, 3); }
  202. EXP                { return_opcode(require_ARB_vp, SCALAR_OP, EXP, 3); }
  203.  
  204. FLR{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, FLR, 3); }
  205. FRC{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, FRC, 3); }
  206.  
  207. KIL                { return_opcode(require_ARB_fp, KIL, KIL, 3); }
  208.  
  209. LIT{szf}{cc}{sat}  { return_opcode(             1, VECTOR_OP, LIT, 3); }
  210. LG2{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, LG2, 3); }
  211. LOG                { return_opcode(require_ARB_vp, SCALAR_OP, LOG, 3); }
  212. LRP{sz}{cc}{sat}   { return_opcode(require_ARB_fp, TRI_OP, LRP, 3); }
  213.  
  214. MAD{sz}{cc}{sat}   { return_opcode(             1, TRI_OP, MAD, 3); }
  215. MAX{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, MAX, 3); }
  216. MIN{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, MIN, 3); }
  217. MOV{sz}{cc}{sat}   { return_opcode(             1, VECTOR_OP, MOV, 3); }
  218. MUL{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, MUL, 3); }
  219.  
  220. POW{szf}{cc}{sat}  { return_opcode(             1, BINSC_OP, POW, 3); }
  221.  
  222. RCP{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, RCP, 3); }
  223. RSQ{szf}{cc}{sat}  { return_opcode(             1, SCALAR_OP, RSQ, 3); }
  224.  
  225. SCS{sat}           { return_opcode(require_ARB_fp, SCALAR_OP, SCS, 3); }
  226. SEQ{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SEQ, 3); }
  227. SGE{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SGE, 3); }
  228. SGT{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SGT, 3); }
  229. SIN{szf}{cc}{sat}  { return_opcode(require_ARB_fp, SCALAR_OP, SIN, 3); }
  230. SLE{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SLE, 3); }
  231. SLT{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SLT, 3); }
  232. SNE{sz}{cc}{sat}   { return_opcode(require_NV_fp,  BIN_OP, SNE, 3); }
  233. SUB{sz}{cc}{sat}   { return_opcode(             1, BIN_OP, SUB, 3); }
  234. SWZ{sat}           { return_opcode(             1, SWZ, SWZ, 3); }
  235.  
  236. TEX{cc}{sat}       { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, 3); }
  237. TXB{cc}{sat}       { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, 3); }
  238. TXD{cc}{sat}       { return_opcode(require_NV_fp,  TXD_OP, TXD, 3); }
  239. TXP{cc}{sat}       { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, 3); }
  240.  
  241. XPD{sat}           { return_opcode(             1, BIN_OP, XPD, 3); }
  242.  
  243. vertex                    { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); }
  244. fragment                  { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); }
  245. program                   { return PROGRAM; }
  246. state                     { return STATE; }
  247. result                    { return RESULT; }
  248.  
  249. {dot}ambient              { return AMBIENT; }
  250. {dot}attenuation          { return ATTENUATION; }
  251. {dot}back                 { return BACK; }
  252. {dot}clip                 { return_token_or_DOT(require_ARB_vp, CLIP); }
  253. {dot}color                { return COLOR; }
  254. {dot}depth                { return_token_or_DOT(require_ARB_fp, DEPTH); }
  255. {dot}diffuse              { return DIFFUSE; }
  256. {dot}direction            { return DIRECTION; }
  257. {dot}emission             { return EMISSION; }
  258. {dot}env                  { return ENV; }
  259. {dot}eye                  { return EYE; }
  260. {dot}fogcoord             { return FOGCOORD; }
  261. {dot}fog                  { return FOG; }
  262. {dot}front                { return FRONT; }
  263. {dot}half                 { return HALF; }
  264. {dot}inverse              { return INVERSE; }
  265. {dot}invtrans             { return INVTRANS; }
  266. {dot}light                { return LIGHT; }
  267. {dot}lightmodel           { return LIGHTMODEL; }
  268. {dot}lightprod            { return LIGHTPROD; }
  269. {dot}local                { return LOCAL; }
  270. {dot}material             { return MATERIAL; }
  271. {dot}program              { return MAT_PROGRAM; }
  272. {dot}matrix               { return MATRIX; }
  273. {dot}matrixindex          { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); }
  274. {dot}modelview            { return MODELVIEW; }
  275. {dot}mvp                  { return MVP; }
  276. {dot}normal               { return_token_or_DOT(require_ARB_vp, NORMAL); }
  277. {dot}object               { return OBJECT; }
  278. {dot}palette              { return PALETTE; }
  279. {dot}params               { return PARAMS; }
  280. {dot}plane                { return PLANE; }
  281. {dot}point                { return_token_or_DOT(require_ARB_vp, POINT_TOK); }
  282. {dot}pointsize            { return_token_or_DOT(require_ARB_vp, POINTSIZE); }
  283. {dot}position             { return POSITION; }
  284. {dot}primary              { return PRIMARY; }
  285. {dot}projection           { return PROJECTION; }
  286. {dot}range                { return_token_or_DOT(require_ARB_fp, RANGE); }
  287. {dot}row                  { return ROW; }
  288. {dot}scenecolor           { return SCENECOLOR; }
  289. {dot}secondary            { return SECONDARY; }
  290. {dot}shininess            { return SHININESS; }
  291. {dot}size                 { return_token_or_DOT(require_ARB_vp, SIZE_TOK); }
  292. {dot}specular             { return SPECULAR; }
  293. {dot}spot                 { return SPOT; }
  294. {dot}texcoord             { return TEXCOORD; }
  295. {dot}texenv               { return_token_or_DOT(require_ARB_fp, TEXENV); }
  296. {dot}texgen               { return_token_or_DOT(require_ARB_vp, TEXGEN); }
  297. {dot}q                    { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); }
  298. {dot}s                    { return_token_or_DOT(require_ARB_vp, TEXGEN_S); }
  299. {dot}t                    { return_token_or_DOT(require_ARB_vp, TEXGEN_T); }
  300. {dot}texture              { return TEXTURE; }
  301. {dot}transpose            { return TRANSPOSE; }
  302. {dot}attrib               { return_token_or_DOT(require_ARB_vp, VTXATTRIB); }
  303. {dot}weight               { return_token_or_DOT(require_ARB_vp, WEIGHT); }
  304.  
  305. texture                   { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); }
  306. 1D                        { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); }
  307. 2D                        { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); }
  308. 3D                        { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); }
  309. CUBE                      { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); }
  310. RECT                      { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); }
  311. SHADOW1D                  { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); }
  312. SHADOW2D                  { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); }
  313. SHADOWRECT                { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); }
  314. ARRAY1D                   { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); }
  315. ARRAY2D                   { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); }
  316. ARRAYSHADOW1D             { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); }
  317. ARRAYSHADOW2D             { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); }
  318.  
  319. [_a-zA-Z$][_a-zA-Z0-9$]*  { return handle_ident(yyextra, yytext, yylval); }
  320.  
  321. ".."                      { return DOT_DOT; }
  322.  
  323. {num}                     {
  324.    yylval->integer = strtol(yytext, NULL, 10);
  325.    return INTEGER;
  326. }
  327. {num}?{frac}{exp}?        {
  328.    yylval->real = _mesa_strtof(yytext, NULL);
  329.    return REAL;
  330. }
  331. {num}"."/[^.]             {
  332.    yylval->real = _mesa_strtof(yytext, NULL);
  333.    return REAL;
  334. }
  335. {num}{exp}                {
  336.    yylval->real = _mesa_strtof(yytext, NULL);
  337.    return REAL;
  338. }
  339. {num}"."{exp}             {
  340.    yylval->real = _mesa_strtof(yytext, NULL);
  341.    return REAL;
  342. }
  343.  
  344. ".xyzw"                   {
  345.    yylval->swiz_mask.swizzle = SWIZZLE_NOOP;
  346.    yylval->swiz_mask.mask = WRITEMASK_XYZW;
  347.    return MASK4;
  348. }
  349.  
  350. ".xy"[zw]                 {
  351.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  352.    yylval->swiz_mask.mask = WRITEMASK_XY
  353.       | mask_from_char(yytext[3]);
  354.    return MASK3;
  355. }
  356. ".xzw"                    {
  357.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  358.    yylval->swiz_mask.mask = WRITEMASK_XZW;
  359.    return MASK3;
  360. }
  361. ".yzw"                    {
  362.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  363.    yylval->swiz_mask.mask = WRITEMASK_YZW;
  364.    return MASK3;
  365. }
  366.  
  367. ".x"[yzw]                 {
  368.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  369.    yylval->swiz_mask.mask = WRITEMASK_X
  370.       | mask_from_char(yytext[2]);
  371.    return MASK2;
  372. }
  373. ".y"[zw]                  {
  374.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  375.    yylval->swiz_mask.mask = WRITEMASK_Y
  376.       | mask_from_char(yytext[2]);
  377.    return MASK2;
  378. }
  379. ".zw"                     {
  380.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  381.    yylval->swiz_mask.mask = WRITEMASK_ZW;
  382.    return MASK2;
  383. }
  384.  
  385. "."[xyzw]                 {
  386.    const unsigned s = swiz_from_char(yytext[1]);
  387.    yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s);
  388.    yylval->swiz_mask.mask = mask_from_char(yytext[1]);
  389.    return MASK1;
  390. }
  391.  
  392. "."[xyzw]{4}              {
  393.    yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]),
  394.                                             swiz_from_char(yytext[2]),
  395.                                             swiz_from_char(yytext[3]),
  396.                                             swiz_from_char(yytext[4]));
  397.    yylval->swiz_mask.mask = 0;
  398.    return SWIZZLE;
  399. }
  400.  
  401. ".rgba"                   {
  402.    yylval->swiz_mask.swizzle = SWIZZLE_NOOP;
  403.    yylval->swiz_mask.mask = WRITEMASK_XYZW;
  404.    return_token_or_DOT(require_ARB_fp, MASK4);
  405. }
  406.  
  407. ".rg"[ba]                 {
  408.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  409.    yylval->swiz_mask.mask = WRITEMASK_XY
  410.       | mask_from_char(yytext[3]);
  411.    return_token_or_DOT(require_ARB_fp, MASK3);
  412. }
  413. ".rba"                    {
  414.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  415.    yylval->swiz_mask.mask = WRITEMASK_XZW;
  416.    return_token_or_DOT(require_ARB_fp, MASK3);
  417. }
  418. ".gba"                    {
  419.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  420.    yylval->swiz_mask.mask = WRITEMASK_YZW;
  421.    return_token_or_DOT(require_ARB_fp, MASK3);
  422. }
  423.  
  424. ".r"[gba]                 {
  425.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  426.    yylval->swiz_mask.mask = WRITEMASK_X
  427.       | mask_from_char(yytext[2]);
  428.    return_token_or_DOT(require_ARB_fp, MASK2);
  429. }
  430. ".g"[ba]                  {
  431.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  432.    yylval->swiz_mask.mask = WRITEMASK_Y
  433.       | mask_from_char(yytext[2]);
  434.    return_token_or_DOT(require_ARB_fp, MASK2);
  435. }
  436. ".ba"                     {
  437.    yylval->swiz_mask.swizzle = SWIZZLE_INVAL;
  438.    yylval->swiz_mask.mask = WRITEMASK_ZW;
  439.    return_token_or_DOT(require_ARB_fp, MASK2);
  440. }
  441.  
  442. "."[gba]                  {
  443.    const unsigned s = swiz_from_char(yytext[1]);
  444.    yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s);
  445.    yylval->swiz_mask.mask = mask_from_char(yytext[1]);
  446.    return_token_or_DOT(require_ARB_fp, MASK1);
  447. }
  448.  
  449.  
  450. ".r"                      {
  451.    if (require_ARB_vp) {
  452.       return TEXGEN_R;
  453.    } else {
  454.       yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X,
  455.                                                 SWIZZLE_X, SWIZZLE_X);
  456.       yylval->swiz_mask.mask = WRITEMASK_X;
  457.       return MASK1;
  458.    }
  459. }
  460.  
  461. "."[rgba]{4}              {
  462.    yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]),
  463.                                             swiz_from_char(yytext[2]),
  464.                                             swiz_from_char(yytext[3]),
  465.                                             swiz_from_char(yytext[4]));
  466.    yylval->swiz_mask.mask = 0;
  467.    return_token_or_DOT(require_ARB_fp, SWIZZLE);
  468. }
  469.  
  470. "."                       { return DOT; }
  471.  
  472. \n                        {
  473.    yylloc->first_line++;
  474.    yylloc->first_column = 1;
  475.    yylloc->last_line++;
  476.    yylloc->last_column = 1;
  477.    yylloc->position++;
  478. }
  479. [ \t\r]+                  /* eat whitespace */ ;
  480. #.*$                      /* eat comments */ ;
  481. .                         { return yytext[0]; }
  482. %%
  483.  
  484. void
  485. _mesa_program_lexer_ctor(void **scanner, struct asm_parser_state *state,
  486.                          const char *string, size_t len)
  487. {
  488.    yylex_init_extra(state, scanner);
  489.    yy_scan_bytes(string, len, *scanner);
  490. }
  491.  
  492. void
  493. _mesa_program_lexer_dtor(void *scanner)
  494. {
  495.    yylex_destroy(scanner);
  496. }
  497.