summaryrefslogtreecommitdiff
path: root/colm/ctinput.cpp
diff options
context:
space:
mode:
authorAdrian Thurston <thurston@complang.org>2010-04-12 23:42:41 +0000
committerAdrian Thurston <thurston@complang.org>2010-04-12 23:42:41 +0000
commitff7a0d7a00f6bfee39d2e745ef852555bb1db8c4 (patch)
tree53de9982e968cb8a1b3721a4c66efe4a93a78493 /colm/ctinput.cpp
parent9da9ca0610627b475e2af7f4b6b0d810dabb250a (diff)
downloadcolm-ff7a0d7a00f6bfee39d2e745ef852555bb1db8c4.tar.gz
More porting to the InputFuncs struct.
Diffstat (limited to 'colm/ctinput.cpp')
-rw-r--r--colm/ctinput.cpp86
1 files changed, 21 insertions, 65 deletions
diff --git a/colm/ctinput.cpp b/colm/ctinput.cpp
index 3b970782..0f7742c6 100644
--- a/colm/ctinput.cpp
+++ b/colm/ctinput.cpp
@@ -32,6 +32,16 @@ InputFuncs replFuncs;
* Implementation
*/
+bool inputStreamStaticIsTree( InputStream *is )
+{
+ return false;
+}
+
+bool inputStreamStaticIsIgnore( InputStream *is )
+{
+ return false;
+}
+
bool InputStreamStatic::tryAgainLater()
{
@@ -44,6 +54,8 @@ bool InputStreamStatic::tryAgainLater()
void initStaticFuncs()
{
memcpy( &staticFuncs, &baseFuncs, sizeof(InputFuncs) );
+ staticFuncs.isTree = &inputStreamStaticIsTree;
+ staticFuncs.isIgnore = &inputStreamStaticIsIgnore;
}
@@ -61,9 +73,10 @@ InputStreamPattern::InputStreamPattern( Pattern *pattern )
funcs = &patternFuncs;
}
-bool InputStreamPattern::isLangEl()
+bool inputStreamPatternIsLangEl( InputStream *_is )
{
- return patItem != 0 && patItem->type == PatternItem::FactorType;
+ InputStreamPattern *is = (InputStreamPattern*) _is;
+ return is->patItem != 0 && is->patItem->type == PatternItem::FactorType;
}
int InputStreamPattern::shouldFlush()
@@ -114,36 +127,6 @@ int inputStreamPatternGetData( InputStream *_is, char *dest, int length )
return length;
}
-#if 0
-int InputStreamPattern::getData( char *dest, int length )
-{
- if ( offset == 0 )
- line = patItem->loc.line;
-
- assert ( patItem->type == PatternItem::InputText );
- int available = patItem->data.length() - offset;
-
- if ( available < length )
- length = available;
-
- memcpy( dest, patItem->data.data+offset, length );
- offset += length;
-
- if ( offset == patItem->data.length() ) {
- /* Read up to the end of the data. Advance the
- * pattern item. */
- patItem = patItem->next;
- offset = 0;
- flush = shouldFlush();
- }
- else {
- /* There is more data in this buffer. Don't flush. */
- flush = false;
- }
- return length;
-}
-#endif
-
int InputStreamPattern::isEof()
{
return patItem == 0;
@@ -194,6 +177,7 @@ void initPatternFuncs()
{
memcpy( &patternFuncs, &staticFuncs, sizeof(InputFuncs) );
patternFuncs.getData = &inputStreamPatternGetData;
+ patternFuncs.isLangEl = &inputStreamPatternIsLangEl;
}
@@ -211,10 +195,11 @@ InputStreamRepl::InputStreamRepl( Replacement *replacement )
funcs = &replFuncs;
}
-bool InputStreamRepl::isLangEl()
+bool inputStreamReplIsLangEl( InputStream *_is )
{
- return replItem != 0 && ( replItem->type == ReplItem::ExprType ||
- replItem->type == ReplItem::FactorType );
+ InputStreamRepl *is = (InputStreamRepl*)_is;
+ return is->replItem != 0 && ( is->replItem->type == ReplItem::ExprType ||
+ is->replItem->type == ReplItem::FactorType );
}
int InputStreamRepl::shouldFlush()
@@ -281,36 +266,6 @@ int inputStreamReplGetData( InputStream *_is, char *dest, int length )
return length;
}
-#if 0
-int InputStreamRepl::getData( char *dest, int length )
-{
- if ( offset == 0 )
- line = replItem->loc.line;
-
- assert ( replItem->type == ReplItem::InputText );
- int available = replItem->data.length() - offset;
-
- if ( available < length )
- length = available;
-
- memcpy( dest, replItem->data.data+offset, length );
- offset += length;
-
- if ( offset == replItem->data.length() ) {
- /* Read up to the end of the data. Advance the
- * replacement item. */
- replItem = replItem->next;
- offset = 0;
- flush = shouldFlush();
- }
- else {
- /* There is more data in this buffer. Don't flush. */
- flush = false;
- }
- return length;
-}
-#endif
-
int InputStreamRepl::isEof()
{
return replItem == 0;
@@ -396,4 +351,5 @@ void initReplFuncs()
{
memcpy( &replFuncs, &staticFuncs, sizeof(InputFuncs) );
replFuncs.getData = &inputStreamReplGetData;
+ replFuncs.isLangEl = &inputStreamReplIsLangEl;
}