Changeset: 76c7540199c5 for MonetDB
URL: http://dev.monetdb.org/hg/MonetDB?cmd=changeset;node=76c7540199c5
Modified Files:
monetdb5/mal/Makefile.ag
monetdb5/mal/mal_parser.c
monetdb5/mal/mal_parser.h
monetdb5/mal/mal_parser.mx
Branch: headless
Log Message:
Converted mal_parser.mx to .c.
diffs (truncated from 1326 to 300 lines):
diff --git a/monetdb5/mal/Makefile.ag b/monetdb5/mal/Makefile.ag
--- a/monetdb5/mal/Makefile.ag
+++ b/monetdb5/mal/Makefile.ag
@@ -46,7 +46,7 @@
mal_linker.c \
mal_module.c \
mal_namespace.mx \
- mal_parser.mx \
+ mal_parser.c \
mal_runtime.mx \
mal_profiler.mx \
mal_properties.mx \
@@ -63,4 +63,4 @@
}
EXTRA_DIST_DIR = Tests
-EXTRA_DIST = mal.h mal_builder.h mal_client.h mal_exception.h mal_factory.h
mal_import.h mal_linker.h mal_module.h mal_sabaoth.h mal_session.h mal_stack.h
mal_type.h mal_utils.h mal_xml.h
+EXTRA_DIST = mal.h mal_builder.h mal_client.h mal_exception.h mal_factory.h
mal_import.h mal_linker.h mal_module.h mal_sabaoth.h mal_session.h mal_stack.h
mal_type.h mal_utils.h mal_xml.h mal_parser.h
diff --git a/monetdb5/mal/mal_parser.mx b/monetdb5/mal/mal_parser.c
rename from monetdb5/mal/mal_parser.mx
rename to monetdb5/mal/mal_parser.c
--- a/monetdb5/mal/mal_parser.mx
+++ b/monetdb5/mal/mal_parser.c
@@ -1,55 +1,22 @@
-@/
-The contents of this file are subject to the MonetDB Public License
-Version 1.1 (the "License"); you may not use this file except in
-compliance with the License. You may obtain a copy of the License at
-http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+/*
+ * The contents of this file are subject to the MonetDB Public License
+ * Version 1.1 (the "License"); you may not use this file except in
+ * compliance with the License. You may obtain a copy of the License at
+ * http://monetdb.cwi.nl/Legal/MonetDBLicense-1.1.html
+ *
+ * Software distributed under the License is distributed on an "AS IS"
+ * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
+ * License for the specific language governing rights and limitations
+ * under the License.
+ *
+ * The Original Code is the MonetDB Database System.
+ *
+ * The Initial Developer of the Original Code is CWI.
+ * Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
+ * Copyright August 2008-2011 MonetDB B.V.
+ * All Rights Reserved.
+ */
-Software distributed under the License is distributed on an "AS IS"
-basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
-License for the specific language governing rights and limitations
-under the License.
-
-The Original Code is the MonetDB Database System.
-
-The Initial Developer of the Original Code is CWI.
-Portions created by CWI are Copyright (C) 1997-July 2008 CWI.
-Copyright August 2008-2011 MonetDB B.V.
-All Rights Reserved.
-@
-
-@h
-#ifndef _MAL_PARSER_H
-#define _MAL_PARSER_H
-
-#include "mal_import.h"
-
-#define MAXERRORS 250
-
-#define CURRENT(c) (c->fdin->buf + c->fdin->pos + c->yycur)
-#define currChar(X) (*CURRENT(X))
-#define peekChar(X) (*((X)->fdin->buf + (X)->fdin->pos + (X)->yycur+1))
-#define nextChar(X) X->yycur++
-#define prevChar(X) if(X->yycur) X->yycur--
-
-mal_export void initParser(void); /* needed in src/mal/mal.c */
-mal_export int parseMAL(Client cntxt, Symbol curPrg);
-mal_export void echoInput(Client cntxt);
-mal_export void debugParser(int i);
-mal_export str parseError(Client cntxt, str msg);
-mal_export int idLength(Client cntxt);
-mal_export int stringLength(Client cntxt);
-mal_export int cstToken(Client cntxt, ValPtr val);
-mal_export int charCst(Client cntxt, ValPtr val);
-mal_export int operatorLength(Client cntxt);
-mal_export str operatorCopy(Client cntxt, int length);
-mal_export int MALkeyword(Client cntxt, str kw, int length);
-mal_export int MALlookahead(Client cntxt, str kw, int length);
-mal_export str lastline(Client cntxt);
-mal_export long position(Client cntxt);
-
-#endif /* _MAL_PARSER_H */
-
-@c
/* Author(s): M. L. Kersten
*The Parser Implementation
* The parser (and its target language) are designed for speed of analysis.
@@ -57,17 +24,17 @@
* MonetDB. For the language design it meant that look-ahead and ambiguity
* is avoided where-ever possible without compromising readability and
* to ease debugging.
- *
+ *
* The syntax layout of a MAL program consists of a module name,
* a list of include commands, a list of function/ pattern/ command/ factory
* definitions and concludes with the statements to be executed as
* the main body of the program. All components are optional.
- *
+ *
* The program may be decorated with comments, which starts with a # and
* runs till the end of the current line. Comments are retained
* in the code block for debugging, but can be removed with an optimizer to
reduce space
* and interpretation overhead.
- *
+ *
* @+ The lexical analyzer
* The implementation of the lexical analyzer is straightforward:
* the input is taken from a client input buffer. It is assumed that
@@ -98,8 +65,8 @@
*/
void echoInput(Client cntxt)
{
- if (cntxt->listing == 1) {
- char *c = CURRENT(cntxt);
+ if (cntxt->listing == 1) {
+ char *c = CURRENT(cntxt);
mnstr_printf(cntxt->fdout,"#");
while (*c && !NL(*c)) {
mnstr_printf(cntxt->fdout, "%c", *c++);
@@ -109,7 +76,7 @@
}
}
-static inline void
+static inline void
skipSpace(Client cntxt)
{
char *s= &currChar(cntxt);
@@ -127,7 +94,7 @@
}
}
-static inline void
+static inline void
advance(Client cntxt, int length)
{
cntxt->yycur += length;
@@ -148,7 +115,7 @@
short idCharacter[256];
short idCharacter2[256];
-void
+void
initParser()
{
int i;
@@ -162,8 +129,8 @@
case '-': case '!': case '\\': case '$': case '%':
case '^': case '*': case '~': case '+': case '&':
case '|': case '<': case '>': case '=': case '/':
- case ':':
- opCharacter[i]=1;
+ case ':':
+ opCharacter[i]=1;
}
idCharacter[TMPMARKER]=1;
idCharacter2[TMPMARKER]=1;
@@ -173,7 +140,7 @@
#undef isdigit
#define isdigit(X) ((X)>='0' && (X)<='9')
-int
+int
idLength(Client cntxt)
{
str s,t;
@@ -188,13 +155,13 @@
s[0]= REFMARKER;
/* prepare escape of temporary names */
s++;
- while (idCharacter2[(int) (*s)] )
+ while (idCharacter2[(int) (*s)] )
s++;
return (int) (s-t);
}
/* Simple type identifiers can not be marked with a type variable. */
-int
+int
typeidLength(Client cntxt)
{
int l;
@@ -228,7 +195,7 @@
return s;
}
-int
+int
MALkeyword(Client cntxt, str kw, int length)
{
skipSpace(cntxt);
@@ -239,7 +206,7 @@
return 0;
}
-int
+int
MALlookahead(Client cntxt, str kw, int length)
{
int i;
@@ -267,7 +234,7 @@
* (check manually). To speed this up we use a pipelined and inline macros.
*/
-static inline int
+static inline int
keyphrase1(Client cntxt, str kw)
{
skipSpace(cntxt);
@@ -278,7 +245,7 @@
return 0;
}
-static inline int
+static inline int
keyphrase2(Client cntxt, str kw)
{
skipSpace(cntxt);
@@ -288,7 +255,7 @@
}
return 0;
}
-static inline int
+static inline int
keyphrase(Client cntxt, str kw,int length)
{
skipSpace(cntxt);
@@ -305,7 +272,7 @@
* We should provide the C-method to split strings and
* concatenate them upon retrieval[todo]
*/
-int
+int
stringLength(Client cntxt)
{
int l=0;
@@ -314,12 +281,12 @@
skipSpace(cntxt);
s = CURRENT(cntxt);
- if( *s != '"')
+ if( *s != '"')
return 0;
s++;
while( *s ){
- if( quote ){
- l++;
+ if( quote ){
+ l++;
s++;
quote=0;
} else {
@@ -342,7 +309,7 @@
i = length<4 ? 4: length;
s = GDKzalloc(i);
- if (s == 0)
+ if (s == 0)
return NULL;
memcpy(s, CURRENT(cntxt) + 1, (size_t) (length - 2) );
mal_unquote(s);
@@ -353,7 +320,7 @@
* A lookup table is considered, because it generally is
* faster then a non-dense switch.
*/
-int
+int
operatorLength(Client cntxt)
{
int l=0;
@@ -361,15 +328,15 @@
skipSpace(cntxt);
for (s = CURRENT(cntxt); *s; s++) {
- if( opCharacter[(int)(*s)] )
- l++;
- else
+ if( opCharacter[(int)(*s)] )
+ l++;
+ else
return l;
}
return l;
}
-str
+str
operatorCopy(Client cntxt, int length)
{
return idCopy(cntxt,length);
_______________________________________________
Checkin-list mailing list
[email protected]
http://mail.monetdb.org/mailman/listinfo/checkin-list