ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 1 | /* |
| 2 | |
| 3 | This file is IGNORED during the build process! |
| 4 | |
| 5 | As this file is updated so infrequently and flex is not universally present on build machines, |
| 6 | the lex.sksl.c file must be manually regenerated if you make any changes to this file. Just run: |
| 7 | |
| 8 | flex sksl.flex |
| 9 | |
| 10 | You will have to manually add a copyright notice to the top of lex.sksl.c. |
| 11 | |
| 12 | */ |
| 13 | |
| 14 | %option prefix="sksl" |
| 15 | %option reentrant |
| 16 | %option yylineno |
| 17 | %option never-interactive |
| 18 | %option nounistd |
| 19 | |
| 20 | DIGIT [0-9] |
| 21 | LETTER [a-zA-Z_$] |
| 22 | |
| 23 | %% |
| 24 | |
| 25 | {DIGIT}*"."{DIGIT}+([eE][+-]?{DIGIT}+)? { return SkSL::Token::FLOAT_LITERAL; } |
| 26 | |
| 27 | {DIGIT}+"."{DIGIT}*([eE][+-]?{DIGIT}+)? { return SkSL::Token::FLOAT_LITERAL; } |
| 28 | |
| 29 | {DIGIT}+([eE][+-]?{DIGIT}+) { return SkSL::Token::FLOAT_LITERAL; } |
| 30 | |
| 31 | {DIGIT}+ { return SkSL::Token::INT_LITERAL; } |
| 32 | |
ethannicholas | ccb1dd8 | 2016-10-11 08:47:04 -0700 | [diff] [blame] | 33 | "0x"[0-9a-fA-F]+ { return SkSL::Token::INT_LITERAL; } |
| 34 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 35 | true { return SkSL::Token::TRUE_LITERAL; } |
| 36 | |
| 37 | false { return SkSL::Token::FALSE_LITERAL; } |
| 38 | |
| 39 | if { return SkSL::Token::IF; } |
| 40 | |
| 41 | else { return SkSL::Token::ELSE; } |
| 42 | |
| 43 | for { return SkSL::Token::FOR; } |
| 44 | |
| 45 | while { return SkSL::Token::WHILE; } |
| 46 | |
| 47 | do { return SkSL::Token::DO; } |
| 48 | |
| 49 | break { return SkSL::Token::BREAK; } |
| 50 | |
| 51 | continue { return SkSL::Token::CONTINUE; } |
| 52 | |
| 53 | discard { return SkSL::Token::DISCARD; } |
| 54 | |
| 55 | return { return SkSL::Token::RETURN; } |
| 56 | |
| 57 | in { return SkSL::Token::IN; } |
| 58 | |
| 59 | out { return SkSL::Token::OUT; } |
| 60 | |
| 61 | inout { return SkSL::Token::INOUT; } |
| 62 | |
| 63 | uniform { return SkSL::Token::UNIFORM; } |
| 64 | |
| 65 | const { return SkSL::Token::CONST; } |
| 66 | |
| 67 | lowp { return SkSL::Token::LOWP; } |
| 68 | |
| 69 | mediump { return SkSL::Token::MEDIUMP; } |
| 70 | |
| 71 | highp { return SkSL::Token::HIGHP; } |
| 72 | |
ethannicholas | f789b38 | 2016-08-03 12:43:36 -0700 | [diff] [blame] | 73 | flat { return SkSL::Token::FLAT; } |
| 74 | |
| 75 | noperspective { return SkSL::Token::NOPERSPECTIVE; } |
| 76 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 77 | struct { return SkSL::Token::STRUCT; } |
| 78 | |
| 79 | layout { return SkSL::Token::LAYOUT; } |
| 80 | |
| 81 | precision { return SkSL::Token::PRECISION; } |
| 82 | |
| 83 | {LETTER}({DIGIT}|{LETTER})* { return SkSL::Token::IDENTIFIER; } |
| 84 | |
| 85 | "#"{LETTER}({DIGIT}|{LETTER})* { return SkSL::Token::DIRECTIVE; } |
| 86 | |
| 87 | "(" { return SkSL::Token::LPAREN; } |
| 88 | |
| 89 | ")" { return SkSL::Token::RPAREN; } |
| 90 | |
| 91 | "{" { return SkSL::Token::LBRACE; } |
| 92 | |
| 93 | "}" { return SkSL::Token::RBRACE; } |
| 94 | |
| 95 | "[" { return SkSL::Token::LBRACKET; } |
| 96 | |
| 97 | "]" { return SkSL::Token::RBRACKET; } |
| 98 | |
| 99 | "." { return SkSL::Token::DOT; } |
| 100 | |
| 101 | "," { return SkSL::Token::COMMA; } |
| 102 | |
| 103 | "++" { return SkSL::Token::PLUSPLUS; } |
| 104 | |
| 105 | "--" { return SkSL::Token::MINUSMINUS; } |
| 106 | |
| 107 | "+" { return SkSL::Token::PLUS; } |
| 108 | |
| 109 | "-" { return SkSL::Token::MINUS; } |
| 110 | |
| 111 | "*" { return SkSL::Token::STAR; } |
| 112 | |
| 113 | "/" { return SkSL::Token::SLASH; } |
| 114 | |
| 115 | "%" { return SkSL::Token::PERCENT; } |
| 116 | |
| 117 | "<<" { return SkSL::Token::SHL; } |
| 118 | |
| 119 | ">>" { return SkSL::Token::SHR; } |
| 120 | |
| 121 | "|" { return SkSL::Token::BITWISEOR; } |
| 122 | |
| 123 | "^" { return SkSL::Token::BITWISEXOR; } |
| 124 | |
| 125 | "&" { return SkSL::Token::BITWISEAND; } |
| 126 | |
ethannicholas | ccb1dd8 | 2016-10-11 08:47:04 -0700 | [diff] [blame] | 127 | "~" { return SkSL::Token::BITWISENOT; } |
| 128 | |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 129 | "||" { return SkSL::Token::LOGICALOR; } |
| 130 | |
| 131 | "^^" { return SkSL::Token::LOGICALXOR; } |
| 132 | |
| 133 | "&&" { return SkSL::Token::LOGICALAND; } |
| 134 | |
ethannicholas | ccb1dd8 | 2016-10-11 08:47:04 -0700 | [diff] [blame] | 135 | "!" { return SkSL::Token::LOGICALNOT; } |
ethannicholas | b3058bd | 2016-07-01 08:22:01 -0700 | [diff] [blame] | 136 | |
| 137 | "?" { return SkSL::Token::QUESTION; } |
| 138 | |
| 139 | ":" { return SkSL::Token::COLON; } |
| 140 | |
| 141 | "=" { return SkSL::Token::EQ; } |
| 142 | |
| 143 | "==" { return SkSL::Token::EQEQ; } |
| 144 | |
| 145 | "!=" { return SkSL::Token::NEQ; } |
| 146 | |
| 147 | ">" { return SkSL::Token::GT; } |
| 148 | |
| 149 | "<" { return SkSL::Token::LT; } |
| 150 | |
| 151 | ">=" { return SkSL::Token::GTEQ; } |
| 152 | |
| 153 | "<=" { return SkSL::Token::LTEQ; } |
| 154 | |
| 155 | "+=" { return SkSL::Token::PLUSEQ; } |
| 156 | |
| 157 | "-=" { return SkSL::Token::MINUSEQ; } |
| 158 | |
| 159 | "*=" { return SkSL::Token::STAREQ; } |
| 160 | |
| 161 | "/=" { return SkSL::Token::SLASHEQ; } |
| 162 | |
| 163 | "%=" { return SkSL::Token::PERCENTEQ; } |
| 164 | |
| 165 | "<<=" { return SkSL::Token::SHLEQ; } |
| 166 | |
| 167 | ">>=" { return SkSL::Token::SHREQ; } |
| 168 | |
| 169 | "|=" { return SkSL::Token::BITWISEOREQ; } |
| 170 | |
| 171 | "^=" { return SkSL::Token::BITWISEXOREQ; } |
| 172 | |
| 173 | "&=" { return SkSL::Token::BITWISEANDEQ; } |
| 174 | |
| 175 | "||=" { return SkSL::Token::LOGICALOREQ; } |
| 176 | |
| 177 | "^^=" { return SkSL::Token::LOGICALXOREQ; } |
| 178 | |
| 179 | "&&=" { return SkSL::Token::LOGICALANDEQ; } |
| 180 | |
| 181 | ";" { return SkSL::Token::SEMICOLON; } |
| 182 | |
| 183 | "//".* /* line comment */ |
| 184 | |
| 185 | "/*"([^*]|"*"[^/])*"*/" /* block comment */ |
| 186 | |
| 187 | [ \t\r\n]+ /* whitespace */ |
| 188 | |
| 189 | . { return SkSL::Token::INVALID_TOKEN; } |
| 190 | |
| 191 | %% |
| 192 | |
| 193 | int skslwrap(yyscan_t scanner) { |
| 194 | return 1; // terminate |
| 195 | } |