Libksieve

lexer.h
1/* -*- c++ -*-
2 ksieve/lexer.h
3
4 This file is part of KSieve,
5 the KDE internet mail/usenet news message filtering library.
6 SPDX-FileCopyrightText: 2003 Marc Mutz <mutz@kde.org>
7
8 SPDX-License-Identifier: GPL-2.0-only
9*/
10
11#pragma once
12
13#include "ksieve_export.h"
14
15class QString;
16
17namespace KSieve
18{
19class Error;
20
21class KSIEVE_EXPORT Lexer
22{
23public:
24 enum Options {
25 IncludeComments = 0,
26 IgnoreComments = 1,
27 IncludeLineFeeds = 0,
28 IgnoreLineFeeds = 2
29 };
30
31 Lexer(const char *scursor, const char *send, int options = 0);
32 ~Lexer();
33
34 /** Return whether comments are returned by @ref
35 nextToken. Default is to not ignore comments. Ignoring them
36 can speed up script parsing a bit, and can be used when the
37 internal representation of the script won't be serialized into
38 string form again (or if you simply want to delete all
39 comments)
40 **/
41 bool ignoreComments() const;
42
43 /** Return whether line feeds are returned by @ref
44 nextToken. Default is to not ignore line feeds. Ignoring them
45 can speed up script parsing a bit, and can be used when the
46 internal representation of the script won't be serialized into
47 string form again.
48 **/
49 bool ignoreLineFeeds() const;
50
51 const Error &error() const;
52
53 bool atEnd() const;
54 int column() const;
55 int line() const;
56
57 enum Token {
58 None = 0,
59 Number, // 1, 100, 1M, 10k, 1G, 2g, 3m
60 Identifier, // atom
61 Tag, // :tag
62 Special, // {} [] () ,;
63 QuotedString, // "foo\"bar" -> foo"bar
64 MultiLineString, // text: \nfoo\n. -> foo
65 HashComment, // # foo
66 BracketComment, // /* foo */
67 LineFeeds // the number of line feeds encountered
68 };
69
70 /** Parse the next token and return it's type. @p result will contain
71 the value of the token. */
72 Token nextToken(QString &result);
73
74 void save();
75 void restore();
76
77 class Impl;
78
79private:
80 Impl *i = nullptr;
81
82private:
83 const Lexer &operator=(const Lexer &);
84 Lexer(const Lexer &);
85};
86} // namespace KSieve
void error(QWidget *parent, const QString &text, const QString &title, const KGuiItem &buttonOk, Options options=Notify)
KGuiItem save()
This file is part of the KDE documentation.
Documentation copyright © 1996-2024 The KDE developers.
Generated on Fri Nov 22 2024 12:09:39 by doxygen 1.12.0 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.