OpenStructure
Main Page
Related Pages
Modules
Namespaces
Data Structures
Files
Examples
File List
Globals
All
Data Structures
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
build-2.6
stage
include
ost
gui
python_shell
python_tokenizer.hh
Go to the documentation of this file.
1
//------------------------------------------------------------------------------
2
// This file is part of the OpenStructure project <www.openstructure.org>
3
//
4
// Copyright (C) 2008-2020 by the OpenStructure authors
5
//
6
// This library is free software; you can redistribute it and/or modify it under
7
// the terms of the GNU Lesser General Public License as published by the Free
8
// Software Foundation; either version 3.0 of the License, or (at your option)
9
// any later version.
10
// This library is distributed in the hope that it will be useful, but WITHOUT
11
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
13
// details.
14
//
15
// You should have received a copy of the GNU Lesser General Public License
16
// along with this library; if not, write to the Free Software Foundation, Inc.,
17
// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
//------------------------------------------------------------------------------
19
#ifndef PYTHON_TOKENIZER_HH
20
#define PYTHON_TOKENIZER_HH
21
22
/*
23
Author: Marco Biasini
24
*/
25
26
27
#include <
ost/gui/module_config.hh
>
28
#include <QString>
29
30
namespace
ost {
namespace
gui {
31
32
struct
DLLEXPORT_OST_GUI
Range
33
{
34
size_t
location
, length;
35
36
Range
(
size_t
loc,
size_t
len):
37
location(loc),
38
length(len)
39
{
40
}
41
42
Range
():
43
location(-1),
44
length(0)
45
{
46
}
47
48
size_t
End
()
const
49
{
50
return
location+length;
51
}
52
};
53
54
class
DLLEXPORT_OST_GUI
PythonToken
55
{
56
public
:
57
enum
Type
{
58
KEYWORD
,
59
STRING_LITERAL
,
60
STRING_DELIM
,
61
IDENTIFIER
,
62
NUMBER
,
63
OPERATOR
,
64
GROUPING
,
65
COMMENT
,
66
END
67
};
68
PythonToken
();
69
PythonToken
(
Type
type,
const
Range
& range,
const
QString& value);
70
Type
GetType()
const
;
71
QString GetTypeAsString()
const
;
72
const
QString&
GetValue
()
const
;
73
const
Range
& GetRange()
const
;
74
75
private
:
76
Type
type_;
77
Range
range_;
78
QString value_;
79
};
80
81
class
DLLEXPORT_OST_GUI
PythonTokenizer
82
{
83
public
:
84
PythonTokenizer
();
85
PythonTokenizer
(
const
QString& command,
int
string_state=0);
86
void
SetCommand(
const
QString& command);
87
PythonToken
NextToken();
88
const
PythonToken
& CurrentToken()
const
;
89
void
SetInString(
bool
in_string);
90
bool
InString
()
const
{
return
in_string_; }
91
const
QString&
GetDelim
()
const
{
return
string_delim_; }
92
private
:
93
void
EatWhities();
94
QString GetSubString(
const
Range
& range);
95
PythonToken
GetIdentifierSeq();
96
PythonToken
GetNumberToken();
97
PythonToken
GetKeywordToken();
98
PythonToken
GetOperatorToken();
99
PythonToken
GetGroupingToken();
100
PythonToken
GetStringLiteral();
101
PythonToken
GetStringDelim();
102
QString command_;
103
int
current_pos_;
104
bool
in_string_;
105
QString string_delim_;
106
PythonToken
current_token_;
107
};
108
109
110
}}
111
112
#endif
ost::gui::PythonTokenizer
Definition:
python_tokenizer.hh:81
ost::gui::Range::Range
Range()
Definition:
python_tokenizer.hh:42
module_config.hh
ost::gui::Range
Definition:
python_tokenizer.hh:32
ost::gui::PythonTokenizer::InString
bool InString() const
Definition:
python_tokenizer.hh:90
ost::gui::PythonToken::KEYWORD
Definition:
python_tokenizer.hh:58
ost::gui::Range::location
size_t location
Definition:
python_tokenizer.hh:34
ost::gui::PythonToken::Type
Type
Definition:
python_tokenizer.hh:57
ost::gui::PythonToken::STRING_DELIM
Definition:
python_tokenizer.hh:60
ost::gui::PythonToken::OPERATOR
Definition:
python_tokenizer.hh:63
DLLEXPORT_OST_GUI
#define DLLEXPORT_OST_GUI
Definition:
module_config.hh:33
ost::gfx::RenderMode::Type
Type
Definition:
render_mode.hh:32
ost::gui::Range::Range
Range(size_t loc, size_t len)
Definition:
python_tokenizer.hh:36
ost::gui::PythonToken
Definition:
python_tokenizer.hh:54
ost::gui::Range::End
size_t End() const
Definition:
python_tokenizer.hh:48
ost::gui::PythonToken::STRING_LITERAL
Definition:
python_tokenizer.hh:59
ost::gui::PythonToken::NUMBER
Definition:
python_tokenizer.hh:62
ost::gui::PythonTokenizer::GetDelim
const QString & GetDelim() const
Definition:
python_tokenizer.hh:91
ost::gui::PythonToken::GROUPING
Definition:
python_tokenizer.hh:64
ost::gui::PythonToken::COMMENT
Definition:
python_tokenizer.hh:65
ost.settings.GetValue
def GetValue
Definition:
settings.py:17
ost::gui::PythonToken::IDENTIFIER
Definition:
python_tokenizer.hh:61
Generated by
1.8.5