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 _SML_TOKEN_H_
7#define _SML_TOKEN_H_
8
9#include <QString>
10#include <sstream>
11
12#include <knowCore/Curie.h>
13
14namespace kDB
15{
16 namespace RDFView
17 {
18 namespace SML
19 {
20 struct Token
21 {
25 enum Type
26 {
27 // Not really token
28 UNFINISHED_STRING = -4,
29 END_OF_FILE = -3,
30 END_OF_LINE = -2,
31 UNKNOWN = -1,
32 // Special characters
33 SEMI = 0,
44 QUESTION,
46 CIRCUMFLEXCIRCUMFLEX,
47 // Constants
48 FLOAT_CONSTANT,
49 INTEGER_CONSTANT,
50 STRING_CONSTANT,
51 URI_CONSTANT,
52 BINDING,
53 IDENTIFIER,
54 LANG_TAG,
55 CURIE_CONSTANT,
56 // Keywords
57 A,
58 AS,
59 BASE,
60 CONSTRAIN,
61 CONSTRUCT,
62 CREATE,
63 FROM,
64 PREFIX,
65 VIEW,
66 WITH,
67 TRUE,
68 FALSE,
69 // Not valid on SML:
70 LOAD_FILE
71 };
75 int line;
77 int column;
79 QString string;
80 // Curie
81 knowCore::Curie curie;
82 Token();
83 Token(const knowCore::Curie& _curie, int _line, int _column);
87 Token(Type _type, int _line, int _column);
91 Token(Type _type, const QString& _string, int _line, int _column);
92 bool isExpressionTerminal();
93 bool isConstant() const;
94 bool isPrimary() const;
95 static QString typeToString(Type);
96 QString toString() const;
97 };
98 } // namespace SML
99 } // namespace RDFView
100}; // namespace kDB
101
102#include <knowCore/Formatter.h>
103
104clog_format_declare_formatter(kDB::RDFView::SML::Token::Type)
105{
106 return format_to(ctx.out(), "{}", kDB::RDFView::SML::Token::typeToString(p));
107}
108
109#endif
Definition Curie.h:22
Definition Token_p.h:21
Type type
type of the token
Definition Token_p.h:73
QString string
String or identifier name.
Definition Token_p.h:79
int line
line of the token
Definition Token_p.h:75
Type
Definition Token_p.h:26
@ STARTBRACE
{
Definition Token_p.h:37
@ UNDERSCORECOLON
< ?
Definition Token_p.h:45
@ EQUAL
=
Definition Token_p.h:43
@ STARTBRACKET
(
Definition Token_p.h:39
@ COMA
,
Definition Token_p.h:35
@ ENDBRACE
}
Definition Token_p.h:38
@ COLON
:
Definition Token_p.h:34
@ DOT
Definition Token_p.h:36
@ SEMI
;
Definition Token_p.h:33
@ STARTBOXBRACKET
[
Definition Token_p.h:41
@ ENDBRACKET
)
Definition Token_p.h:40
@ ENDBOXBRACKET
]
Definition Token_p.h:42
int column
Column of the token.
Definition Token_p.h:77