/usr/include/srchilite/highlightrule.h is in libsource-highlight-dev 3.1.6-2ubuntu1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 | //
// Author: Lorenzo Bettini <http://www.lorenzobettini.it>, (C) 2004-2008
//
// Copyright: See COPYING file that comes with this distribution
//
#ifndef HIGHLIGHTRULE_H_
#define HIGHLIGHTRULE_H_
#include <string>
#include <boost/shared_ptr.hpp>
#include "highlightstate.h"
namespace srchilite {
struct HighlightToken;
struct MatchingParameters;
/// list representing the names of parts of a program
typedef std::deque<std::string> ElemList;
/**
* Base class for highlight rules. This abstracts from the actual
* implementation for matching.
*/
class HighlightRule {
/// the list of program elements detected by this rule
ElemList elemList;
/// if set, it represents the state to enter if this rule matches
/// this class does not delete nextState
HighlightStatePtr nextState;
/// additional information about this rule
std::string additionalInfo;
/// how many state must we exit if we match this rule:
/// 0: none, -1: all, otherwise the number of states to exit
int exitLevel;
/// tells that if this rule matches we must enter the same state once again
bool nested;
/// whether this rule has dynamic references to be replaced
bool needsReferenceReplacement;
/// whether this rule can match subexpressions
bool hasSubexpressions;
public:
HighlightRule();
/**
* Creates a rule for the given element (Although each rule can concern
* more than one program element, we provide only this convenience constructor with
* only one name: if the rule concerns more than one element one can use
* addElem method)
* @param name the element name of this rule
*/
HighlightRule(const std::string &name);
virtual ~HighlightRule();
/**
* Try to match this rule against the passed string (implemented by calling
* the pure virtual function tryToMatch below). The passed token is assumed to be
* reset (i.e., no existing matching information is stored in it when passing it to
* this method).
*
* @param s the string for trying to match the rule
* @param token where results will be inserted, if the rule matched
* @param params additional arguments for the matching
* @return the result of this matching
*/
virtual bool tryToMatch(const std::string &s, HighlightToken &token,
const MatchingParameters ¶ms);
/**
* Try to match this rule against the passed string
*
* @param start the beginning of the string for trying to match the rule
* @param end the beginning of the string for trying to match the rule
* @param token where results will be inserted, if the rule matched
* @param params additional arguments for the matching
* @return the result of this matching
*/
virtual bool tryToMatch(std::string::const_iterator start,
std::string::const_iterator end, HighlightToken &token,
const MatchingParameters ¶ms) = 0;
virtual const std::string toString() const = 0;
/**
* Performs replacement of references in this rule.
* @param the list of values for the replacement; the first element
* is the value for replacing the first dynamic back reference, and so on.
* (it should contain 9 possibly empty elements)
*/
virtual void replaceReferences(const ReplacementList &rep) = 0;
/**
* @return a copy of this rule.
*/
virtual HighlightRule *clone() = 0;
const HighlightStatePtr getNextState() const {
return nextState;
}
void setNextState(HighlightStatePtr _nextState) {
nextState = _nextState;
}
/**
* Adds an element name to the list of this rule
* @param name the name to add
*/
void addElem(const std::string &name);
const ElemList &getElemList() const {
return elemList;
}
int getExitLevel() const {
return exitLevel;
}
void setExitLevel(int l) {
exitLevel = l;
}
bool isNested() const {
return nested;
}
void setNested(bool n) {
nested = n;
}
bool getNeedsReferenceReplacement() const {
return needsReferenceReplacement;
}
void setNeedsReferenceReplacement(bool b = true) {
needsReferenceReplacement = b;
}
bool getHasSubexpressions() const {
return hasSubexpressions;
}
void setHasSubexpressions(bool b = true) {
hasSubexpressions = b;
}
std::string getAdditionalInfo() const {
return additionalInfo;
}
void setAdditionalInfo(const std::string &info) {
additionalInfo = info;
}
};
}
#endif /*HIGHLIGHTRULE_H_*/
|