Plasma Engine  2.0
Loading...
Searching...
No Matches
TokenParseUtils.h
1#pragma once
2
3#include <Foundation/CodeUtils/Tokenizer.h>
4#include <Foundation/Containers/HybridArray.h>
5
6namespace plTokenParseUtils
7{
8 using TokenStream = plHybridArray<const plToken*, 32>;
9
13 PL_FOUNDATION_DLL void SkipWhitespace(const TokenStream& tokens, plUInt32& ref_uiCurToken); // [tested]
14
18 PL_FOUNDATION_DLL void SkipWhitespaceAndNewline(const TokenStream& tokens, plUInt32& ref_uiCurToken); // [tested]
19
25 PL_FOUNDATION_DLL bool IsEndOfLine(const TokenStream& tokens, plUInt32 uiCurToken, bool bIgnoreWhitespace); // [tested]
26
32 PL_FOUNDATION_DLL void CopyRelevantTokens(const TokenStream& source, plUInt32 uiFirstSourceToken, TokenStream& ref_destination, bool bPreserveNewLines); // [tested]
33
40 PL_FOUNDATION_DLL bool Accept(const TokenStream& tokens, plUInt32& ref_uiCurToken, plStringView sToken, plUInt32* pAccepted = nullptr); // [tested]
41
43 PL_FOUNDATION_DLL bool Accept(const TokenStream& tokens, plUInt32& ref_uiCurToken, plTokenType::Enum type, plUInt32* pAccepted = nullptr); // [tested]
44
52 PL_FOUNDATION_DLL bool Accept(const TokenStream& tokens, plUInt32& ref_uiCurToken, plStringView sToken1, plStringView sToken2, plUInt32* pAccepted = nullptr); // [tested]
53
61 PL_FOUNDATION_DLL bool AcceptUnless(const TokenStream& tokens, plUInt32& ref_uiCurToken, plStringView sToken1, plStringView sToken2, plUInt32* pAccepted = nullptr); // [tested]
62
66 {
69 : m_sToken(sToken)
70 {
71 }
74 : m_Type(type)
75 {
76 }
77
80 : m_Type(type)
81 , m_sToken(sToken)
82 {
83 }
84
86 plStringView m_sToken;
87 };
88
103 PL_FOUNDATION_DLL bool Accept(const TokenStream& tokens, plUInt32& ref_uiCurToken, plArrayPtr<const TokenMatch> matches, plDynamicArray<plUInt32>* pAccepted = nullptr); // [tested]
104
112 PL_FOUNDATION_DLL void CombineTokensToString(const TokenStream& tokens, plUInt32 uiCurToken, plStringBuilder& ref_sResult, bool bKeepComments = true, bool bRemoveRedundantWhitespace = false, bool bInsertLine = false);
113
118 PL_FOUNDATION_DLL void CombineRelevantTokensToString(const TokenStream& tokens, plUInt32 uiCurToken, plStringBuilder& ref_sResult);
119
124 PL_FOUNDATION_DLL void CreateCleanTokenStream(const TokenStream& tokens, plUInt32 uiCurToken, TokenStream& ref_destination);
125} // namespace plTokenParseUtils
This class encapsulates an array and it's size. It is recommended to use this class instead of plain ...
Definition ArrayPtr.h:37
Definition DynamicArray.h:81
A hybrid array uses in-place storage to handle the first few elements without any allocation....
Definition HybridArray.h:12
plStringBuilder is a class that is meant for creating and modifying strings.
Definition StringBuilder.h:35
plStringView represent a read-only sub-string of a larger string, as it can store a dedicated string ...
Definition StringView.h:34
A token to be matched by the plTokenParseUtils::Accept overload for arrays of tokens....
Definition TokenParseUtils.h:66
TokenMatch(plStringView sToken)
This matches a token string of any type.
Definition TokenParseUtils.h:68
TokenMatch(plTokenType::Enum type, plStringView sToken)
For internal use. Use one of the other constructors instead.
Definition TokenParseUtils.h:79
TokenMatch(plTokenType::Enum type)
This matches a token type of any string value.
Definition TokenParseUtils.h:73
Enum
Definition Tokenizer.h:13
@ Unknown
for internal use
Definition Tokenizer.h:14