1848b8605Smrg%{ 2848b8605Smrg/* 3848b8605Smrg * Copyright © 2009 Intel Corporation 4848b8605Smrg * 5848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a 6848b8605Smrg * copy of this software and associated documentation files (the "Software"), 7848b8605Smrg * to deal in the Software without restriction, including without limitation 8848b8605Smrg * the rights to use, copy, modify, merge, publish, distribute, sublicense, 9848b8605Smrg * and/or sell copies of the Software, and to permit persons to whom the 10848b8605Smrg * Software is furnished to do so, subject to the following conditions: 11848b8605Smrg * 12848b8605Smrg * The above copyright notice and this permission notice (including the next 13848b8605Smrg * paragraph) shall be included in all copies or substantial portions of the 14848b8605Smrg * Software. 15848b8605Smrg * 16848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 17848b8605Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 18848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 19848b8605Smrg * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 20848b8605Smrg * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 21848b8605Smrg * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 22848b8605Smrg * DEALINGS IN THE SOFTWARE. 23848b8605Smrg */ 24b8e80941Smrg 25b8e80941Smrg#ifndef _MSC_VER 26b8e80941Smrg#include <unistd.h> 27b8e80941Smrg#endif 28b8e80941Smrg 29848b8605Smrg#include "main/glheader.h" 30848b8605Smrg#include "main/imports.h" 31848b8605Smrg#include "program/prog_instruction.h" 32848b8605Smrg#include "program/prog_statevars.h" 33848b8605Smrg#include "program/symbol_table.h" 34848b8605Smrg#include "program/program_parser.h" 35848b8605Smrg#include "program/program_parse.tab.h" 36b8e80941Smrg#include "util/strtod.h" 37848b8605Smrg 38848b8605Smrg#define require_ARB_vp (yyextra->mode == ARB_vertex) 39848b8605Smrg#define require_ARB_fp (yyextra->mode == ARB_fragment) 40848b8605Smrg#define require_shadow (yyextra->option.Shadow) 41848b8605Smrg#define require_rect (yyextra->option.TexRect) 42848b8605Smrg#define require_texarray (yyextra->option.TexArray) 43848b8605Smrg 44848b8605Smrg#ifndef HAVE_UNISTD_H 45848b8605Smrg#define YY_NO_UNISTD_H 46848b8605Smrg#endif 47848b8605Smrg 48848b8605Smrg#define return_token_or_IDENTIFIER(condition, token) \ 49848b8605Smrg do { \ 50848b8605Smrg if (condition) { \ 51848b8605Smrg return token; \ 52848b8605Smrg } else { \ 53848b8605Smrg return handle_ident(yyextra, yytext, yylval); \ 54848b8605Smrg } \ 55848b8605Smrg } while (0) 56848b8605Smrg 57848b8605Smrg#define return_token_or_DOT(condition, token) \ 58848b8605Smrg do { \ 59848b8605Smrg if (condition) { \ 60848b8605Smrg return token; \ 61848b8605Smrg } else { \ 62848b8605Smrg yyless(1); \ 63848b8605Smrg return DOT; \ 64848b8605Smrg } \ 65848b8605Smrg } while (0) 66848b8605Smrg 67848b8605Smrg 68848b8605Smrg#define return_opcode(condition, token, opcode, len) \ 69848b8605Smrg do { \ 70848b8605Smrg if (condition && \ 71848b8605Smrg _mesa_parse_instruction_suffix(yyextra, \ 72848b8605Smrg yytext + len, \ 73848b8605Smrg & yylval->temp_inst)) { \ 74848b8605Smrg yylval->temp_inst.Opcode = OPCODE_ ## opcode; \ 75848b8605Smrg return token; \ 76848b8605Smrg } else { \ 77848b8605Smrg return handle_ident(yyextra, yytext, yylval); \ 78848b8605Smrg } \ 79848b8605Smrg } while (0) 80848b8605Smrg 81848b8605Smrg#define SWIZZLE_INVAL MAKE_SWIZZLE4(SWIZZLE_NIL, SWIZZLE_NIL, \ 82848b8605Smrg SWIZZLE_NIL, SWIZZLE_NIL) 83848b8605Smrg 84848b8605Smrgstatic unsigned 85848b8605Smrgmask_from_char(char c) 86848b8605Smrg{ 87848b8605Smrg switch (c) { 88848b8605Smrg case 'x': 89848b8605Smrg case 'r': 90848b8605Smrg return WRITEMASK_X; 91848b8605Smrg case 'y': 92848b8605Smrg case 'g': 93848b8605Smrg return WRITEMASK_Y; 94848b8605Smrg case 'z': 95848b8605Smrg case 'b': 96848b8605Smrg return WRITEMASK_Z; 97848b8605Smrg case 'w': 98848b8605Smrg case 'a': 99848b8605Smrg return WRITEMASK_W; 100848b8605Smrg } 101848b8605Smrg 102848b8605Smrg return 0; 103848b8605Smrg} 104848b8605Smrg 105848b8605Smrgstatic unsigned 106848b8605Smrgswiz_from_char(char c) 107848b8605Smrg{ 108848b8605Smrg switch (c) { 109848b8605Smrg case 'x': 110848b8605Smrg case 'r': 111848b8605Smrg return SWIZZLE_X; 112848b8605Smrg case 'y': 113848b8605Smrg case 'g': 114848b8605Smrg return SWIZZLE_Y; 115848b8605Smrg case 'z': 116848b8605Smrg case 'b': 117848b8605Smrg return SWIZZLE_Z; 118848b8605Smrg case 'w': 119848b8605Smrg case 'a': 120848b8605Smrg return SWIZZLE_W; 121848b8605Smrg } 122848b8605Smrg 123848b8605Smrg return 0; 124848b8605Smrg} 125848b8605Smrg 126848b8605Smrgstatic int 127848b8605Smrghandle_ident(struct asm_parser_state *state, const char *text, YYSTYPE *lval) 128848b8605Smrg{ 129848b8605Smrg lval->string = strdup(text); 130848b8605Smrg 131b8e80941Smrg return (_mesa_symbol_table_find_symbol(state->st, text) == NULL) 132848b8605Smrg ? IDENTIFIER : USED_IDENTIFIER; 133848b8605Smrg} 134848b8605Smrg 135848b8605Smrg#define YY_USER_ACTION \ 136848b8605Smrg do { \ 137848b8605Smrg yylloc->first_column = yylloc->last_column; \ 138848b8605Smrg yylloc->last_column += yyleng; \ 139848b8605Smrg if ((yylloc->first_line == 1) \ 140848b8605Smrg && (yylloc->first_column == 1)) { \ 141848b8605Smrg yylloc->position = 1; \ 142848b8605Smrg } else { \ 143848b8605Smrg yylloc->position += yylloc->last_column - yylloc->first_column; \ 144848b8605Smrg } \ 145848b8605Smrg } while(0); 146848b8605Smrg 147848b8605Smrg#define YY_NO_INPUT 148848b8605Smrg 149848b8605Smrg/* Yes, this is intentionally doing nothing. We have this line of code 150848b8605Smrghere only to avoid the compiler complaining about an unput function 151848b8605Smrgthat is defined, but never called. */ 152848b8605Smrg#define YY_USER_INIT while (0) { unput(0); } 153848b8605Smrg 154848b8605Smrg#define YY_EXTRA_TYPE struct asm_parser_state * 155848b8605Smrg 156848b8605Smrg/* Flex defines a couple of functions with no declarations nor the 157848b8605Smrgstatic keyword. Declare them here to avoid a compiler warning. */ 158848b8605Smrgint yyget_column (yyscan_t yyscanner); 159848b8605Smrgvoid yyset_column (int column_no , yyscan_t yyscanner); 160848b8605Smrg 161848b8605Smrg%} 162848b8605Smrg 163848b8605Smrgnum [0-9]+ 164848b8605Smrgexp [Ee][-+]?[0-9]+ 165848b8605Smrgfrac "."[0-9]+ 166848b8605Smrgdot "."[ \t]* 167848b8605Smrg 168848b8605Smrgsat (_SAT)? 169848b8605Smrg 170848b8605Smrg%option prefix="_mesa_program_lexer_" 171848b8605Smrg%option bison-bridge bison-locations reentrant noyywrap 172848b8605Smrg%% 173848b8605Smrg 174848b8605Smrg"!!ARBvp1.0" { return ARBvp_10; } 175848b8605Smrg"!!ARBfp1.0" { return ARBfp_10; } 176848b8605SmrgADDRESS { 177848b8605Smrg yylval->integer = at_address; 178848b8605Smrg return_token_or_IDENTIFIER(require_ARB_vp, ADDRESS); 179848b8605Smrg} 180848b8605SmrgALIAS { return ALIAS; } 181848b8605SmrgATTRIB { return ATTRIB; } 182848b8605SmrgEND { return END; } 183848b8605SmrgOPTION { return OPTION; } 184848b8605SmrgOUTPUT { return OUTPUT; } 185848b8605SmrgPARAM { return PARAM; } 186848b8605SmrgTEMP { yylval->integer = at_temp; return TEMP; } 187848b8605Smrg 188b8e80941SmrgABS{sat} { return_opcode( 1, VECTOR_OP, ABS, 3); } 189b8e80941SmrgADD{sat} { return_opcode( 1, BIN_OP, ADD, 3); } 190848b8605SmrgARL { return_opcode(require_ARB_vp, ARL, ARL, 3); } 191848b8605Smrg 192848b8605SmrgCMP{sat} { return_opcode(require_ARB_fp, TRI_OP, CMP, 3); } 193b8e80941SmrgCOS{sat} { return_opcode(require_ARB_fp, SCALAR_OP, COS, 3); } 194848b8605Smrg 195b8e80941SmrgDP3{sat} { return_opcode( 1, BIN_OP, DP3, 3); } 196b8e80941SmrgDP4{sat} { return_opcode( 1, BIN_OP, DP4, 3); } 197b8e80941SmrgDPH{sat} { return_opcode( 1, BIN_OP, DPH, 3); } 198b8e80941SmrgDST{sat} { return_opcode( 1, BIN_OP, DST, 3); } 199848b8605Smrg 200b8e80941SmrgEX2{sat} { return_opcode( 1, SCALAR_OP, EX2, 3); } 201848b8605SmrgEXP { return_opcode(require_ARB_vp, SCALAR_OP, EXP, 3); } 202848b8605Smrg 203b8e80941SmrgFLR{sat} { return_opcode( 1, VECTOR_OP, FLR, 3); } 204b8e80941SmrgFRC{sat} { return_opcode( 1, VECTOR_OP, FRC, 3); } 205848b8605Smrg 206848b8605SmrgKIL { return_opcode(require_ARB_fp, KIL, KIL, 3); } 207848b8605Smrg 208b8e80941SmrgLIT{sat} { return_opcode( 1, VECTOR_OP, LIT, 3); } 209b8e80941SmrgLG2{sat} { return_opcode( 1, SCALAR_OP, LG2, 3); } 210848b8605SmrgLOG { return_opcode(require_ARB_vp, SCALAR_OP, LOG, 3); } 211b8e80941SmrgLRP{sat} { return_opcode(require_ARB_fp, TRI_OP, LRP, 3); } 212848b8605Smrg 213b8e80941SmrgMAD{sat} { return_opcode( 1, TRI_OP, MAD, 3); } 214b8e80941SmrgMAX{sat} { return_opcode( 1, BIN_OP, MAX, 3); } 215b8e80941SmrgMIN{sat} { return_opcode( 1, BIN_OP, MIN, 3); } 216b8e80941SmrgMOV{sat} { return_opcode( 1, VECTOR_OP, MOV, 3); } 217b8e80941SmrgMUL{sat} { return_opcode( 1, BIN_OP, MUL, 3); } 218848b8605Smrg 219b8e80941SmrgPOW{sat} { return_opcode( 1, BINSC_OP, POW, 3); } 220848b8605Smrg 221b8e80941SmrgRCP{sat} { return_opcode( 1, SCALAR_OP, RCP, 3); } 222b8e80941SmrgRSQ{sat} { return_opcode( 1, SCALAR_OP, RSQ, 3); } 223848b8605Smrg 224848b8605SmrgSCS{sat} { return_opcode(require_ARB_fp, SCALAR_OP, SCS, 3); } 225b8e80941SmrgSGE{sat} { return_opcode( 1, BIN_OP, SGE, 3); } 226b8e80941SmrgSIN{sat} { return_opcode(require_ARB_fp, SCALAR_OP, SIN, 3); } 227b8e80941SmrgSLT{sat} { return_opcode( 1, BIN_OP, SLT, 3); } 228b8e80941SmrgSUB{sat} { return_opcode( 1, BIN_OP, SUB, 3); } 229848b8605SmrgSWZ{sat} { return_opcode( 1, SWZ, SWZ, 3); } 230848b8605Smrg 231b8e80941SmrgTEX{sat} { return_opcode(require_ARB_fp, SAMPLE_OP, TEX, 3); } 232b8e80941SmrgTXB{sat} { return_opcode(require_ARB_fp, SAMPLE_OP, TXB, 3); } 233b8e80941SmrgTXP{sat} { return_opcode(require_ARB_fp, SAMPLE_OP, TXP, 3); } 234848b8605Smrg 235848b8605SmrgXPD{sat} { return_opcode( 1, BIN_OP, XPD, 3); } 236848b8605Smrg 237848b8605Smrgvertex { return_token_or_IDENTIFIER(require_ARB_vp, VERTEX); } 238848b8605Smrgfragment { return_token_or_IDENTIFIER(require_ARB_fp, FRAGMENT); } 239848b8605Smrgprogram { return PROGRAM; } 240848b8605Smrgstate { return STATE; } 241848b8605Smrgresult { return RESULT; } 242848b8605Smrg 243848b8605Smrg{dot}ambient { return AMBIENT; } 244848b8605Smrg{dot}attenuation { return ATTENUATION; } 245848b8605Smrg{dot}back { return BACK; } 246848b8605Smrg{dot}clip { return_token_or_DOT(require_ARB_vp, CLIP); } 247848b8605Smrg{dot}color { return COLOR; } 248848b8605Smrg{dot}depth { return_token_or_DOT(require_ARB_fp, DEPTH); } 249848b8605Smrg{dot}diffuse { return DIFFUSE; } 250848b8605Smrg{dot}direction { return DIRECTION; } 251848b8605Smrg{dot}emission { return EMISSION; } 252848b8605Smrg{dot}env { return ENV; } 253848b8605Smrg{dot}eye { return EYE; } 254848b8605Smrg{dot}fogcoord { return FOGCOORD; } 255848b8605Smrg{dot}fog { return FOG; } 256848b8605Smrg{dot}front { return FRONT; } 257848b8605Smrg{dot}half { return HALF; } 258848b8605Smrg{dot}inverse { return INVERSE; } 259848b8605Smrg{dot}invtrans { return INVTRANS; } 260848b8605Smrg{dot}light { return LIGHT; } 261848b8605Smrg{dot}lightmodel { return LIGHTMODEL; } 262848b8605Smrg{dot}lightprod { return LIGHTPROD; } 263848b8605Smrg{dot}local { return LOCAL; } 264848b8605Smrg{dot}material { return MATERIAL; } 265848b8605Smrg{dot}program { return MAT_PROGRAM; } 266848b8605Smrg{dot}matrix { return MATRIX; } 267848b8605Smrg{dot}matrixindex { return_token_or_DOT(require_ARB_vp, MATRIXINDEX); } 268848b8605Smrg{dot}modelview { return MODELVIEW; } 269848b8605Smrg{dot}mvp { return MVP; } 270848b8605Smrg{dot}normal { return_token_or_DOT(require_ARB_vp, NORMAL); } 271848b8605Smrg{dot}object { return OBJECT; } 272848b8605Smrg{dot}palette { return PALETTE; } 273848b8605Smrg{dot}params { return PARAMS; } 274848b8605Smrg{dot}plane { return PLANE; } 275848b8605Smrg{dot}point { return_token_or_DOT(require_ARB_vp, POINT_TOK); } 276848b8605Smrg{dot}pointsize { return_token_or_DOT(require_ARB_vp, POINTSIZE); } 277848b8605Smrg{dot}position { return POSITION; } 278848b8605Smrg{dot}primary { return PRIMARY; } 279848b8605Smrg{dot}projection { return PROJECTION; } 280848b8605Smrg{dot}range { return_token_or_DOT(require_ARB_fp, RANGE); } 281848b8605Smrg{dot}row { return ROW; } 282848b8605Smrg{dot}scenecolor { return SCENECOLOR; } 283848b8605Smrg{dot}secondary { return SECONDARY; } 284848b8605Smrg{dot}shininess { return SHININESS; } 285848b8605Smrg{dot}size { return_token_or_DOT(require_ARB_vp, SIZE_TOK); } 286848b8605Smrg{dot}specular { return SPECULAR; } 287848b8605Smrg{dot}spot { return SPOT; } 288848b8605Smrg{dot}texcoord { return TEXCOORD; } 289848b8605Smrg{dot}texenv { return_token_or_DOT(require_ARB_fp, TEXENV); } 290848b8605Smrg{dot}texgen { return_token_or_DOT(require_ARB_vp, TEXGEN); } 291848b8605Smrg{dot}q { return_token_or_DOT(require_ARB_vp, TEXGEN_Q); } 292848b8605Smrg{dot}s { return_token_or_DOT(require_ARB_vp, TEXGEN_S); } 293848b8605Smrg{dot}t { return_token_or_DOT(require_ARB_vp, TEXGEN_T); } 294848b8605Smrg{dot}texture { return TEXTURE; } 295848b8605Smrg{dot}transpose { return TRANSPOSE; } 296848b8605Smrg{dot}attrib { return_token_or_DOT(require_ARB_vp, VTXATTRIB); } 297848b8605Smrg 298848b8605Smrgtexture { return_token_or_IDENTIFIER(require_ARB_fp, TEXTURE_UNIT); } 299848b8605Smrg1D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_1D); } 300848b8605Smrg2D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_2D); } 301848b8605Smrg3D { return_token_or_IDENTIFIER(require_ARB_fp, TEX_3D); } 302848b8605SmrgCUBE { return_token_or_IDENTIFIER(require_ARB_fp, TEX_CUBE); } 303848b8605SmrgRECT { return_token_or_IDENTIFIER(require_ARB_fp && require_rect, TEX_RECT); } 304848b8605SmrgSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW1D); } 305848b8605SmrgSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow, TEX_SHADOW2D); } 306848b8605SmrgSHADOWRECT { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_rect, TEX_SHADOWRECT); } 307848b8605SmrgARRAY1D { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY1D); } 308848b8605SmrgARRAY2D { return_token_or_IDENTIFIER(require_ARB_fp && require_texarray, TEX_ARRAY2D); } 309848b8605SmrgARRAYSHADOW1D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW1D); } 310848b8605SmrgARRAYSHADOW2D { return_token_or_IDENTIFIER(require_ARB_fp && require_shadow && require_texarray, TEX_ARRAYSHADOW2D); } 311848b8605Smrg 312848b8605Smrg[_a-zA-Z$][_a-zA-Z0-9$]* { return handle_ident(yyextra, yytext, yylval); } 313848b8605Smrg 314848b8605Smrg".." { return DOT_DOT; } 315848b8605Smrg 316848b8605Smrg{num} { 317848b8605Smrg yylval->integer = strtol(yytext, NULL, 10); 318848b8605Smrg return INTEGER; 319848b8605Smrg} 320848b8605Smrg{num}?{frac}{exp}? { 321848b8605Smrg yylval->real = _mesa_strtof(yytext, NULL); 322848b8605Smrg return REAL; 323848b8605Smrg} 324848b8605Smrg{num}"."/[^.] { 325848b8605Smrg yylval->real = _mesa_strtof(yytext, NULL); 326848b8605Smrg return REAL; 327848b8605Smrg} 328848b8605Smrg{num}{exp} { 329848b8605Smrg yylval->real = _mesa_strtof(yytext, NULL); 330848b8605Smrg return REAL; 331848b8605Smrg} 332848b8605Smrg{num}"."{exp} { 333848b8605Smrg yylval->real = _mesa_strtof(yytext, NULL); 334848b8605Smrg return REAL; 335848b8605Smrg} 336848b8605Smrg 337848b8605Smrg".xyzw" { 338848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_NOOP; 339848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_XYZW; 340848b8605Smrg return MASK4; 341848b8605Smrg} 342848b8605Smrg 343848b8605Smrg".xy"[zw] { 344848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 345848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_XY 346848b8605Smrg | mask_from_char(yytext[3]); 347848b8605Smrg return MASK3; 348848b8605Smrg} 349848b8605Smrg".xzw" { 350848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 351848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_XZW; 352848b8605Smrg return MASK3; 353848b8605Smrg} 354848b8605Smrg".yzw" { 355848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 356848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_YZW; 357848b8605Smrg return MASK3; 358848b8605Smrg} 359848b8605Smrg 360848b8605Smrg".x"[yzw] { 361848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 362848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_X 363848b8605Smrg | mask_from_char(yytext[2]); 364848b8605Smrg return MASK2; 365848b8605Smrg} 366848b8605Smrg".y"[zw] { 367848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 368848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_Y 369848b8605Smrg | mask_from_char(yytext[2]); 370848b8605Smrg return MASK2; 371848b8605Smrg} 372848b8605Smrg".zw" { 373848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 374848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_ZW; 375848b8605Smrg return MASK2; 376848b8605Smrg} 377848b8605Smrg 378848b8605Smrg"."[xyzw] { 379848b8605Smrg const unsigned s = swiz_from_char(yytext[1]); 380848b8605Smrg yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); 381848b8605Smrg yylval->swiz_mask.mask = mask_from_char(yytext[1]); 382848b8605Smrg return MASK1; 383848b8605Smrg} 384848b8605Smrg 385848b8605Smrg"."[xyzw]{4} { 386848b8605Smrg yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), 387848b8605Smrg swiz_from_char(yytext[2]), 388848b8605Smrg swiz_from_char(yytext[3]), 389848b8605Smrg swiz_from_char(yytext[4])); 390848b8605Smrg yylval->swiz_mask.mask = 0; 391848b8605Smrg return SWIZZLE; 392848b8605Smrg} 393848b8605Smrg 394848b8605Smrg".rgba" { 395848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_NOOP; 396848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_XYZW; 397848b8605Smrg return_token_or_DOT(require_ARB_fp, MASK4); 398848b8605Smrg} 399848b8605Smrg 400848b8605Smrg".rg"[ba] { 401848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 402848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_XY 403848b8605Smrg | mask_from_char(yytext[3]); 404848b8605Smrg return_token_or_DOT(require_ARB_fp, MASK3); 405848b8605Smrg} 406848b8605Smrg".rba" { 407848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 408848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_XZW; 409848b8605Smrg return_token_or_DOT(require_ARB_fp, MASK3); 410848b8605Smrg} 411848b8605Smrg".gba" { 412848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 413848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_YZW; 414848b8605Smrg return_token_or_DOT(require_ARB_fp, MASK3); 415848b8605Smrg} 416848b8605Smrg 417848b8605Smrg".r"[gba] { 418848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 419848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_X 420848b8605Smrg | mask_from_char(yytext[2]); 421848b8605Smrg return_token_or_DOT(require_ARB_fp, MASK2); 422848b8605Smrg} 423848b8605Smrg".g"[ba] { 424848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 425848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_Y 426848b8605Smrg | mask_from_char(yytext[2]); 427848b8605Smrg return_token_or_DOT(require_ARB_fp, MASK2); 428848b8605Smrg} 429848b8605Smrg".ba" { 430848b8605Smrg yylval->swiz_mask.swizzle = SWIZZLE_INVAL; 431848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_ZW; 432848b8605Smrg return_token_or_DOT(require_ARB_fp, MASK2); 433848b8605Smrg} 434848b8605Smrg 435848b8605Smrg"."[gba] { 436848b8605Smrg const unsigned s = swiz_from_char(yytext[1]); 437848b8605Smrg yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(s, s, s, s); 438848b8605Smrg yylval->swiz_mask.mask = mask_from_char(yytext[1]); 439848b8605Smrg return_token_or_DOT(require_ARB_fp, MASK1); 440848b8605Smrg} 441848b8605Smrg 442848b8605Smrg 443848b8605Smrg".r" { 444848b8605Smrg if (require_ARB_vp) { 445848b8605Smrg return TEXGEN_R; 446848b8605Smrg } else { 447848b8605Smrg yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(SWIZZLE_X, SWIZZLE_X, 448848b8605Smrg SWIZZLE_X, SWIZZLE_X); 449848b8605Smrg yylval->swiz_mask.mask = WRITEMASK_X; 450848b8605Smrg return MASK1; 451848b8605Smrg } 452848b8605Smrg} 453848b8605Smrg 454848b8605Smrg"."[rgba]{4} { 455848b8605Smrg yylval->swiz_mask.swizzle = MAKE_SWIZZLE4(swiz_from_char(yytext[1]), 456848b8605Smrg swiz_from_char(yytext[2]), 457848b8605Smrg swiz_from_char(yytext[3]), 458848b8605Smrg swiz_from_char(yytext[4])); 459848b8605Smrg yylval->swiz_mask.mask = 0; 460848b8605Smrg return_token_or_DOT(require_ARB_fp, SWIZZLE); 461848b8605Smrg} 462848b8605Smrg 463848b8605Smrg"." { return DOT; } 464848b8605Smrg 465848b8605Smrg\n { 466848b8605Smrg yylloc->first_line++; 467848b8605Smrg yylloc->first_column = 1; 468848b8605Smrg yylloc->last_line++; 469848b8605Smrg yylloc->last_column = 1; 470848b8605Smrg yylloc->position++; 471848b8605Smrg} 472848b8605Smrg[ \t\r]+ /* eat whitespace */ ; 473848b8605Smrg#.*$ /* eat comments */ ; 474848b8605Smrg. { return yytext[0]; } 475848b8605Smrg%% 476848b8605Smrg 477848b8605Smrgvoid 478848b8605Smrg_mesa_program_lexer_ctor(void **scanner, struct asm_parser_state *state, 479848b8605Smrg const char *string, size_t len) 480848b8605Smrg{ 481848b8605Smrg yylex_init_extra(state, scanner); 482848b8605Smrg yy_scan_bytes(string, len, *scanner); 483848b8605Smrg} 484848b8605Smrg 485848b8605Smrgvoid 486848b8605Smrg_mesa_program_lexer_dtor(void *scanner) 487848b8605Smrg{ 488848b8605Smrg yylex_destroy(scanner); 489848b8605Smrg} 490