Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Q
qt-creator
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Tobias Hunger
qt-creator
Commits
81cac3cc
Commit
81cac3cc
authored
15 years ago
by
Roberto Raggi
Browse files
Options
Downloads
Patches
Plain Diff
Introduced BackwardsScanner::LA(n). LA(n) returns the n-th lookhead token.
parent
8ce39a8a
No related branches found
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
src/libs/cplusplus/BackwardsScanner.cpp
+8
-3
8 additions, 3 deletions
src/libs/cplusplus/BackwardsScanner.cpp
src/libs/cplusplus/BackwardsScanner.h
+6
-1
6 additions, 1 deletion
src/libs/cplusplus/BackwardsScanner.h
with
14 additions
and
4 deletions
src/libs/cplusplus/BackwardsScanner.cpp
+
8
−
3
View file @
81cac3cc
...
@@ -45,6 +45,8 @@ BackwardsScanner::BackwardsScanner(const QTextCursor &cursor, const QString &suf
...
@@ -45,6 +45,8 @@ BackwardsScanner::BackwardsScanner(const QTextCursor &cursor, const QString &suf
_text
+=
suffix
;
_text
+=
suffix
;
_tokens
.
append
(
_tokenize
(
_text
,
previousBlockState
(
_block
)));
_tokens
.
append
(
_tokenize
(
_text
,
previousBlockState
(
_block
)));
_startToken
=
_tokens
.
size
();
}
}
int
BackwardsScanner
::
state
()
const
int
BackwardsScanner
::
state
()
const
...
@@ -53,8 +55,11 @@ int BackwardsScanner::state() const
...
@@ -53,8 +55,11 @@ int BackwardsScanner::state() const
const
QList
<
SimpleToken
>
&
BackwardsScanner
::
tokens
()
const
const
QList
<
SimpleToken
>
&
BackwardsScanner
::
tokens
()
const
{
return
_tokens
;
}
{
return
_tokens
;
}
const
SimpleToken
&
BackwardsScanner
::
operator
[](
int
i
)
const
const
SimpleToken
&
BackwardsScanner
::
LA
(
int
index
)
const
{
return
const_cast
<
BackwardsScanner
*>
(
this
)
->
fetchToken
(
i
);
}
{
return
const_cast
<
BackwardsScanner
*>
(
this
)
->
fetchToken
(
_startToken
-
index
);
}
const
SimpleToken
&
BackwardsScanner
::
operator
[](
int
index
)
const
{
return
const_cast
<
BackwardsScanner
*>
(
this
)
->
fetchToken
(
index
);
}
const
SimpleToken
&
BackwardsScanner
::
fetchToken
(
int
i
)
const
SimpleToken
&
BackwardsScanner
::
fetchToken
(
int
i
)
{
{
...
@@ -89,7 +94,7 @@ const SimpleToken &BackwardsScanner::fetchToken(int i)
...
@@ -89,7 +94,7 @@ const SimpleToken &BackwardsScanner::fetchToken(int i)
}
}
int
BackwardsScanner
::
startToken
()
const
int
BackwardsScanner
::
startToken
()
const
{
return
_
tokens
.
size
()
;
}
{
return
_
startToken
;
}
int
BackwardsScanner
::
startPosition
()
const
int
BackwardsScanner
::
startPosition
()
const
{
return
_block
.
position
();
}
{
return
_block
.
position
();
}
...
...
This diff is collapsed.
Click to expand it.
src/libs/cplusplus/BackwardsScanner.h
+
6
−
1
View file @
81cac3cc
...
@@ -54,7 +54,11 @@ public:
...
@@ -54,7 +54,11 @@ public:
QString
text
(
int
begin
,
int
end
)
const
;
QString
text
(
int
begin
,
int
end
)
const
;
QStringRef
textRef
(
int
begin
,
int
end
)
const
;
QStringRef
textRef
(
int
begin
,
int
end
)
const
;
const
SimpleToken
&
operator
[](
int
i
)
const
;
// 1-based
const
SimpleToken
&
LA
(
int
index
)
const
;
// n-la token is [startToken - n]
const
SimpleToken
&
operator
[](
int
index
)
const
;
// ### deprecate
int
startOfMatchingBrace
(
int
index
)
const
;
int
startOfMatchingBrace
(
int
index
)
const
;
int
previousBlockState
(
const
QTextBlock
&
block
)
const
;
int
previousBlockState
(
const
QTextBlock
&
block
)
const
;
...
@@ -71,6 +75,7 @@ private:
...
@@ -71,6 +75,7 @@ private:
QString
_text
;
QString
_text
;
SimpleLexer
_tokenize
;
SimpleLexer
_tokenize
;
int
_maxBlockCount
;
int
_maxBlockCount
;
int
_startToken
;
};
};
}
// end of namespace CPlusPlus
}
// end of namespace CPlusPlus
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment