VapourSynth-llvmexpr
Loading...
Searching...
No Matches
infix2postfix::preprocessor_detail Namespace Reference

Classes

struct  Token
class  PreprocessorTokenizer

Enumerations

enum class  TokenType : std::uint8_t {
  Identifier , Number , Plus , Minus ,
  Multiply , Divide , Modulo , Power ,
  Equal , NotEqual , Greater , GreaterEqual ,
  Less , LessEqual , LogicalAnd , LogicalOr ,
  LogicalNot , BitAnd , BitOr , BitXor ,
  BitNot , Lparen , Rparen , Lbracket ,
  Rbracket , Lbrace , Rbrace , Comma ,
  Dot , Question , Colon , Semicolon ,
  Assign , AtDefine , AtUndef , AtIfdef ,
  AtIfndef , AtIf , AtElse , AtEndif ,
  AtError , AtRequires , At , Whitespace ,
  Newline , Comment , EndOfFile , Concat ,
  BeginMacroExpansion , EndMacroExpansion
}

Functions

std::string tokensToString (const std::vector< Token > &tokens, bool preserve_whitespace=false)
std::vector< TokentrimTokens (const std::vector< Token > &tokens)
bool isSkippable (const Token &t)

Enumeration Type Documentation

◆ TokenType

enum class infix2postfix::preprocessor_detail::TokenType : std::uint8_t
strong
Enumerator
Identifier 
Number 
Plus 
Minus 
Multiply 
Divide 
Modulo 
Power 
Equal 
NotEqual 
Greater 
GreaterEqual 
Less 
LessEqual 
LogicalAnd 
LogicalOr 
LogicalNot 
BitAnd 
BitOr 
BitXor 
BitNot 
Lparen 
Rparen 
Lbracket 
Rbracket 
Lbrace 
Rbrace 
Comma 
Dot 
Question 
Colon 
Semicolon 
Assign 
AtDefine 
AtUndef 
AtIfdef 
AtIfndef 
AtIf 
AtElse 
AtEndif 
AtError 
AtRequires 
At 
Whitespace 
Newline 
Comment 
EndOfFile 
Concat 
BeginMacroExpansion 
EndMacroExpansion 

Definition at line 42 of file Preprocessor.cpp.

42 : std::uint8_t {
44 Number,
45 Plus,
46 Minus,
48 Divide,
49 Modulo,
50 Power,
51 Equal,
53 Greater,
55 Less,
60 BitAnd,
61 BitOr,
62 BitXor,
63 BitNot,
64 Lparen,
65 Rparen,
68 Lbrace,
69 Rbrace,
70 Comma,
71 Dot,
73 Colon,
75 Assign,
77 AtUndef,
78 AtIfdef,
80 AtIf,
81 AtElse,
82 AtEndif,
83 AtError,
85 At,
87 Newline,
88 Comment,
90 Concat,
93};

Function Documentation

◆ isSkippable()

bool infix2postfix::preprocessor_detail::isSkippable ( const Token & t)

Definition at line 476 of file Preprocessor.cpp.

476 {
477 return t.type == TokenType::Whitespace || t.type == TokenType::Comment ||
478 t.type == TokenType::BeginMacroExpansion ||
479 t.type == TokenType::EndMacroExpansion;
480}

References infix2postfix::preprocessor_detail::Token::type.

Referenced by infix2postfix::preprocessor::TokenStream::skipWhitespace().

◆ tokensToString()

std::string infix2postfix::preprocessor_detail::tokensToString ( const std::vector< Token > & tokens,
bool preserve_whitespace = false )

Definition at line 441 of file Preprocessor.cpp.

442 {
443 std::string result;
444 for (const auto& tok : tokens) {
445 if (!preserve_whitespace && (tok.type == TokenType::Whitespace ||
446 tok.type == TokenType::Comment)) {
447 continue;
448 }
449 result += tok.text;
450 }
451 return result;
452}

◆ trimTokens()

std::vector< Token > infix2postfix::preprocessor_detail::trimTokens ( const std::vector< Token > & tokens)

Definition at line 454 of file Preprocessor.cpp.

454 {
455 if (tokens.empty()) {
456 return tokens;
457 }
458
459 size_t start = 0;
460 while (start < tokens.size() &&
461 (tokens[start].type == TokenType::Whitespace ||
462 tokens[start].type == TokenType::Comment)) {
463 start++;
464 }
465
466 size_t end = tokens.size();
467 while (end > start && (tokens[end - 1].type == TokenType::Whitespace ||
468 tokens[end - 1].type == TokenType::Comment)) {
469 end--;
470 }
471
472 return {tokens.begin() + static_cast<std::ptrdiff_t>(start),
473 tokens.begin() + static_cast<std::ptrdiff_t>(end)};
474}