Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
32138324
Commit
32138324
authored
Oct 05, 2010
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
enhance and better document PopReader()
parent
9f4e57d4
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
30 additions
and
10 deletions
+30
-10
dsnlexer.cpp
common/dsnlexer.cpp
+17
-7
dsnlexer.h
include/dsnlexer.h
+13
-3
No files found.
common/dsnlexer.cpp
View file @
32138324
...
...
@@ -57,9 +57,6 @@ void DSNLEXER::init()
space_in_quoted_tokens
=
true
;
commentsAreTokens
=
false
;
limit
=
start
;
next
=
start
;
}
...
...
@@ -90,15 +87,28 @@ void DSNLEXER::PushReader( LINE_READER* aLineReader )
readerStack
.
push_back
(
aLineReader
);
reader
=
aLineReader
;
start
=
(
char
*
)
(
*
aLineReader
);
// force a new readLine() as first thing.
limit
=
start
;
next
=
start
;
}
void
DSNLEXER
::
PopReader
()
bool
DSNLEXER
::
PopReader
()
{
readerStack
.
pop_back
();
reader
=
&
readerStack
.
back
();
if
(
reader
)
// the very last reader cannot be popped, for that would screw up limit and next.
if
(
readerStack
.
size
()
>=
2
)
{
readerStack
.
pop_back
();
reader
=
&
readerStack
.
back
();
start
=
(
char
*
)
(
*
reader
);
// force a new readLine() as first thing.
limit
=
start
;
next
=
start
;
}
}
...
...
include/dsnlexer.h
View file @
32138324
...
...
@@ -172,8 +172,12 @@ public:
/**
* Function PushReader
* manages a stack of LINE_READERs in order to handle nested file inclusion.
*
P
ushes aLineReader onto the top of a stack of LINE_READERs and makes
*
This function p
ushes aLineReader onto the top of a stack of LINE_READERs and makes
* it the current LINE_READER with its own GetSource(), line number and line text.
* A grammar must be designed such that the "include" token (whatever its various names),
* and any of its parameters are not followed by anything on that same line,
* because PopReader always starts reading from a new line upon returning to
* the original LINE_READER.
*/
void
PushReader
(
LINE_READER
*
aLineReader
);
...
...
@@ -183,9 +187,15 @@ public:
* in the case of FILE_LINE_READER this means the associated FILE is closed.
* The most recently used former LINE_READER on the stack becomes the
* current LINE_READER and its previous position in its input stream and the
* its latest line number should pertain.
* its latest line number should pertain. PopReader always starts reading
* from a new line upon returning to the previous LINE_READER. A pop is only
* possible if there are at least 2 LINE_READERs on the stack, since popping
* the last one is not supported.
*
* @return bool - true if there was at least two readers on the stack and
* therefore the pop succeeded, else false and the pop failed.
*/
void
PopReader
();
bool
PopReader
();
// Some functions whose return value is best overloaded to return an enum
// in a derived class.
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment