edbee - Qt Editor Library
grammartextlexer.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 #include <QMap>
9 #include <QList>
10 #include <QRegExp>
11 #include <QVector>
12 
13 #include "edbee/models/textlexer.h"
14 
15 namespace edbee {
16 
17 class MultiLineScopedTextRange;
18 class RegExp;
19 class ScopedTextRange;
20 class ScopedTextRangeList;
21 class TextDocumentScopes;
22 class TextGrammar;
23 class TextGrammarRule;
24 
27 {
28 public:
30  virtual ~GrammarTextLexer();
31 
32  virtual void textChanged( const TextBufferChange& change );
33 
34 private:
35  virtual bool lexLine(int line, int& currentDocOffset );
36 
37 public:
38  virtual void lexLines( int line, int lineCount );
39  virtual void lexRange( int beginOffset, int endOffset );
40 
41 private:
42 
43  RegExp* createEndRegExp( RegExp* startRegExp, const QString &endRegExpStringIn);
44 
45  void findNextGrammarRule(const QString &line, int offsetInLine, TextGrammarRule *activeRule, TextGrammarRule *&foundRule, RegExp*& foundRegExp, int& foundPosition );
46  void processCaptures( RegExp *foundRegExp, const QMap<int,QString>* foundCaptures );
47 
48  TextGrammarRule* findAndApplyNextGrammarRule(int currentDocOffset, const QString& line, int& offsetInLine );
49 
50  MultiLineScopedTextRange* activeMultiLineRange();
51  ScopedTextRange* activeScopedTextRange();
52 
53  void popActiveRange();
54  void pushActiveRange( ScopedTextRange* range, MultiLineScopedTextRange* multiRange );
55 
56  TextGrammarRule* findIncludeGrammarRule( TextGrammarRule* base );
57 
58 private:
59 
60  QVector<MultiLineScopedTextRange*> activeMultiLineRangesRefList_;
61  QVector<MultiLineScopedTextRange*> currentMultiLineRangeList_;
62  QVector<MultiLineScopedTextRange*> closedMultiRangesRangesRefList_;
63 
64  QVector<ScopedTextRange*> activeScopedRangesRefList_;
65 
66 // QVector<MultiLineScopedTextRange*> currentLineRangesList_; ///< The current scope ranges (only valid during parsing)
67 
68  ScopedTextRangeList* lineRangeList_;
69 
70 };
71 
72 } // edbee
virtual void lexRange(int beginOffset, int endOffset)
This method is called when the given range needs to be lexed.
Definition: grammartextlexer.cpp:514
This clas represents a text buffer change and is used to pass around between events This is a sharedd...
Definition: textbuffer.h:45
virtual ~GrammarTextLexer()
The destructor.
Definition: grammartextlexer.cpp:32
This class &#39;defines&#39; a single document scope.
Definition: textdocumentscopes.h:257
defines a single grammar rule
Definition: textgrammar.h:24
A simple lexer matches texts with simple regular expressions.
Definition: grammartextlexer.h:26
GrammarTextLexer(TextDocumentScopes *scopes)
Constructs the grammar textlexer.
Definition: grammartextlexer.cpp:23
virtual void textChanged(const TextBufferChange &change)
This method is called to notify the lexer some data has been changed.
Definition: grammartextlexer.cpp:341
Copyright 2011-2013 - Reliable Bits Software by Blommers IT.
Definition: commentcommand.cpp:22
A class for matching QStrings with the Oniguruma API We need this Regular Expression library to be ab...
Definition: regexp.h:36
a list of textscopes This class is used for single-line scopes (Todo, this needs to be optimized) ...
Definition: textdocumentscopes.h:223
A base scoped text range.
Definition: textdocumentscopes.h:178
This class is used to &#39;contain&#39; all document scope information.
Definition: textdocumentscopes.h:325
virtual void lexLines(int line, int lineCount)
This method lexes a range of line.
Definition: grammartextlexer.cpp:456
This is a single lexer.
Definition: textlexer.h:17