Path: blob/master/dep/reshadefx/include/effect_token.hpp
4246 views
/*1* Copyright (C) 2014 Patrick Mours2* SPDX-License-Identifier: BSD-3-Clause3*/45#pragma once67#include <cstdint>8#include <string>9#include <vector>10#include <cstdint>1112namespace reshadefx13{14/// <summary>15/// Structure which keeps track of a code location.16/// </summary>17struct location18{19location() : line(1), column(1) {}20explicit location(uint32_t line, uint32_t column = 1) : line(line), column(column) {}21explicit location(std::string source, uint32_t line, uint32_t column = 1) : source(std::move(source)), line(line), column(column) {}2223std::string source;24uint32_t line, column;25};2627/// <summary>28/// A collection of identifiers for various possible tokens.29/// </summary>30enum class tokenid31{32unknown = -1,33end_of_file = 0,34end_of_line = '\n',3536// operators37space = ' ',38exclaim = '!',39hash = '#',40dollar = '$',41percent = '%',42ampersand = '&',43parenthesis_open = '(',44parenthesis_close = ')',45star = '*',46plus = '+',47comma = ',',48minus = '-',49dot = '.',50slash = '/',51colon = ':',52semicolon = ';',53less = '<',54equal = '=',55greater = '>',56question = '?',57at = '@',58bracket_open = '[',59backslash = '\\',60bracket_close = ']',61caret = '^',62brace_open = '{',63pipe = '|',64brace_close = '}',65tilde = '~',66exclaim_equal = 256 /* != */,67percent_equal /* %= */,68ampersand_ampersand /* && */,69ampersand_equal /* &= */,70star_equal /* *= */,71plus_plus /* ++*/,72plus_equal /* += */,73minus_minus /* -- */,74minus_equal /* -= */,75arrow /* -> */,76ellipsis /* ... */,77slash_equal /* /= */,78colon_colon /* :: */,79less_less_equal /* <<= */,80less_less /* << */,81less_equal /* <= */,82equal_equal /* == */,83greater_greater_equal /* >>= */,84greater_greater /* >> */,85greater_equal /* >= */,86caret_equal /* ^= */,87pipe_equal /* |= */,88pipe_pipe /* || */,8990// identifiers91reserved,92identifier,9394// literals95true_literal,96false_literal,97int_literal,98uint_literal,99float_literal,100double_literal,101string_literal,102103// keywords104namespace_,105struct_,106technique,107pass,108for_,109while_,110do_,111if_,112else_,113switch_,114case_,115default_,116break_,117continue_,118return_,119discard_,120extern_,121static_,122uniform_,123volatile_,124precise,125groupshared,126in,127out,128inout,129const_,130linear,131noperspective,132centroid,133nointerpolation,134135void_,136bool_,137bool2,138bool3,139bool4,140bool2x2,141bool2x3,142bool2x4,143bool3x2,144bool3x3,145bool3x4,146bool4x2,147bool4x3,148bool4x4,149int_,150int2,151int3,152int4,153int2x2,154int2x3,155int2x4,156int3x2,157int3x3,158int3x4,159int4x2,160int4x3,161int4x4,162min16int,163min16int2,164min16int3,165min16int4,166uint_,167uint2,168uint3,169uint4,170uint2x2,171uint2x3,172uint2x4,173uint3x2,174uint3x3,175uint3x4,176uint4x2,177uint4x3,178uint4x4,179min16uint,180min16uint2,181min16uint3,182min16uint4,183float_,184float2,185float3,186float4,187float2x2,188float2x3,189float2x4,190float3x2,191float3x3,192float3x4,193float4x2,194float4x3,195float4x4,196min16float,197min16float2,198min16float3,199min16float4,200vector,201matrix,202string_,203texture1d,204texture2d,205texture3d,206sampler1d,207sampler2d,208sampler3d,209storage1d,210storage2d,211storage3d,212213// preprocessor directives214hash_def,215hash_undef,216hash_if,217hash_ifdef,218hash_ifndef,219hash_else,220hash_elif,221hash_endif,222hash_error,223hash_warning,224hash_pragma,225hash_include,226hash_unknown,227228single_line_comment,229multi_line_comment,230};231232/// <summary>233/// A structure describing a single token in the input string.234/// </summary>235struct token236{237tokenid id;238reshadefx::location location;239size_t offset, length;240union241{242int literal_as_int;243unsigned int literal_as_uint;244float literal_as_float;245double literal_as_double;246};247std::string literal_as_string;248249operator tokenid() const { return id; }250251static std::string id_to_name(tokenid id);252};253}254255256