kDB: Knowledge DataBase
Loading...
Searching...
No Matches
Token_p.h
1/*
2 * Copyright (c) 2008,2010,2015 Cyrille Berger <cberger@cberger.net>
3 *
4 */
5
6#ifndef _SPARQL_TOKEN_H_
7#define _SPARQL_TOKEN_H_
8
9#include <QString>
10#include <sstream>
11
12#include <knowCore/Curie.h>
13
14namespace kDB
15{
16 namespace SPARQL
17 {
18 struct Token {
22 enum Type {
23 // Not really token
24 INVALID_BINDING = -6,
25 UNKNOWN_BINDING = -5,
26 UNFINISHED_STRING = -4,
27 END_OF_FILE = -3,
28 END_OF_LINE = -2,
29 UNKNOWN = - 1,
30 // Special characters
31 SEMI = 0,
56 // Constants
57 FLOAT_CONSTANT,
58 INTEGER_CONSTANT,
59 STRING_CONSTANT,
60 URI_CONSTANT,
61 NAME,
62 LANG_TAG,
63 VARIABLE,
64 CURIE_CONSTANT,
65 BINDING,
66 // Special values,
67 FALSE,
68 TRUE,
69#define KDB_SPARQL_KEYWORD(_NAME_) _NAME_,
70 // Keywords
71 A,
72#include "Keywords.h"
73 // PL/SPARQL
74#include "PlKeywords.h"
75#undef KDB_SPARQL_KEYWORD
76 ___
77 };
81 int line;
83 int column;
85 QString string;
86 // Curie
87 knowCore::Curie curie;
88 Token();
89 Token(const knowCore::Curie& _curie, int _line, int _column);
93 Token(Type _type, int _line, int _column);
97 Token(Type _type, const QString& _string, int _line, int _column);
98 bool isExpressionTerminal();
99 bool isConstant() const;
100 bool isBinaryOperator() const;
101 int binaryOperationPriority() const;
102 bool isUnaryOperator() const;
103 bool isOperator() const;
104 bool isPrimary() const;
105 static QString typeToString(Type );
106 QString toString() const;
107 bool operator==(const Token& _rhs) const
108 {
109 return type == _rhs.type and line == _rhs.line and column == _rhs.column and string == _rhs.string and curie == _rhs.curie;
110 }
111 };
112 }
113};
114
115
116#endif
Definition Curie.h:22
Definition Token_p.h:18
Type type
type of the token
Definition Token_p.h:79
QString string
String or identifier name.
Definition Token_p.h:85
int column
Column of the token.
Definition Token_p.h:83
int line
line of the token
Definition Token_p.h:81
Type
Definition Token_p.h:22
@ AND
and &&
Definition Token_p.h:43
@ SUPPERIOREQUAL
>=
Definition Token_p.h:48
@ COMA
,
Definition Token_p.h:33
@ STARTBOXBRACKET
[
Definition Token_p.h:39
@ DIFFERENT
!=
Definition Token_p.h:42
@ DIVIDE
/
Definition Token_p.h:52
@ EXCLAMATION
not !
Definition Token_p.h:53
@ MINUS
Definition Token_p.h:50
@ STARTBRACE
{
Definition Token_p.h:35
@ INFERIOR
<
Definition Token_p.h:45
@ PLUS
Definition Token_p.h:49
@ STARTBRACKET
(
Definition Token_p.h:37
@ SEMI
;
Definition Token_p.h:31
@ INFERIOREQUAL
<=
Definition Token_p.h:46
@ CIRCUMFLEXCIRCUMFLEX
^^
Definition Token_p.h:55
@ MULTIPLY
Definition Token_p.h:51
@ UNDERSCORECOLON
_:
Definition Token_p.h:54
@ COLON
:
Definition Token_p.h:32
@ EQUAL
=
Definition Token_p.h:41
@ ENDBOXBRACKET
]
Definition Token_p.h:40
@ SUPPERIOR
Definition Token_p.h:47
@ OR
or ||
Definition Token_p.h:44
@ ENDBRACE
}
Definition Token_p.h:36
@ DOT
Definition Token_p.h:34
@ ENDBRACKET
)
Definition Token_p.h:38