knowL: Knowledge Libraries
Loading...
Searching...
No Matches
Token_p.h
1/*
2 * Copyright (c) 2008,2010,2015 Cyrille Berger <cberger@cberger.net>
3 *
4 */
5
6#ifndef _TURTLE_TOKEN_H_
7#define _TURTLE_TOKEN_H_
8
9#include <QString>
10#include <sstream>
11
12#include <knowCore/Curie.h>
13
14namespace knowRDF
15{
16 namespace Turtle
17 {
18 struct Token
19 {
23 enum Type
24 {
25 // Not really token
26 UNFINISHED_STRING = -4,
27 END_OF_FILE = -3,
28 END_OF_LINE = -2,
29 UNKNOWN = -1,
30 // Special characters
31 SEMI = 0,
39 QUESTION,
42 // Constants
43 FLOAT_CONSTANT,
44 INTEGER_CONSTANT,
45 STRING_CONSTANT,
46 URI_CONSTANT,
47 IDENTIFIER,
48 LANG_TAG,
49 CURIE_CONSTANT,
50 // Keywords,
51 BASE,
52 PREFIX,
53 A,
54 TRUE,
55 FALSE,
56 LOAD_FILE
57 };
61 int line;
63 int column;
65 QString string;
66 // Curie
67 knowCore::Curie curie;
68 Token();
69 Token(const knowCore::Curie& _curie, int _line, int _column);
73 Token(Type _type, int _line, int _column);
77 Token(Type _type, const QString& _string, int _line, int _column);
78 static QString typeToString(Type);
79 QString toString() const;
80 };
81 } // namespace Turtle
82} // namespace knowRDF
83
84#include <knowCore/Formatter.h>
85
86clog_format_declare_formatter(knowRDF::Turtle::Token::Type)
87{
88 return std::format_to(ctx.out(), "{}", knowRDF::Turtle::Token::typeToString(p));
89}
90
91#endif
Definition Curie.h:22
Definition Token_p.h:19
int column
Column of the token.
Definition Token_p.h:63
int line
line of the token
Definition Token_p.h:61
Type
Definition Token_p.h:24
@ COLON
:
Definition Token_p.h:32
@ ENDBOXBRACKET
]
Definition Token_p.h:38
@ STARTBOXBRACKET
[
Definition Token_p.h:37
@ STARTBRACKET
(
Definition Token_p.h:35
@ SEMI
;
Definition Token_p.h:31
@ UNDERSCORECOLON
< ?
Definition Token_p.h:40
@ DOT
Definition Token_p.h:34
@ CIRCUMFLEXCIRCUMFLEX
^^
Definition Token_p.h:41
@ ENDBRACKET
)
Definition Token_p.h:36
@ COMA
,
Definition Token_p.h:33
Type type
type of the token
Definition Token_p.h:59
QString string
String or identifier name.
Definition Token_p.h:65