aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/sksl/SkSLLexer.h
diff options
context:
space:
mode:
authorGravatar Ethan Nicholas <ethannicholas@google.com>2017-09-07 15:44:01 -0400
committerGravatar Skia Commit-Bot <skia-commit-bot@chromium.org>2017-09-11 16:17:00 +0000
commitc576e93d174f3106e072a2f506bca3990b541265 (patch)
treed4a410200aa71183c95643535b440bec919f2e18 /src/sksl/SkSLLexer.h
parenta2bdf005f3c706065d1aa93f319f4b73932721d4 (diff)
Switch to the new SkSL lexer.
This completely replaces flex with a new in-house lexical analyzer generator, which we have done for performance and memory usage reasons. Flex requires us to copy strings every time we need the text of a token, whereas this new lexer allows us to handle strings as a (non-null-terminated) pointer and length everywhere, eliminating most string copies. Bug: skia: Change-Id: I2add26efc9e20cb699520e82abcf713af3968aca Reviewed-on: https://skia-review.googlesource.com/39780 Reviewed-by: Brian Salomon <bsalomon@google.com> Commit-Queue: Ethan Nicholas <ethannicholas@google.com>
Diffstat (limited to 'src/sksl/SkSLLexer.h')
-rw-r--r--src/sksl/SkSLLexer.h238
1 files changed, 238 insertions, 0 deletions
diff --git a/src/sksl/SkSLLexer.h b/src/sksl/SkSLLexer.h
new file mode 100644
index 0000000000..246be22b9e
--- /dev/null
+++ b/src/sksl/SkSLLexer.h
@@ -0,0 +1,238 @@
+/*
+ * Copyright 2017 Google Inc.
+ *
+ * Use of this source code is governed by a BSD-style license that can be
+ * found in the LICENSE file.
+ */
+/*****************************************************************************************
+ ******************** This file was generated by sksllex. Do not edit. *******************
+ *****************************************************************************************/
+#ifndef SKSL_Lexer
+#define SKSL_Lexer
+#include <cstddef>
+#include <cstdint>
+namespace SkSL {
+
+struct Token {
+ enum Kind {
+#undef END_OF_FILE
+ END_OF_FILE,
+#undef FLOAT_LITERAL
+ FLOAT_LITERAL,
+#undef INT_LITERAL
+ INT_LITERAL,
+#undef TRUE_LITERAL
+ TRUE_LITERAL,
+#undef FALSE_LITERAL
+ FALSE_LITERAL,
+#undef IF
+ IF,
+#undef STATIC_IF
+ STATIC_IF,
+#undef ELSE
+ ELSE,
+#undef FOR
+ FOR,
+#undef WHILE
+ WHILE,
+#undef DO
+ DO,
+#undef SWITCH
+ SWITCH,
+#undef STATIC_SWITCH
+ STATIC_SWITCH,
+#undef CASE
+ CASE,
+#undef DEFAULT
+ DEFAULT,
+#undef BREAK
+ BREAK,
+#undef CONTINUE
+ CONTINUE,
+#undef DISCARD
+ DISCARD,
+#undef RETURN
+ RETURN,
+#undef IN
+ IN,
+#undef OUT
+ OUT,
+#undef INOUT
+ INOUT,
+#undef UNIFORM
+ UNIFORM,
+#undef CONST
+ CONST,
+#undef LOWP
+ LOWP,
+#undef MEDIUMP
+ MEDIUMP,
+#undef HIGHP
+ HIGHP,
+#undef FLAT
+ FLAT,
+#undef NOPERSPECTIVE
+ NOPERSPECTIVE,
+#undef READONLY
+ READONLY,
+#undef WRITEONLY
+ WRITEONLY,
+#undef COHERENT
+ COHERENT,
+#undef VOLATILE
+ VOLATILE,
+#undef RESTRICT
+ RESTRICT,
+#undef BUFFER
+ BUFFER,
+#undef HASSIDEEFFECTS
+ HASSIDEEFFECTS,
+#undef STRUCT
+ STRUCT,
+#undef LAYOUT
+ LAYOUT,
+#undef PRECISION
+ PRECISION,
+#undef IDENTIFIER
+ IDENTIFIER,
+#undef DIRECTIVE
+ DIRECTIVE,
+#undef SECTION
+ SECTION,
+#undef LPAREN
+ LPAREN,
+#undef RPAREN
+ RPAREN,
+#undef LBRACE
+ LBRACE,
+#undef RBRACE
+ RBRACE,
+#undef LBRACKET
+ LBRACKET,
+#undef RBRACKET
+ RBRACKET,
+#undef DOT
+ DOT,
+#undef COMMA
+ COMMA,
+#undef PLUSPLUS
+ PLUSPLUS,
+#undef MINUSMINUS
+ MINUSMINUS,
+#undef PLUS
+ PLUS,
+#undef MINUS
+ MINUS,
+#undef STAR
+ STAR,
+#undef SLASH
+ SLASH,
+#undef PERCENT
+ PERCENT,
+#undef SHL
+ SHL,
+#undef SHR
+ SHR,
+#undef BITWISEOR
+ BITWISEOR,
+#undef BITWISEXOR
+ BITWISEXOR,
+#undef BITWISEAND
+ BITWISEAND,
+#undef BITWISENOT
+ BITWISENOT,
+#undef LOGICALOR
+ LOGICALOR,
+#undef LOGICALXOR
+ LOGICALXOR,
+#undef LOGICALAND
+ LOGICALAND,
+#undef LOGICALNOT
+ LOGICALNOT,
+#undef QUESTION
+ QUESTION,
+#undef COLON
+ COLON,
+#undef EQ
+ EQ,
+#undef EQEQ
+ EQEQ,
+#undef NEQ
+ NEQ,
+#undef GT
+ GT,
+#undef LT
+ LT,
+#undef GTEQ
+ GTEQ,
+#undef LTEQ
+ LTEQ,
+#undef PLUSEQ
+ PLUSEQ,
+#undef MINUSEQ
+ MINUSEQ,
+#undef STAREQ
+ STAREQ,
+#undef SLASHEQ
+ SLASHEQ,
+#undef PERCENTEQ
+ PERCENTEQ,
+#undef SHLEQ
+ SHLEQ,
+#undef SHREQ
+ SHREQ,
+#undef BITWISEOREQ
+ BITWISEOREQ,
+#undef BITWISEXOREQ
+ BITWISEXOREQ,
+#undef BITWISEANDEQ
+ BITWISEANDEQ,
+#undef LOGICALOREQ
+ LOGICALOREQ,
+#undef LOGICALXOREQ
+ LOGICALXOREQ,
+#undef LOGICALANDEQ
+ LOGICALANDEQ,
+#undef SEMICOLON
+ SEMICOLON,
+#undef ARROW
+ ARROW,
+#undef COLONCOLON
+ COLONCOLON,
+#undef WHITESPACE
+ WHITESPACE,
+#undef LINE_COMMENT
+ LINE_COMMENT,
+#undef BLOCK_COMMENT
+ BLOCK_COMMENT,
+#undef INVALID
+ INVALID,
+ };
+
+ Token() : fKind(Kind::INVALID), fOffset(-1), fLength(-1) {}
+
+ Token(Kind kind, int offset, int length) : fKind(kind), fOffset(offset), fLength(length) {}
+
+ Kind fKind;
+ int fOffset;
+ int fLength;
+};
+
+class Lexer {
+public:
+ void start(const char* text, size_t length) {
+ fText = text;
+ fLength = length;
+ fOffset = 0;
+ }
+
+ Token next();
+
+private:
+ const char* fText;
+ int fLength;
+ int fOffset;
+};
+
+} // namespace
+#endif