coan  6.0.1
A C/C++ Configuration Analyzer
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
chewer< CharSeq > Struct Template Reference

`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence type upon which it can performs some routine forms of lexical scanning. More...

#include <chew.h>

Inheritance diagram for chewer< CharSeq >:
no_assign

Public Types

using sequence_type = CharSeq
 Type of the character-sequence consumed.
 
using char_type = typename sequence_type::value_type
 Value-type of the character-sequence.
 
template<class Mode1 , class Mode2 >
using void_if = typename std::enable_if< std::is_same< Mode1, Mode2 >::value >::type
 SFINAE type equating to void if enabled.
 

Public Member Functions

 chewer (bool cxx, sequence_type &seq, size_t off=0)
 Construct from a sequence_type and initial offset. More...
 
template<class Mode >
 chewer (bool cxx, Mode mode, sequence_type &seq, size_t off=0)
 Construct, scanning a given a sequence_type from a given offset. More...
 
bool cxx () const
 Say whether scanning as C/C++ source.
 
void sync ()
 Synchronise the object with the associated sequence_type More...
 
template<class Mode >
void scan (Mode mode, size_t off)
 Scan the associated sequence_type in a given mode from a given offset.
 
template<class FirstMode , class... OtherModes>
void scan (ptrdiff_t adjust, FirstMode first_mode, OtherModes...other_modes)
 Adjust position and then scan in a sequence of modes. More...
 
template<class FirstMode , class... OtherModes>
void scan ()
 Scan in a sequence of modes. More...
 
bool overshoot (size_t off=0) const
 Say whether the scanning position is past the end of the associated sequence_type
 
char_type atoff (ptrdiff_t off) const
 Get the character at an offset from the scanning position.
 
char_typeatoff (size_t off)
 Get a reference to the character at an offset from the scanning position.
 
char_type operator[] (size_t off) const
 operator[]() const is an alias for atoff() const
 
char_typeoperator[] (size_t off)
 operator[]() is an alias for atoff()
 
size_t cursor () const
 Get the scanning position.
 
size_t remaining () const
 Get the remaining length of the associated sequence_type from the scanning position.
 
void cursor (size_t off)
 Set the scanning position. More...
 
char_type curch () const
 Get the character at the scanning position.
 
char_typecurch ()
 Get a reference to the character at the scanning position.
 
cheweroperator= (size_t off)
 Assign the scanning position, returning *this
 
 operator size_t () const
 Explicitly cast to size_t, returning the scanning positition.
 
char_type operator* () const
 operator*() const is an alias for curch() const.
 
char_typeoperator* ()
 operator*() is an alias for curch().
 
 operator bool () const
 Explicitly cast to bool, returning !overshoot()
 
void on (size_t n)
 Advance the scanning position an amount. More...
 
void back (size_t n)
 Retreat the scanning position an amount. More...
 
cheweroperator++ ()
 Increment the scanning position, returning *this
 
cheweroperator-- ()
 Decrement the scanning position, returning *this
 
cheweroperator+= (size_t n)
 Advance the scanning position an amount, returning *this
 
cheweroperator-= (size_t n)
 Retreat the scanning position an amount, returning *this
 
template<class Mode >
cheweroperator() (ptrdiff_t move, Mode mode)
 operator()(move,mode) calls scan(move,mode) returning *this
 
template<class FirstMode , class... OtherModes>
std::enable_if
<!std::is_arithmetic
< FirstMode >::value, chewer & >
::type 
operator() (FirstMode first_mode, OtherModes...other_modes)
 operator()(mode) calls scan(mode) returning *this
 
sequence_typebuf ()
 Get a [const] reference to the associated sequence_type
 
sequence_type const & buf () const
 

Private Types

template<typename U >
using if_sequence_is_extensible = typename std::enable_if< traits::has_extend_method< U >::value >::type
 SFINAE type equating to void if sequence_type has an extend method.
 
template<typename U >
using if_sequence_is_not_extensible = typename std::enable_if<!traits::has_extend_method< U >::value >::type
 SFINAE type equating to void if sequence_type lacks an extend method.
 

Private Member Functions

unsigned eol (size_t off=0)
 Test for a newline-sequence at an offset from the scanning position. More...
 
bool line_continues (size_t off=0)
 Say whether there is a line-continuation at an offset. More...
 
template<char_type Opener, char_type Closer>
void consume_enclosed_string ()
 Consume characters between delimiting characters.
 
void missing_terminator (size_t off, char_type missing)
 Diagnose a missing terminator character.
 
void eof_in_comment ()
 Diagnose end of file in C-comment.
 
template<typename U = sequence_type>
void extend (if_sequence_is_extensible< U > *=nullptr)
 Extend the associated sequence_type by reading more input.
 
template<typename U = sequence_type>
void extend (if_sequence_is_not_extensible< U > *=nullptr)
 
template<typename U = sequence_type>
void extend (size_t skip, if_sequence_is_extensible< U > *=nullptr)
 Extend the associated sequence_type by reading more input, possibly replacing skip characters ahead of the cursor.
 
template<typename U = sequence_type>
void extend (size_t skip, if_sequence_is_not_extensible< U > *=nullptr)
 
template<class Mode >
void_if< Mode,
chew_mode::continuation
consume ()
 Consume characters satisfying a given mode, without preliminary snyc()
 
template<class Mode >
void_if< Mode,
chew_mode::whitespace
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::number_space
consume ()
 
template<class Mode >
void_if< Mode, chew_mode::nameconsume ()
 
template<class Mode >
void_if< Mode,
chew_mode::punctuation
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::stringify
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::token_paste
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::cxx_comment
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::c_comment
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::string_literal
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::header_name
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::character_literal
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::raw_string_literal
consume ()
 
template<class Mode >
void_if< Mode,
chew_mode::greyspace
consume ()
 
template<class Mode >
void_if< Mode, chew_mode::codeconsume ()
 
template<class Mode >
void_if< Mode,
chew_mode::literal_space
consume ()
 
template<class First , class Next , class... Rest>
std::enable_if< sizeof...(Rest)==0 >
::type 
consume ()
 Consume characters satisfying a sequence of modes, without preliminary sync()
 
template<class First , class Next , class... Rest>
std::enable_if< sizeof...(Rest)!=0 >
::type 
consume ()
 

Private Attributes

bool _cxx
 Scanning C/C++ source?
 
sequence_type_seq
 The sequence that is consumed.
 
char_type_buf
 Pointer to the data controlled by _seq
 
size_t _cur
 The scanning position in _buf.
 
size_t _len
 The length of the data at `_buf'.
 

Detailed Description

template<class CharSeq>
struct chewer< CharSeq >

`template struct chewer<CharSeq> is a cursor-like type that is associated with a character-sequence type upon which it can performs some routine forms of lexical scanning.

Template Parameters
CharSeqA character-sequence type

Definition at line 248 of file chew.h.

Constructor & Destructor Documentation

template<class CharSeq>
chewer< CharSeq >::chewer ( bool  cxx,
sequence_type seq,
size_t  off = 0 
)
inlineexplicit

Construct from a sequence_type and initial offset.

Parameters
cxxIs C/C++ code to be scanned?
seqA sequence_type to be scanned
offOffset in seq at which to start scanning

The constructor performs no scanning of seq

Definition at line 268 of file chew.h.

template<class CharSeq>
template<class Mode >
chewer< CharSeq >::chewer ( bool  cxx,
Mode  mode,
sequence_type seq,
size_t  off = 0 
)
inlineexplicit

Construct, scanning a given a sequence_type from a given offset.

Template Parameters
ModeThe type of mode in which to scan
Parameters
cxxIs C/C++ code to be scanned?
modeA Mode
seqA sequence_type to be scanned
offOffset in seq at which to start scanning

The constructor performs scanning of seq according to Mode

Definition at line 283 of file chew.h.

Member Function Documentation

template<class CharSeq>
void chewer< CharSeq >::back ( size_t  n)
inline

Retreat the scanning position an amount.

Parameters
nThe amount to move the scanning position back. The new position is not range-chacked.

Definition at line 450 of file chew.h.

template<class CharSeq>
void chewer< CharSeq >::cursor ( size_t  off)
inline

Set the scanning position.

Parameters
offAn offset in the associated sequence_type

The scanning position is set = off without range-checking

Definition at line 385 of file chew.h.

template<class CharSeq>
unsigned chewer< CharSeq >::eol ( size_t  off = 0)
inlineprivate

Test for a newline-sequence at an offset from the scanning position.

Parameters
offOffset in the associated sequence_type at which to test for new-line.
Returns
The length of the newline-sequence detected, if any (1 for Unix '
', 2 for Windows "\r\n"), else 0

Definition at line 542 of file chew.h.

template<class CharSeq>
bool chewer< CharSeq >::line_continues ( size_t  off = 0)
inlineprivate

Say whether there is a line-continuation at an offset.

from the scanning position.

Parameters
offThe offset at which to test
Returns
True iff there is a line-continuation at offset off

Definition at line 550 of file chew.h.

template<class CharSeq>
void chewer< CharSeq >::on ( size_t  n)
inline

Advance the scanning position an amount.

Parameters
nThe mount by which the advance the scanning position.

The new position is not range-chacked.

Definition at line 441 of file chew.h.

template<class CharSeq>
template<class FirstMode , class... OtherModes>
void chewer< CharSeq >::scan ( ptrdiff_t  adjust,
FirstMode  first_mode,
OtherModes...  other_modes 
)
inline

Adjust position and then scan in a sequence of modes.

Template Parameters
FirstModeType of the first sccanning mode
OtherModesTypes of successive subsequent scanning modes
Parameters
adjustA signed amount by which the object's scanning position in the assoiciated sequence_type shall be moved before scanning starts.
first_modeA FirstMode
other_modesA sequence of modes of types per OtherModes

The adjusted scanning position is not range checked.

Definition at line 324 of file chew.h.

template<class CharSeq>
template<class FirstMode , class... OtherModes>
void chewer< CharSeq >::scan ( )
inline

Scan in a sequence of modes.

Template Parameters
FirstModeType of the first sccanning mode
OtherModesTypes of successive subsequent scanning modes

Definition at line 337 of file chew.h.

template<class CharSeq>
void chewer< CharSeq >::sync ( )
inline

Synchronise the object with the associated sequence_type

Must be called after any operation on the associated sequence_type that would invalidate an iterator on sequence_type. before further operations on the object.

Definition at line 299 of file chew.h.


The documentation for this struct was generated from the following file: