xref: /third_party/skia/src/sksl/lex/sksl.lex (revision cb93a386)
1// *****************
2// *** IMPORTANT ***
3// *****************
4//
5// 1. This file is only used when gn arg sksl_lex is set to true. It is used to regenerate the
6//    SkSLLexer.h and SkSLLexer.cpp files.
7// 2. Since token IDs are used to identify operators and baked into the .dehydrated.sksl files,
8//    after modifying this file it is likely everything will break until you update the dehydrated
9//    binaries. If things break after updating the lexer, set REHYDRATE in SkSLCompiler.cpp to 0,
10//    rebuild, and then set it back to 1.
11
12FLOAT_LITERAL  = [0-9]*\.[0-9]+([eE][+-]?[0-9]+)?|[0-9]+\.[0-9]*([eE][+-]?[0-9]+)?|[0-9]+([eE][+-]?[0-9]+)
13INT_LITERAL    = [0-9]+|0[xX][0-9a-fA-F]+
14TRUE_LITERAL   = "true"
15FALSE_LITERAL  = "false"
16IF             = "if"
17STATIC_IF      = "@if"
18ELSE           = "else"
19FOR            = "for"
20WHILE          = "while"
21DO             = "do"
22SWITCH         = "switch"
23STATIC_SWITCH  = "@switch"
24CASE           = "case"
25DEFAULT        = "default"
26BREAK          = "break"
27CONTINUE       = "continue"
28DISCARD        = "discard"
29RETURN         = "return"
30IN             = "in"
31OUT            = "out"
32INOUT          = "inout"
33UNIFORM        = "uniform"
34CONST          = "const"
35FLAT           = "flat"
36NOPERSPECTIVE  = "noperspective"
37INLINE         = "inline"
38NOINLINE       = "noinline"
39HASSIDEEFFECTS = "sk_has_side_effects"
40STRUCT         = "struct"
41LAYOUT         = "layout"
42HIGHP          = "highp"
43MEDIUMP        = "mediump"
44LOWP           = "lowp"
45ES3            = "$es3"
46RESERVED       = attribute|varying|precision|invariant|asm|class|union|enum|typedef|template|this|packed|goto|volatile|public|static|extern|external|interface|long|double|fixed|unsigned|superp|input|output|hvec[234]|dvec[234]|fvec[234]|sampler[12]DShadow|sampler3DRect|sampler2DRectShadow|samplerCube|sizeof|cast|namespace|using|gl_[0-9a-zA-Z_$]*
47IDENTIFIER     = [a-zA-Z_$][0-9a-zA-Z_$]*
48DIRECTIVE      = #[a-zA-Z_$][0-9a-zA-Z_$]*
49LPAREN         = "("
50RPAREN         = ")"
51LBRACE         = "{"
52RBRACE         = "}"
53LBRACKET       = "["
54RBRACKET       = "]"
55DOT            = "."
56COMMA          = ","
57PLUSPLUS       = "++"
58MINUSMINUS     = "--"
59PLUS           = "+"
60MINUS          = "-"
61STAR           = "*"
62SLASH          = "/"
63PERCENT        = "%"
64SHL            = "<<"
65SHR            = ">>"
66BITWISEOR      = "|"
67BITWISEXOR     = "^"
68BITWISEAND     = "&"
69BITWISENOT     = "~"
70LOGICALOR      = "||"
71LOGICALXOR     = "^^"
72LOGICALAND     = "&&"
73LOGICALNOT     = "!"
74QUESTION       = "?"
75COLON          = ":"
76EQ             = "="
77EQEQ           = "=="
78NEQ            = "!="
79GT             = ">"
80LT             = "<"
81GTEQ           = ">="
82LTEQ           = "<="
83PLUSEQ         = "+="
84MINUSEQ        = "-="
85STAREQ         = "*="
86SLASHEQ        = "/="
87PERCENTEQ      = "%="
88SHLEQ          = "<<="
89SHREQ          = ">>="
90BITWISEOREQ    = "|="
91BITWISEXOREQ   = "^="
92BITWISEANDEQ   = "&="
93SEMICOLON      = ";"
94ARROW          = "->"
95WHITESPACE     = \s+
96LINE_COMMENT   = //.*
97BLOCK_COMMENT  = /\*([^*]|\*[^/])*\*/
98INVALID        = .
99