Changeset: 13d1f74c2784 for MonetDB
URL: https://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=13d1f74c2784
Modified Files:
        monetdb5/mal/Tests/tst163.stable.err
        monetdb5/mal/Tests/tst275.stable.out
        monetdb5/mal/Tests/tst804.stable.err
        monetdb5/mal/mal_import.c
        monetdb5/mal/mal_import.h
        monetdb5/mal/mal_parser.c
        monetdb5/mal/mal_parser.h
        monetdb5/mal/mal_prelude.c
        monetdb5/mal/mal_prelude.h
        monetdb5/mal/mal_session.c
        monetdb5/mal/mel.h
        sql/backends/monet5/wlr.c
Branch: mbedded
Log Message:

Extend the parse with an optional address for inclusion
Allow for comment strings without quote but ending at ';'
Add missing modules automatically upon need.


diffs (truncated from 426 to 300 lines):

diff --git a/monetdb5/mal/Tests/tst163.stable.err 
b/monetdb5/mal/Tests/tst163.stable.err
--- a/monetdb5/mal/Tests/tst163.stable.err
+++ b/monetdb5/mal/Tests/tst163.stable.err
@@ -20,10 +20,8 @@ QUERY = #multiple atomary types
         j:= i+3;
         io.print(i);
         io.print(j);
-ERROR = !SyntaxException:parseError:atom myint:int;
-        !SyntaxException:parseError:              ^Atom redefinition
-        !SyntaxException:parseError:i:= 1:myint;
-        !SyntaxException:parseError:^';' expected
+ERROR = !TypeException:user.main[3]:'calc.+' undefined in:     j:any := 
calc.+(i:myint, 3:int);
+
 
 # 15:19:56 >  
 # 15:19:56 >  "Done."
diff --git a/monetdb5/mal/Tests/tst275.stable.out 
b/monetdb5/mal/Tests/tst275.stable.out
--- a/monetdb5/mal/Tests/tst275.stable.out
+++ b/monetdb5/mal/Tests/tst275.stable.out
@@ -33,8 +33,8 @@ stdout of test 'tst275` in directory 'mo
 # t    t       t  # name
 # void str     str  # type
 #--------------------------#
-[ 0@0, "batId",        "tmp_267"       ]
-[ 1@0, "batCacheid",   "183"   ]
+[ 0@0, "batId",        "tmp_1004"      ]
+[ 1@0, "batCacheid",   "516"   ]
 [ 2@0, "tparentid",    "0"     ]
 [ 3@0, "batSharecnt",  "0"     ]
 [ 4@0, "batCount",     "0"     ]
@@ -66,10 +66,10 @@ stdout of test 'tst275` in directory 'mo
 [ 30@0,        "batDirtydesc", "dirty" ]
 [ 31@0,        "theap.dirty",  "clean" ]
 [ 32@0,        "tail.free",    "0"     ]
-[ 33@0,        "tail.size",    "1024"  ]
-[ 34@0,        "tail.storage", "malloced"      ]
-[ 35@0,        "tail.newstorage",      "malloced"      ]
-[ 36@0,        "tail.filename",        "02/267.tail"   ]
+[ 33@0,        "0",    "1024"  ]
+[ 34@0,        "1024", "malloced"      ]
+[ 35@0,        "1024", "malloced"      ]
+[ 36@0,        "1024", "10/1004.tail"  ]
 [ 37@0,        "tvheap->dirty",        "clean" ]
 #~EndVariableOutput~#
 #--------------------------#
diff --git a/monetdb5/mal/Tests/tst804.stable.err 
b/monetdb5/mal/Tests/tst804.stable.err
--- a/monetdb5/mal/Tests/tst804.stable.err
+++ b/monetdb5/mal/Tests/tst804.stable.err
@@ -40,10 +40,8 @@ QUERY = # test definiton of a function i
                wrong.message();
                wrongTo.message();
         end foo;
-ERROR = !SyntaxException:parseError:function wrong.message():void;
-        !SyntaxException:parseError:                      ^<module> name not 
defined
-        !SyntaxException:parseError:end message;
-        !SyntaxException:parseError:   ^non matching end label
+ERROR = !TypeException:user.foo[2]:'wrongTo.message' undefined in:     
wrongTo.message();
+
 
 # 15:26:53 >  
 # 15:26:53 >  "Done."
diff --git a/monetdb5/mal/mal_import.c b/monetdb5/mal/mal_import.c
--- a/monetdb5/mal/mal_import.c
+++ b/monetdb5/mal/mal_import.c
@@ -142,7 +142,7 @@ malLoadScript(str name, bstream **fdin)
        restoreClient2
 
 str
-malIncludeString(Client c, const str name, const str mal, int listing) 
+malIncludeString(Client c, const str name, const str mal, int listing, MALfcn 
address) 
 {
        str msg = MAL_SUCCEED;
 
@@ -185,7 +185,7 @@ malIncludeString(Client c, const str nam
                throw(MAL, "malIncludeString", MAL_MALLOC_FAIL);
        }
        bstream_next(c->fdin);
-       parseMAL(c, c->curprg, 1, INT_MAX);
+       parseMAL(c, c->curprg, 1, INT_MAX, address);
        bstream_destroy(c->fdin);
        c->fdin = NULL;
        GDKfree(mal_buf);
@@ -234,7 +234,7 @@ malInclude(Client c, str name, int listi
                        c->yycur = 0;
                        c->bak = NULL;
                        if ((msg = malLoadScript(filename, &c->fdin)) == 
MAL_SUCCEED) {
-                               parseMAL(c, c->curprg, 1, INT_MAX);
+                               parseMAL(c, c->curprg, 1, INT_MAX, 0);
                                bstream_destroy(c->fdin);
                        } else {
                                /* TODO output msg ? */
diff --git a/monetdb5/mal/mal_import.h b/monetdb5/mal/mal_import.h
--- a/monetdb5/mal/mal_import.h
+++ b/monetdb5/mal/mal_import.h
@@ -15,7 +15,7 @@
 #include "mal_utils.h"
 #include "mal_prelude.h"
 
-mal_export str malIncludeString(Client c, const str name, const str mal, int 
listing);
+mal_export str malIncludeString(Client c, const str name, const str mal, int 
listing, MALfcn address);
 
 mal_export str malInclude(Client c, str name, int listing);
 mal_export void slash_2_dir_sep(str fname);
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
@@ -785,17 +785,29 @@ static void
 helpInfo(Client cntxt, str *help)
 {
        int l;
+       char c, *e, *s;
 
        if (MALkeyword(cntxt, "comment", 7)) {
                skipSpace(cntxt);
-               if ((l = stringLength(cntxt))) {
-                       GDKfree(*help);
+               // The comment is either a quoted string or all characters up 
to the next semicolon
+               c = currChar(cntxt);
+               if (c != '"'){
+                       e = s = CURRENT(cntxt);
+                       for (;*e; l++, e++) 
+                               if (*e == ';')
+                                       break;
                        *help = strCopy(cntxt, l);
-                       if (*help)
-                               advance(cntxt, l - 1);
                        skipToEnd(cntxt);
                } else {
-                       parseError(cntxt, "<string> expected\n");
+                       if ((l = stringLength(cntxt))) {
+                               GDKfree(*help);
+                               *help = strCopy(cntxt, l);
+                               if (*help)
+                                       advance(cntxt, l - 1);
+                               skipToEnd(cntxt);
+                       } else {
+                               parseError(cntxt, "<string> expected\n");
+                       }
                }
        } else if (currChar(cntxt) != ';')
                parseError(cntxt, "';' expected\n");
@@ -964,9 +976,7 @@ parseAtom(Client cntxt)
                tpe = TYPE_void;  /* no type qualifier */
        else
                tpe = parseTypeId(cntxt, TYPE_int);
-       if( ATOMindex(modnme) >= 0)
-               parseError(cntxt, "Atom redefinition\n");
-       else {
+       if( ATOMindex(modnme) < 0) {
                if(cntxt->curprg->def->errors)
                        GDKfree(cntxt->curprg->def->errors);
                cntxt->curprg->def->errors = malAtomDefinition(modnme, tpe);
@@ -1105,8 +1115,10 @@ fcnHeader(Client cntxt, int kind)
                nextChar(cntxt); /* skip '.' */
                modnme = fnme;
                if( strcmp(modnme,"user") && getModule(modnme) == NULL){
-                       parseError(cntxt, "<module> name not defined\n");
-                       return 0;
+                       if( globalModule(modnme) == NULL){
+                               parseError(cntxt, "<module> name not 
defined\n");
+                               return 0;
+                       }
                }
                l = operatorLength(cntxt);
                if (l == 0)
@@ -1255,7 +1267,7 @@ fcnHeader(Client cntxt, int kind)
 }
 
 static MalBlkPtr
-parseCommandPattern(Client cntxt, int kind)
+parseCommandPattern(Client cntxt, int kind, MALfcn address)
 {
        MalBlkPtr curBlk = 0;
        Symbol curPrg = 0;
@@ -1276,9 +1288,11 @@ parseCommandPattern(Client cntxt, int ki
 
        modnme = getModuleId(getInstrPtr(curBlk, 0));
        if (modnme && (getModule(modnme) == FALSE && strcmp(modnme,"user"))){
-               parseError(cntxt, "<module> not defined\n");
-               cntxt->blkmode = 0;
-               return curBlk;
+               // introduce the module
+               if( globalModule(modnme) == NULL){
+                       parseError(cntxt, "<module> could not be defined\n");
+                       return 0;
+               }
        }
        modnme = modnme ? modnme : cntxt->usermodule->name;
 
@@ -1317,6 +1331,7 @@ parseCommandPattern(Client cntxt, int ki
  * [note, command and patterns do not have a MAL block]
  */
        if (MALkeyword(cntxt, "address", 7)) {
+               /* TO BE DEPRECATED */
                int i;
                i = idLength(cntxt);
                if (i == 0) {
@@ -1343,10 +1358,12 @@ parseCommandPattern(Client cntxt, int ki
                        malAtomProperty(curBlk, curInstr);
                }
                skipSpace(cntxt);
-       } else {
-               parseError(cntxt, "'address' expected\n");
-               return 0;
-       }
+       } else
+       if(address){
+               setModuleScope(curInstr, findModule(cntxt->usermodule, modnme));
+               setModuleId(curInstr, modnme);
+               curInstr->fcn = address;
+       }
        helpInfo(cntxt, &curBlk->help);
 #ifdef HAVE_HGE
        if (!have_hge)
@@ -1364,6 +1381,7 @@ parseFunction(Client cntxt, int kind)
        if (curBlk == NULL)
                return curBlk;
        if (MALkeyword(cntxt, "address", 7)) {
+               /* TO BE DEPRECATED */
                str nme;
                int i;
                InstrPtr curInstr = getInstrPtr(curBlk, 0);
@@ -1384,7 +1402,7 @@ parseFunction(Client cntxt, int kind)
                        return 0;
                }
                skipSpace(cntxt);
-       }
+       } 
        /* block is terminated at the END statement */
        helpInfo(cntxt, &curBlk->help);
        return curBlk;
@@ -1758,7 +1776,7 @@ part3:
 }
 
 void
-parseMAL(Client cntxt, Symbol curPrg, int skipcomments, int lines)
+parseMAL(Client cntxt, Symbol curPrg, int skipcomments, int lines, MALfcn 
address)
 {
        int cntrl = 0;
        /*Symbol curPrg= cntxt->curprg;*/
@@ -1842,7 +1860,7 @@ parseMAL(Client cntxt, Symbol curPrg, in
                        goto allLeft;
                case 'C': case 'c':
                        if (MALkeyword(cntxt, "command", 7)) {
-                               MalBlkPtr p = parseCommandPattern(cntxt, 
COMMANDsymbol);
+                               MalBlkPtr p = parseCommandPattern(cntxt, 
COMMANDsymbol, address);
                                if (p) {
                                        p->unsafeProp = unsafeProp;
                                }
@@ -1917,7 +1935,7 @@ parseMAL(Client cntxt, Symbol curPrg, in
                                MalBlkPtr p;
                                if( inlineProp )
                                        parseError(cntxt, "parseError:INLINE 
ignored\n");
-                               p = parseCommandPattern(cntxt, PATTERNsymbol);
+                               p = parseCommandPattern(cntxt, PATTERNsymbol, 
address);
                                if (p) {
                                        p->unsafeProp = unsafeProp;
                                }
diff --git a/monetdb5/mal/mal_parser.h b/monetdb5/mal/mal_parser.h
--- a/monetdb5/mal/mal_parser.h
+++ b/monetdb5/mal/mal_parser.h
@@ -20,7 +20,7 @@
 #define prevChar(X) if(X->yycur) X->yycur--
 
 mal_export void initParser(void);   /* needed in src/mal/mal.c */
-mal_export void parseMAL(Client cntxt, Symbol curPrg, int skipcomments, int 
lines);
+mal_export void parseMAL(Client cntxt, Symbol curPrg, int skipcomments, int 
lines, MALfcn address);
 
 #endif /* _MAL_PARSER_H */
 
diff --git a/monetdb5/mal/mal_prelude.c b/monetdb5/mal/mal_prelude.c
--- a/monetdb5/mal/mal_prelude.c
+++ b/monetdb5/mal/mal_prelude.c
@@ -6,7 +6,7 @@
  * Copyright 1997 - July 2008 CWI, August 2008 - 2020 MonetDB B.V.
  */
 
-/* Author(s) M.L. Kersten
+/* Author(s) M.L. Kersten, N. Nes
  * This module takes the statically defined modules, atoms, commands and 
patterns
  * and populate the internal structures.
  *
@@ -34,6 +34,11 @@ static int mal_modules = 0;
 static str mal_module_name[MAX_MAL_MODULES] = {0};
 static unsigned char *mal_module_code[MAX_MAL_MODULES] = {0};
 
+#ifdef SPECS
+static int mal_limit = 0;
+static mal_spec *mal_specs[MAX_MAL_MODULES] = {0};
+#endif
+
 int
 mal_startup(void)
 {
@@ -48,13 +53,23 @@ mal_startup(void)
 */
 
 void
+#ifdef SPECS
+mal_module(str name, mel_atom *atoms, mel_func *funcs, mal_spec *specs)
_______________________________________________
checkin-list mailing list
checkin-list@monetdb.org
https://www.monetdb.org/mailman/listinfo/checkin-list

Reply via email to