CoreComponents 3.0.0
A Modern C++ Toolkit
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages Modules
SyntaxDefinition::State Class Reference

Internal state. More...

#include <SyntaxDefinition>

Inheritance diagram for SyntaxDefinition::State:

Public Member Functions

 State (const SyntaxRule *entry)
 Initialize internal state.
 
Token match (const String &text, long start=0) const
 Match this syntax definition against text starting at offset
 
Token parse (const String &text, long offset=0) const
 Match this syntax definition against text starting at offset
 
Token findIn (const String &text, long offset=0) const
 Find the next occurance of this pattern in text starting from offset.
 
List< StringbreakUp (const String &text) const
 Break up text into the non-matching parts.
 
- Public Member Functions inherited from Object::State
 State ()=default
 Default constructor.
 
 State (const State &)
 Copy constructor.
 
virtual ~State ()
 Virtual destructor.
 
long useCount () const
 Reference count.
 
const Stateoperator= (const State &) const
 
template<class T >
bool is () const
 Check if this state is of type T.
 
template<class T >
T & as ()
 Statically cast this state to a different type T.
 
template<class T >
const T & as () const
 Statically cast this state to a different type T.
 

Single Character Literals

using Char = syntax::CharNode
 Match the next character by comparing for equality
 
using Other = syntax::OtherNode
 Match the next character by comparing for inequality
 
using Match = syntax::MatchNode
 Match the next character with a custom function
 
using Any = syntax::AnyNode
 Match an arbitrary next character
 
using Within = syntax::RangeNode
 Match the next character for lying in a given range
 
using Outside = syntax::OutOfRangeNode
 Match the next character for not lying in a given range
 
using OneOf = syntax::OneOfNode
 Match the next character against a set of characters
 
using NoneOf = syntax::NoneOfNode
 Match the next character if it is not member of a set of characters
 

Multi-Character Literals

using Literal = syntax::LiteralNode
 Match a case-sensitive multi-character literal
 
using Casefree = syntax::CasefreeNode
 Match a case-insensitive multi-character literal
 
using Keyword = syntax::KeywordNode
 Match the shortest matching keyword out of a set of keywords.
 

Structural Elements

using Sequence = syntax::SequenceNode
 Match a series of sub-expressions in sequence.
 
using Choice = syntax::ChoiceNode
 Try sub-expression choices until the first matches (without considering the rest of the expression).
 
using LongestChoice = syntax::ChoiceNode
 Try all sub-expression choices and produce the longest match (without considering the rest of the expression).
 
using Repeat = syntax::RepeatNode
 Repeatedly match a sub-expression.
 
using Find = syntax::FindNode
 Find the next text position at which the given sub-expression matches.
 
using FindLast = syntax::FindLastNode
 Find the last text position at which the given sub-expression matches.
 
using Ahead = syntax::AheadNode
 Match a given sub-expression ahead of the current text position.
 
using Behind = syntax::BehindNode
 Match a given sub-expression behind the current text position.
 
using Not = syntax::NotNode
 Do not match a given sub-expression ahead of the current text position.
 
using NotBehind = syntax::NotBehindNode
 Match a given sub-expression not behind the current text position.
 
using Ref = syntax::RefNode
 Bind a reference to another syntax rule.
 
using Inline = syntax::InlineNode
 Bind a reference to another syntax rule (inline mode)
 

Constraints

using Boi = syntax::BoiNode
 Match the start of information (current text position equals 0).
 
using Eoi = syntax::EoiNode
 Match the end of the text (current text position equals length of text).
 
using Length = syntax::LengthNode
 Enforce a required minimum and maximum text length when matching a sub-expression.
 
using Pass = syntax::PassNode
 Unconditionally succeed to match at the current text position.
 
using Fail = syntax::FailNode
 Unconditionally fail to match at the current text position.
 
using Expect = syntax::ExpectNode
 Throw an expection if a sub-expression match fails.
 

Context Awareness

using Capture = syntax::CaptureNode
 Match a sub-expression and copy the matching sequence
 
using Replay = syntax::ReplayNode
 Match a previously captured text
 
using Context = syntax::ContextNode
 Select a rule to match depending on production context.
 
using Debug = syntax::DebugNode
 Show debugging information for a sub-expression match.
 

Detailed Description

Internal state.

Member Typedef Documentation

◆ Char

Match the next character by comparing for equality

◆ Other

Match the next character by comparing for inequality

◆ Match

Match the next character with a custom function

◆ Any

Match an arbitrary next character

◆ Within

Match the next character for lying in a given range

◆ Outside

Match the next character for not lying in a given range

◆ OneOf

Match the next character against a set of characters

◆ NoneOf

Match the next character if it is not member of a set of characters

◆ Literal

Match a case-sensitive multi-character literal

◆ Casefree

Match a case-insensitive multi-character literal

◆ Keyword

Match the shortest matching keyword out of a set of keywords.

◆ Sequence

Match a series of sub-expressions in sequence.

◆ Choice

Try sub-expression choices until the first matches (without considering the rest of the expression).

◆ LongestChoice

Try all sub-expression choices and produce the longest match (without considering the rest of the expression).

◆ Repeat

Repeatedly match a sub-expression.

◆ Find

Find the next text position at which the given sub-expression matches.

◆ FindLast

Find the last text position at which the given sub-expression matches.

◆ Ahead

Match a given sub-expression ahead of the current text position.

◆ Behind

Match a given sub-expression behind the current text position.

◆ Not

Do not match a given sub-expression ahead of the current text position.

◆ NotBehind

Match a given sub-expression not behind the current text position.

◆ Ref

Bind a reference to another syntax rule.

◆ Inline

Bind a reference to another syntax rule (inline mode)

◆ Boi

Match the start of information (current text position equals 0).

◆ Eoi

Match the end of the text (current text position equals length of text).

◆ Length

Enforce a required minimum and maximum text length when matching a sub-expression.

◆ Pass

Unconditionally succeed to match at the current text position.

◆ Fail

Unconditionally fail to match at the current text position.

◆ Expect

Throw an expection if a sub-expression match fails.

◆ Capture

Match a sub-expression and copy the matching sequence

◆ Replay

Match a previously captured text

◆ Context

Select a rule to match depending on production context.

◆ Debug

Show debugging information for a sub-expression match.

Constructor & Destructor Documentation

◆ State()

State ( const SyntaxRule * entry)
explicit

Initialize internal state.

Parameters
entryEntry point for syntax production

Member Function Documentation

◆ match()

Token match ( const String & text,
long start = 0 ) const

Match this syntax definition against text starting at offset

Returns
Root node of the syntax production tree

◆ parse()

Token parse ( const String & text,
long offset = 0 ) const

Match this syntax definition against text starting at offset

Returns
Root node of the syntax production tree
Exceptions
TextErrorText does not match this syntax definition

◆ findIn()

Token findIn ( const String & text,
long offset = 0 ) const

Find the next occurance of this pattern in text starting from offset.

◆ breakUp()

List< String > breakUp ( const String & text) const

Break up text into the non-matching parts.