Changeset: 7596acfb3bef for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=7596acfb3bef
Modified Files:
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_session.c
Branch: malparsing
Log Message:
Handle console and mclient input
diffs (111 lines):
diff --git a/monetdb5/mal/mal_parser.c b/monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.c
+++ b/monetdb5/mal/mal_parser.c
@@ -1468,9 +1468,11 @@ parseMAL(Client cntxt)
while(*cntxt->lineptr && cntxt->curprg->def->errors == NULL){
switch (*cntxt->lineptr) {
case '\n': case '\r': case '\f':
+ // end of the instruction
+ break;
case ';':
- // end of the instruction
- return 0;
+ advance(cntxt,1);
+ break;
case 'A': case 'a':
if ( MALkeyword(cntxt, "atom", 4) ){
parseAtom(cntxt);
@@ -1497,6 +1499,7 @@ parseMAL(Client cntxt)
if( msg != MAL_SUCCEED)
parseError(cntxt,msg);
}
+ skipSpace(cntxt);
return 0;
}
if (MALkeyword(cntxt, "catch", 5)) {
@@ -1511,6 +1514,7 @@ parseMAL(Client cntxt)
cntxt->blkmode--;
cntrl = EXITsymbol;
} else if (parseEnd(cntxt)) {
+ skipSpace(cntxt);
return 1;
}
goto allLeft;
@@ -1560,6 +1564,7 @@ parseMAL(Client cntxt)
case 'M': case 'm':
if (MALkeyword(cntxt, "module", 6) ){
parseModule(cntxt);
+ skipSpace(cntxt);
return 0;
}
goto allLeft;
@@ -1580,6 +1585,7 @@ parseMAL(Client cntxt)
if( msg != MAL_SUCCEED)
parseError(cntxt,msg);
}
+ skipSpace(cntxt);
return 0;
}
goto allLeft;
@@ -1618,6 +1624,7 @@ parseMAL(Client cntxt)
parseStatement(cntxt, cntrl);
}
}
+ skipSpace(cntxt);
return 0;
}
diff --git a/monetdb5/mal/mal_session.c b/monetdb5/mal/mal_session.c
--- a/monetdb5/mal/mal_session.c
+++ b/monetdb5/mal/mal_session.c
@@ -563,15 +563,18 @@ MALreader(Client c)
if( c->fdin == 0)
throw(MAL,"mal.reader","missing input");
do{
- blocked = isa_block_stream(c->fdin->s);
+ blocked = isa_block_stream(c->fdin->s);
if(c->fdin->pos >= c->fdin->len ){
ssize_t nr = 0;
if(c->fdin->eof && c->prompt ){
if (!blocked)
mnstr_write(c->fdout, c->prompt,
strlen(c->prompt), 1);
mnstr_flush(c->fdout);
-
c->fdin->eof = 0;
+ } else
+ if( ! blocked && c->prompt){
+ mnstr_write(c->fdout, c->prompt,
strlen(c->prompt), 1);
+ mnstr_flush(c->fdout);
}
if((nr = bstream_next(c->fdin)) < 0 || (!blocked &&
c->fdin->eof)){
if (c->bak){
@@ -633,15 +636,13 @@ MALreader(Client c)
mnstr_printf(c->fdout,"%c", *l);
if( string)
continue;
- if ( *l == ';'){
+ if ( *l == ';' || *l == '#'){
+ if ( *l == '#' ){
+ c->linefill--;
+ s--;
+ }
*s = 0;
- return MAL_SUCCEED;
- }
- if ( *l == '#' ){
// eat everything away until end of line
- c->linefill--;
- s--;
- *s = 0;
for( l++ ; c->fdin->pos < c->fdin->len ; l++){
if ( c->listing)
mnstr_printf(c->fdout,"%c", *l);
@@ -653,7 +654,7 @@ MALreader(Client c)
}
}
*s = 0;
- } while (c->fdin->eof == 0);
+ } while (c->fdin->eof == 0 || blocked);
return MAL_SUCCEED;
}
_______________________________________________
checkin-list mailing list
[email protected]
https://www.monetdb.org/mailman/listinfo/checkin-list