File indexing completed on 2024-04-14 05:44:26

0001 /*
0002  *  SPDX-FileCopyrightText: 2002-2003 Jesper K. Pedersen <blackie@kde.org>
0003  *
0004  *  SPDX-License-Identifier: LGPL-2.0-only
0005  **/
0006 
0007 #ifndef __REPEATREGEXP_H
0008 #define __REPEATREGEXP_H
0009 
0010 #include "regexp.h"
0011 
0012 /**
0013    Abstract syntax node for `repeated content' regular expression
0014    @internal
0015 */
0016 class RepeatRegExp : public RegExp
0017 {
0018 public:
0019     explicit RepeatRegExp(bool selected, int lower = 0, int upper = 0, RegExp *child = nullptr);
0020 
0021     bool check(ErrorMap &, bool first, bool last) override;
0022     int precedence() const override
0023     {
0024         return 3;
0025     }
0026 
0027     QDomNode toXml(QDomDocument *doc) const override;
0028     bool load(const QDomElement &, const QString &version) override;
0029     int min() const
0030     {
0031         return _lower;
0032     }
0033 
0034     int max() const
0035     {
0036         return _upper;
0037     }
0038 
0039     RegExp *child() const
0040     {
0041         return _child;
0042     }
0043 
0044     RegExpType type() const override
0045     {
0046         return REPEAT;
0047     }
0048 
0049     bool operator==(const RegExp &other) const override;
0050     void replacePart(CompoundRegExp *replacement) override
0051     {
0052         _child->replacePart(replacement);
0053     }
0054 
0055 private:
0056     int _lower;
0057     int _upper;
0058     RegExp *_child = nullptr;
0059 };
0060 
0061 #endif // __REPEATREGEXP_H