summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml/script/lexer.h
blob: 9de4afd2579227e2eb48f0d4be1862a4ece36db2 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/****************************************************************************
**
** This file is part of the $PACKAGE_NAME$.
**
** Copyright (C) $THISYEAR$ $COMPANY_NAME$.
**
** $QT_EXTENDED_DUAL_LICENSE$
**
****************************************************************************/

#ifndef LEXER_H
#define LEXER_H

#include <QtCore/QList>
#include "tokens.h"


QT_BEGIN_HEADER

QT_BEGIN_NAMESPACE

QT_MODULE(Declarative)
struct LexerToken
{
    LexerToken() : token(NOTOKEN), start(-1), end(-1), line(-1), offset(-1) {}
    LexerToken(const LexerToken &other) : token(other.token),
                                          start(other.start),
                                          end(other.end),
                                          line(other.line),
                                          offset(other.offset) {}
    LexerToken &operator=(const LexerToken &other) {
        token = other.token;
        start = other.start;
        end = other.end;
        line = other.line;
        offset = other.offset;
        return *this;
    }

    Token token;
    int start;
    int end;
    int line;
    int offset;
};

QList<LexerToken> tokenize(const char *text);
void dumpTokens(const char *text, const QList<LexerToken> &tokens);


QT_END_NAMESPACE

QT_END_HEADER
#endif