Algorithms Library Toolkit
A toolkit for algorithms, especially for algorithms on formal languages
Toggle main menu visibility
Main Page
Modules
Namespaces
Namespace List
Namespace Members
All
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
q
r
s
t
u
v
w
Functions
a
b
c
d
e
f
g
h
i
k
l
m
n
o
p
r
s
t
u
v
w
Variables
a
c
d
e
f
g
i
n
q
r
s
v
w
Typedefs
b
c
d
f
i
l
n
p
r
s
t
u
Enumerations
Enumerator
Concepts
Data Structures
Data Structures
Data Structure Index
Class Hierarchy
Data Fields
All
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Functions
a
b
c
d
e
f
g
h
i
j
k
l
m
n
o
p
q
r
s
t
u
v
w
x
~
Variables
a
c
d
e
f
h
i
l
m
n
o
p
r
s
t
v
w
Typedefs
c
d
e
f
i
n
o
p
r
s
t
v
w
Enumerations
Related Functions
a
b
f
n
o
p
s
t
u
v
Files
File List
Globals
All
Functions
Typedefs
Macros
•
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Modules
Concepts
alib2str
src
common
lexer.hpp
Go to the documentation of this file.
1
6
/*
7
* This file is part of Algorithms library toolkit.
8
* Copyright (C) 2017 Jan Travnicek (jan.travnicek@fit.cvut.cz)
9
10
* Algorithms library toolkit is free software: you can redistribute it and/or modify
11
* it under the terms of the GNU General Public License as published by
12
* the Free Software Foundation, either version 3 of the License, or
13
* (at your option) any later version.
14
15
* Algorithms library toolkit is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU General Public License for more details.
19
20
* You should have received a copy of the GNU General Public License
21
* along with Algorithms library toolkit. If not, see <http://www.gnu.org/licenses/>.
22
*/
23
24
#pragma once
25
26
#include <exception>
27
28
#include <ext/istream>
29
30
namespace
ext
{
31
32
class
BasicLexer
{
33
public
:
34
static
void
putback
(
ext::istream
& input,
const
std::string & data );
35
36
static
bool
test
(
ext::istream
& input,
const
std::string & value );
37
38
static
void
consume
(
ext::istream
& input,
const
std::string & value );
39
40
static
bool
testAndConsume
(
ext::istream
& input,
const
std::string & value );
41
42
};
43
44
template
<
typename
SuperLexer >
45
class
Lexer
:
public
BasicLexer
{
46
public
:
47
struct
Token
{
48
typename
SuperLexer::TokenType
type
;
49
std::string
value
;
50
std::string
raw
;
51
};
52
53
static
Token
peek
(
ext::istream
& input ) {
54
Token
token = SuperLexer::next ( input );
55
putback
( input, token );
56
return
token;
57
}
58
59
using
BasicLexer::putback
;
60
61
static
void
putback
(
ext::istream
& input,
const
Token
& token ) {
62
putback
( input, token.
raw
);
63
}
64
65
};
66
67
}
/* namespace ext */
68
ext::BasicLexer
Definition:
lexer.hpp:32
ext::BasicLexer::test
static bool test(ext::istream &input, const std::string &value)
Definition:
lexer.cpp:22
ext::BasicLexer::putback
static void putback(ext::istream &input, const std::string &data)
Definition:
lexer.cpp:15
ext::BasicLexer::consume
static void consume(ext::istream &input, const std::string &value)
Definition:
lexer.cpp:31
ext::BasicLexer::testAndConsume
static bool testAndConsume(ext::istream &input, const std::string &value)
Definition:
lexer.cpp:36
ext::Lexer
Definition:
lexer.hpp:45
ext::Lexer::peek
static Token peek(ext::istream &input)
Definition:
lexer.hpp:53
ext::Lexer::putback
static void putback(ext::istream &input, const Token &token)
Definition:
lexer.hpp:61
ext::istream
Definition:
istream.h:32
ext
Definition:
sigHandler.cpp:20
ext::Lexer::Token
Definition:
lexer.hpp:47
ext::Lexer::Token::value
std::string value
Definition:
lexer.hpp:49
ext::Lexer::Token::type
SuperLexer::TokenType type
Definition:
lexer.hpp:48
ext::Lexer::Token::raw
std::string raw
Definition:
lexer.hpp:50
Generated on Mon Dec 27 2021 10:21:54 for Algorithms Library Toolkit by
1.9.2