slang_shader.syn
来自「Mesa is an open-source implementation of」· SYN 代码 · 共 1,616 行 · 第 1/5 页
SYN
1,616 行
/* * Mesa 3-D graphics library * Version: 6.5 * * Copyright (C) 2004-2006 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), * to deal in the Software without restriction, including without limitation * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be included * in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *//* * \file slang_shader.syn * slang vertex/fragment shader syntax * \author Michal Krol *//* * usage: * syn2c slang_shader.syn > slang_shader_syn.h * * when modifying or extending this file, several things must be taken into consideration: * - when adding new operators that were marked as reserved in the initial specification, * one must only uncomment particular lines of code that refer to operators being added; * - when adding new shader target, one must reserve new value for shader_type register and * use it in .if constructs for symbols that are exclusive for that shader; * - some symbols mimic output of other symbols - the best example is the "for" construct: * expression "for (foo(); ; bar())" is seen as "for (foo(); true; bar())" by the output * processor - hence, special care must be taken when rearranging output of essential symbols; * - order of single-quoted tokens does matter in alternatives - so do not parse "<" operator * before "<<" and "<<" before "<<="; * - all double-quoted tokens are internally preprocessed to eliminate problems with parsing * strings that are prefixes of other strings, like "sampler1D" and "sampler1DShadow"; */.syntax translation_unit;/* revision number - increment after each change affecting emitted output */.emtcode REVISION 4/* external declaration (or precision or invariant stmt) */.emtcode EXTERNAL_NULL 0.emtcode EXTERNAL_FUNCTION_DEFINITION 1.emtcode EXTERNAL_DECLARATION 2.emtcode DEFAULT_PRECISION 3.emtcode INVARIANT_STMT 4/* precision */.emtcode PRECISION_DEFAULT 0.emtcode PRECISION_LOW 1.emtcode PRECISION_MEDIUM 2.emtcode PRECISION_HIGH 3/* declaration */.emtcode DECLARATION_FUNCTION_PROTOTYPE 1.emtcode DECLARATION_INIT_DECLARATOR_LIST 2/* function type */.emtcode FUNCTION_ORDINARY 0.emtcode FUNCTION_CONSTRUCTOR 1.emtcode FUNCTION_OPERATOR 2/* operator type */.emtcode OPERATOR_ADDASSIGN 1.emtcode OPERATOR_SUBASSIGN 2.emtcode OPERATOR_MULASSIGN 3.emtcode OPERATOR_DIVASSIGN 4/*.emtcode OPERATOR_MODASSIGN 5*//*.emtcode OPERATOR_LSHASSIGN 6*//*.emtcode OPERATOR_RSHASSIGN 7*//*.emtcode OPERATOR_ORASSIGN 8*//*.emtcode OPERATOR_XORASSIGN 9*//*.emtcode OPERATOR_ANDASSIGN 10*/.emtcode OPERATOR_LOGICALXOR 11/*.emtcode OPERATOR_BITOR 12*//*.emtcode OPERATOR_BITXOR 13*//*.emtcode OPERATOR_BITAND 14*/.emtcode OPERATOR_LESS 15.emtcode OPERATOR_GREATER 16.emtcode OPERATOR_LESSEQUAL 17.emtcode OPERATOR_GREATEREQUAL 18/*.emtcode OPERATOR_LSHIFT 19*//*.emtcode OPERATOR_RSHIFT 20*/.emtcode OPERATOR_MULTIPLY 21.emtcode OPERATOR_DIVIDE 22/*.emtcode OPERATOR_MODULUS 23*/.emtcode OPERATOR_INCREMENT 24.emtcode OPERATOR_DECREMENT 25.emtcode OPERATOR_PLUS 26.emtcode OPERATOR_MINUS 27/*.emtcode OPERATOR_COMPLEMENT 28*/.emtcode OPERATOR_NOT 29/* init declarator list */.emtcode DECLARATOR_NONE 0.emtcode DECLARATOR_NEXT 1/* variable declaration */.emtcode VARIABLE_NONE 0.emtcode VARIABLE_IDENTIFIER 1.emtcode VARIABLE_INITIALIZER 2.emtcode VARIABLE_ARRAY_EXPLICIT 3.emtcode VARIABLE_ARRAY_UNKNOWN 4/* type qualifier */.emtcode TYPE_QUALIFIER_NONE 0.emtcode TYPE_QUALIFIER_CONST 1.emtcode TYPE_QUALIFIER_ATTRIBUTE 2.emtcode TYPE_QUALIFIER_VARYING 3.emtcode TYPE_QUALIFIER_UNIFORM 4.emtcode TYPE_QUALIFIER_FIXEDOUTPUT 5.emtcode TYPE_QUALIFIER_FIXEDINPUT 6/* type specifier */.emtcode TYPE_SPECIFIER_VOID 0.emtcode TYPE_SPECIFIER_BOOL 1.emtcode TYPE_SPECIFIER_BVEC2 2.emtcode TYPE_SPECIFIER_BVEC3 3.emtcode TYPE_SPECIFIER_BVEC4 4.emtcode TYPE_SPECIFIER_INT 5.emtcode TYPE_SPECIFIER_IVEC2 6.emtcode TYPE_SPECIFIER_IVEC3 7.emtcode TYPE_SPECIFIER_IVEC4 8.emtcode TYPE_SPECIFIER_FLOAT 9.emtcode TYPE_SPECIFIER_VEC2 10.emtcode TYPE_SPECIFIER_VEC3 11.emtcode TYPE_SPECIFIER_VEC4 12.emtcode TYPE_SPECIFIER_MAT2 13.emtcode TYPE_SPECIFIER_MAT3 14.emtcode TYPE_SPECIFIER_MAT4 15.emtcode TYPE_SPECIFIER_SAMPLER1D 16.emtcode TYPE_SPECIFIER_SAMPLER2D 17.emtcode TYPE_SPECIFIER_SAMPLER3D 18.emtcode TYPE_SPECIFIER_SAMPLERCUBE 19.emtcode TYPE_SPECIFIER_SAMPLER1DSHADOW 20.emtcode TYPE_SPECIFIER_SAMPLER2DSHADOW 21.emtcode TYPE_SPECIFIER_SAMPLER2DRECT 22.emtcode TYPE_SPECIFIER_SAMPLER2DRECTSHADOW 23.emtcode TYPE_SPECIFIER_STRUCT 24.emtcode TYPE_SPECIFIER_TYPENAME 25/* OpenGL 2.1 */.emtcode TYPE_SPECIFIER_MAT23 26.emtcode TYPE_SPECIFIER_MAT32 27.emtcode TYPE_SPECIFIER_MAT24 28.emtcode TYPE_SPECIFIER_MAT42 29.emtcode TYPE_SPECIFIER_MAT34 30.emtcode TYPE_SPECIFIER_MAT43 31/* structure field */.emtcode FIELD_NONE 0.emtcode FIELD_NEXT 1.emtcode FIELD_ARRAY 2/* operation */.emtcode OP_END 0.emtcode OP_BLOCK_BEGIN_NO_NEW_SCOPE 1.emtcode OP_BLOCK_BEGIN_NEW_SCOPE 2.emtcode OP_DECLARE 3.emtcode OP_ASM 4.emtcode OP_BREAK 5.emtcode OP_CONTINUE 6.emtcode OP_DISCARD 7.emtcode OP_RETURN 8.emtcode OP_EXPRESSION 9.emtcode OP_IF 10.emtcode OP_WHILE 11.emtcode OP_DO 12.emtcode OP_FOR 13.emtcode OP_PUSH_VOID 14.emtcode OP_PUSH_BOOL 15.emtcode OP_PUSH_INT 16.emtcode OP_PUSH_FLOAT 17.emtcode OP_PUSH_IDENTIFIER 18.emtcode OP_SEQUENCE 19.emtcode OP_ASSIGN 20.emtcode OP_ADDASSIGN 21.emtcode OP_SUBASSIGN 22.emtcode OP_MULASSIGN 23.emtcode OP_DIVASSIGN 24/*.emtcode OP_MODASSIGN 25*//*.emtcode OP_LSHASSIGN 26*//*.emtcode OP_RSHASSIGN 27*//*.emtcode OP_ORASSIGN 28*//*.emtcode OP_XORASSIGN 29*//*.emtcode OP_ANDASSIGN 30*/.emtcode OP_SELECT 31.emtcode OP_LOGICALOR 32.emtcode OP_LOGICALXOR 33.emtcode OP_LOGICALAND 34/*.emtcode OP_BITOR 35*//*.emtcode OP_BITXOR 36*//*.emtcode OP_BITAND 37*/.emtcode OP_EQUAL 38.emtcode OP_NOTEQUAL 39.emtcode OP_LESS 40.emtcode OP_GREATER 41.emtcode OP_LESSEQUAL 42.emtcode OP_GREATEREQUAL 43/*.emtcode OP_LSHIFT 44*//*.emtcode OP_RSHIFT 45*/.emtcode OP_ADD 46.emtcode OP_SUBTRACT 47.emtcode OP_MULTIPLY 48.emtcode OP_DIVIDE 49/*.emtcode OP_MODULUS 50*/.emtcode OP_PREINCREMENT 51.emtcode OP_PREDECREMENT 52.emtcode OP_PLUS 53.emtcode OP_MINUS 54/*.emtcode OP_COMPLEMENT 55*/.emtcode OP_NOT 56.emtcode OP_SUBSCRIPT 57.emtcode OP_CALL 58.emtcode OP_FIELD 59.emtcode OP_POSTINCREMENT 60.emtcode OP_POSTDECREMENT 61/* parameter qualifier */.emtcode PARAM_QUALIFIER_IN 0.emtcode PARAM_QUALIFIER_OUT 1.emtcode PARAM_QUALIFIER_INOUT 2/* function parameter */.emtcode PARAMETER_NONE 0.emtcode PARAMETER_NEXT 1/* function parameter array presence */.emtcode PARAMETER_ARRAY_NOT_PRESENT 0.emtcode PARAMETER_ARRAY_PRESENT 1/* INVALID_EXTERNAL_DECLARATION seems to be reported when there's *//* any syntax errors... */.errtext INVALID_EXTERNAL_DECLARATION "2001: Syntax error.".errtext INVALID_OPERATOR_OVERRIDE "2002: Invalid operator override.".errtext LBRACE_EXPECTED "2003: '{' expected but '$err_token$' found.".errtext LPAREN_EXPECTED "2004: '(' expected but '$err_token$' found.".errtext RPAREN_EXPECTED "2005: ')' expected but '$err_token$' found.".errtext INVALID_PRECISION "2006: Invalid precision specifier '$err_token$'.".errtext INVALID_PRECISION_TYPE "2007: Invalid precision type '$err_token$'."/* tells whether the shader that is being parsed is a built-in shader or not *//* 0 - normal behaviour *//* 1 - accepts constructor and operator definitions and __asm statements *//* the implementation will set it to 1 when compiling internal built-in shaders */.regbyte parsing_builtin 0/* holds the type of the shader being parsed; possible values are listed below *//* FRAGMENT_SHADER 1 *//* VERTEX_SHADER 2 *//* shader type is set by the caller before parsing */.regbyte shader_type 0/* <variable_identifier> ::= <identifier>*/variable_identifier identifier .emit OP_PUSH_IDENTIFIER;/* <primary_expression> ::= <variable_identifier> | <intconstant> | <floatconstant> | <boolconstant> | "(" <expression> ")"*/primary_expression floatconstant .or boolconstant .or intconstant .or variable_identifier .or primary_expression_1;primary_expression_1 lparen .and expression .and rparen;/* <postfix_expression> ::= <primary_expression> | <postfix_expression> "[" <integer_expression> "]" | <function_call> | <postfix_expression> "." <field_selection> | <postfix_expression> "++" | <postfix_expression> "--"*/postfix_expression postfix_expression_1 .and .loop postfix_expression_2;postfix_expression_1 function_call .or primary_expression;postfix_expression_2 postfix_expression_3 .or postfix_expression_4 .or plusplus .emit OP_POSTINCREMENT .or minusminus .emit OP_POSTDECREMENT;postfix_expression_3 lbracket .and integer_expression .and rbracket .emit OP_SUBSCRIPT;postfix_expression_4 dot .and field_selection .emit OP_FIELD;/* <integer_expression> ::= <expression>*/integer_expression expression;/* <function_call> ::= <function_call_generic>*/function_call function_call_generic .emit OP_CALL .and .true .emit OP_END;/* <function_call_generic> ::= <function_call_header_with_parameters> ")" | <function_call_header_no_parameters> ")"*/function_call_generic
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?