summaryrefslogtreecommitdiff
path: root/source/slang/lexer.h
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2019-05-31 17:20:37 -0400
committerGitHub <noreply@github.com>2019-05-31 17:20:37 -0400
commit6cbc3929a54d37bd23cb5efa8e3320ba02f78b2f (patch)
tree5a23cb47782e9e2a77762c90dd35da1005eba8d0 /source/slang/lexer.h
parentb81ff3ef968d1cc4e954b31a1812b3c391d17b02 (diff)
Use slang- prefix on slang compiler and core source (#973)
* Prefixing source files in source/slang with slang- * Prefix source in source/slang with slang- prefix. * Rename core source files with slang- prefix. * Update project files. * Fix problems from automatic merge.
Diffstat (limited to 'source/slang/lexer.h')
-rw-r--r--source/slang/lexer.h136
1 files changed, 0 insertions, 136 deletions
diff --git a/source/slang/lexer.h b/source/slang/lexer.h
deleted file mode 100644
index 8587cc904..000000000
--- a/source/slang/lexer.h
+++ /dev/null
@@ -1,136 +0,0 @@
-#ifndef RASTER_RENDERER_LEXER_H
-#define RASTER_RENDERER_LEXER_H
-
-#include "../core/basic.h"
-#include "diagnostics.h"
-
-namespace Slang
-{
- struct NamePool;
-
- //
-
- struct TokenList
- {
- Token* begin() const;
- Token* end() const;
-
- List<Token> mTokens;
- };
-
- struct TokenSpan
- {
- TokenSpan();
- TokenSpan(
- TokenList const& tokenList)
- : mBegin(tokenList.begin())
- , mEnd (tokenList.end ())
- {}
-
- Token* begin() const { return mBegin; }
- Token* end () const { return mEnd ; }
-
- int GetCount() { return (int)(mEnd - mBegin); }
-
- Token* mBegin;
- Token* mEnd;
- };
-
- struct TokenReader
- {
- Token nextToken;
- TokenReader();
- explicit TokenReader(TokenSpan const& tokens)
- : mCursor(tokens.begin())
- , mEnd (tokens.end ())
- , nextToken(tokens.begin() ? *tokens.begin() : GetEndOfFileToken())
- {}
- explicit TokenReader(TokenList const& tokens)
- : mCursor(tokens.begin())
- , mEnd (tokens.end ())
- , nextToken(tokens.begin() ? *tokens.begin() : GetEndOfFileToken())
- {}
- struct ParsingCursor
- {
- Token nextToken;
- Token* tokenReaderCursor = nullptr;
- };
- ParsingCursor getCursor()
- {
- ParsingCursor rs;
- rs.nextToken = nextToken;
- rs.tokenReaderCursor = mCursor;
- return rs;
- }
- void setCursor(ParsingCursor cursor)
- {
- mCursor = cursor.tokenReaderCursor;
- nextToken = cursor.nextToken;
- }
- bool IsAtEnd() const { return mCursor == mEnd; }
- Token& PeekToken();
- TokenType PeekTokenType() const;
- SourceLoc PeekLoc() const;
-
- Token AdvanceToken();
-
- int GetCount() { return (int)(mEnd - mCursor); }
-
- Token* mCursor;
- Token* mEnd;
- static Token GetEndOfFileToken();
- };
-
- typedef unsigned int LexerFlags;
- enum
- {
- kLexerFlag_InDirective = 1 << 0, ///< Turn end-of-line and end-of-file into end-of-directive
- kLexerFlag_ExpectFileName = 1 << 1, ///< Support `<>` style strings for file paths
- kLexerFlag_IgnoreInvalid = 1 << 2, ///< Suppress errors about invalid/unsupported characters
- kLexerFlag_ExpectDirectiveMessage = 1 << 3, ///< Don't lexer ordinary tokens, and instead consume rest of line as a string
- };
-
- struct Lexer
- {
- void initialize(
- SourceView* sourceView,
- DiagnosticSink* sink,
- NamePool* namePool,
- MemoryArena* memoryArena);
-
- ~Lexer();
-
- Token lexToken(LexerFlags extraFlags = 0);
-
- TokenList lexAllTokens();
-
- SourceView* sourceView;
- DiagnosticSink* sink;
- NamePool* namePool;
-
- char const* cursor;
-
- char const* begin;
- char const* end;
-
- /// The starting sourceLoc (same as first location of SourceView)
- SourceLoc startLoc;
-
- TokenFlags tokenFlags;
- LexerFlags lexerFlags;
-
- MemoryArena* memoryArena;
- };
-
- // Helper routines for extracting values from tokens
- String getStringLiteralTokenValue(Token const& token);
- String getFileNameTokenValue(Token const& token);
-
- typedef int64_t IntegerLiteralValue;
- typedef double FloatingPointLiteralValue;
-
- IntegerLiteralValue getIntegerLiteralValue(Token const& token, UnownedStringSlice* outSuffix = 0);
- FloatingPointLiteralValue getFloatingPointLiteralValue(Token const& token, UnownedStringSlice* outSuffix = 0);
-}
-
-#endif