SimpleLexer.h
Go to the documentation of this file.
1/*
2* This file is part of ArmarX.
3*
4* ArmarX is free software; you can redistribute it and/or modify
5* it under the terms of the GNU General Public License version 2 as
6* published by the Free Software Foundation.
7*
8* ArmarX is distributed in the hope that it will be useful, but
9* WITHOUT ANY WARRANTY; without even the implied warranty of
10* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11* GNU General Public License for more details.
12*
13* You should have received a copy of the GNU General Public License
14* along with this program. If not, see <http://www.gnu.org/licenses/>.
15*
16* @author Simon Ottenhaus (simon dot ottenhaus at kit dot edu)
17* @copyright http://www.gnu.org/licenses/gpl-2.0.txt
18* GNU General Public License
19*/
20
21#pragma once
22
23#include <string>
24
25#include <boost/regex.hpp>
26
27#include "LexerInfo.h"
28
29namespace armarx
30{
32 {
33 public:
34 struct Rule
35 {
36 Rule(int id, const std::string& name, const boost::regex& regex) :
38 {
39 }
40
41 int id;
42 std::string name;
43 boost::regex regex;
44 };
45
46 SimpleLexer(std::string src, int tokenFin = -1, int tokenError = -2);
47
48 void addRule(int id, const std::string& name, const std::string& regex);
49
50 int nextToken();
51
52 void reset();
53
54 std::string tokenIdToName(int id);
55
56 void positionToLineAndColumn(int pos, int& line, int& column);
58
59 int pos;
61 std::string src;
62
64 std::string currentTokenValue;
65
67 std::vector<Rule> rules;
68 };
69} // namespace armarx
LexerInfo getPositionInfo(int pos)
std::vector< Rule > rules
Definition SimpleLexer.h:67
void addRule(int id, const std::string &name, const std::string &regex)
void positionToLineAndColumn(int pos, int &line, int &column)
SimpleLexer(std::string src, int tokenFin=-1, int tokenError=-2)
std::string tokenIdToName(int id)
std::string currentTokenValue
Definition SimpleLexer.h:64
This file offers overloads of toIce() and fromIce() functions for STL container types.
Rule(int id, const std::string &name, const boost::regex &regex)
Definition SimpleLexer.h:36