rev 224 - in trunk: . bison include/prothon modules/File modules/Float modules/List modules/Re modules/String modules/Tuple pr src
SVN User <[email protected]>
| Newsgroups | gmane.comp.lang.prothon.cvs |
|---|---|
| Message-ID | <[email protected]> |
Author: mark
Date: 2004-03-31 01:14:45 -0500 (Wed, 31 Mar 2004)
New Revision: 224
Modified:
trunk/STATUS.txt
trunk/bison/bison.simple
trunk/include/prothon/prothon.h
trunk/include/prothon/prothon_dll.h
trunk/modules/File/File.c
trunk/modules/Float/Float.c
trunk/modules/List/List.c
trunk/modules/Re/Re.c
trunk/modules/String/String.c
trunk/modules/Tuple/Tuple.c
trunk/pr/hex.pr
trunk/pr/re_test.pr
trunk/src/builtins.c
trunk/src/console.c
trunk/src/interp.c
trunk/src/object.c
trunk/src/parser.h
trunk/src/parser_routines.c
trunk/src/prothon.y
trunk/src/symbol.c
trunk/src/sys.c
Log:
Enabled support for tab indents or space indents,
added var? to lexer, changed all func names that answer
true or false to end in ?, such as __eq_? (__eq__QUES)
Modified: trunk/STATUS.txt
===================================================================
--- trunk/STATUS.txt 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/STATUS.txt 2004-03-31 06:14:45 UTC (rev 224)
@@ -39,10 +39,6 @@
----------------------- TO-DO (highest priority first) ------------------------
---- implement new space/tab indent scheme
-
---- add var? form to lexer
-
--- make print a function
--- write and publish prothon directives
Modified: trunk/bison/bison.simple
===================================================================
--- trunk/bison/bison.simple 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/bison/bison.simple 2004-03-31 06:14:45 UTC (rev 224)
@@ -253,7 +253,7 @@
#if YYDEBUG != 0
if (yydebug)
- fprintf(stderr, "Starting parse\n");
+ printf("Starting parse\n");
#endif
yystate = 0;
@@ -342,7 +342,7 @@
#if YYDEBUG != 0
if (yydebug)
- fprintf(stderr, "Stack size increased to %d\n", yystacksize);
+ printf("Stack size increased to %d\n", yystacksize);
#endif
if (yyssp >= yyss + yystacksize - 1)
@@ -351,7 +351,7 @@
#if YYDEBUG != 0
if (yydebug)
- fprintf(stderr, "Entering state %d\n", yystate);
+ printf("Entering state %d\n", yystate);
#endif
goto yybackup;
@@ -376,7 +376,7 @@
{
#if YYDEBUG != 0
if (yydebug)
- fprintf(stderr, "Reading a token: ");
+ printf("Reading a token: ");
#endif
yychar = YYLEX;
}
@@ -390,7 +390,7 @@
#if YYDEBUG != 0
if (yydebug)
- fprintf(stderr, "Now at end of input.\n");
+ printf("Now at end of input.\n");
#endif
}
else
@@ -400,13 +400,13 @@
#if YYDEBUG != 0
if (yydebug)
{
- fprintf (stderr, "Next token is %d (%s", yychar, yytname[yychar1]);
+ printf("Next token is %d (%s", yychar, yytname[yychar1]);
/* Give the individual parser a way to print the precise meaning
of a token, for further debugging info. */
#ifdef YYPRINT
YYPRINT (stderr, yychar, yylval);
#endif
- fprintf (stderr, ")\n");
+ printf(")\n");
}
#endif
}
@@ -441,7 +441,7 @@
#if YYDEBUG != 0
if (yydebug)
- fprintf(stderr, "Shifting token %d (%s), ", yychar, yytname[yychar1]);
+ printf("Shifting token %d (%s), ", yychar, yytname[yychar1]);
#endif
/* Discard the token being shifted unless it is eof. */
@@ -477,13 +477,13 @@
{
int i;
- fprintf (stderr, "Reducing via rule %d (line %d), ",
+ printf("Reducing via rule %d (line %d), ",
yyn, yyrline[yyn]);
/* Print the symbols being reduced, and their result. */
for (i = yyprhs[yyn]; yyrhs[i] > 0; i++)
- fprintf (stderr, "%s ", yytname[yyrhs[i]]);
- fprintf (stderr, " -> %s\n", yytname[yyr1[yyn]]);
+ printf("%s ", yytname[yyrhs[i]]);
+ printf(" -> %s\n", yytname[yyr1[yyn]]);
}
#endif
@@ -500,10 +500,10 @@
if (yydebug)
{
short *ssp1 = yyss - 1;
- fprintf (stderr, "state stack now");
+ printf("state stack now");
while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
+ printf(" %d", *++ssp1);
+ printf("\n");
}
#endif
@@ -605,7 +605,7 @@
#if YYDEBUG != 0
if (yydebug)
- fprintf(stderr, "Discarding token %d (%s).\n", yychar, yytname[yychar1]);
+ printf("Discarding token %d (%s).\n", yychar, yytname[yychar1]);
#endif
yychar = YYEMPTY;
@@ -640,10 +640,10 @@
if (yydebug)
{
short *ssp1 = yyss - 1;
- fprintf (stderr, "Error: state stack now");
+ printf("Error: state stack now");
while (ssp1 != yyssp)
- fprintf (stderr, " %d", *++ssp1);
- fprintf (stderr, "\n");
+ printf(" %d", *++ssp1);
+ printf("\n");
}
#endif
@@ -673,7 +673,7 @@
#if YYDEBUG != 0
if (yydebug)
- fprintf(stderr, "Shifting error token, ");
+ printf("Shifting error token, ");
#endif
*++yyvsp = yylval;
Modified: trunk/include/prothon/prothon.h
===================================================================
--- trunk/include/prothon/prothon.h 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/include/prothon/prothon.h 2004-03-31 06:14:45 UTC (rev 224)
@@ -92,7 +92,7 @@
//#define TRACE_PARSER
//#define TRACE_INTERPRETER
//#define DUMP_MODULE_CODE
-#define DUMP_OBJECTS_AT_END
+//#define DUMP_OBJECTS_AT_END
//************************* BASIC TYPE DEFINITIONS ********************************
@@ -275,22 +275,22 @@
// actual symbols are lower-case versions of these constants
typedef enum {
__STRING__,
- __NOT__,
+ __NOT__QUES,
__POS__,
__NEG__,
__INV__,
- __IN__,
- __NOTIN__,
- __IS__,
- __ISNOT__,
+ __IN__QUES,
+ __NOTIN__QUES,
+ __IS__QUES,
+ __ISNOT__QUES,
CMP,
- __LT__,
- __LE__,
- __GT__,
- __GE__,
- __NE__,
- __EQ__,
+ __LT__QUES,
+ __LE__QUES,
+ __GT__QUES,
+ __GE__QUES,
+ __NE__QUES,
+ __EQ__QUES,
__OR__,
__XOR__,
@@ -318,12 +318,12 @@
__IMOD__,
__IPOW__,
- __RIN__,
- __RNOTIN__,
- __RLT__,
- __RLE__,
- __RGT__,
- __RGE__,
+ __RIN__QUES,
+ __RNOTIN__QUES,
+ __RLT__QUES,
+ __RLE__QUES,
+ __RGT__QUES,
+ __RGE__QUES,
__RRSHIFT__,
__RLSHIFT__,
__RSUB__,
@@ -334,7 +334,7 @@
__RCMP__,
__INIT__,
- __BOOL__,
+ __BOOL__QUES,
__GEN__,
__DOC__,
__HASH__,
@@ -474,7 +474,7 @@
// HAS_PROTO: Returns TRUE if second object is in reachable proto list of first object
// The ist param may return an exception object if proto pointers are missing
// or have a circular reference. See section "INTERPRETER STATE" below.
-int has_proto(isp ist, obj_p obj, obj_p obj_proto);
+int has_proto_QUES(isp ist, obj_p obj, obj_p obj_proto);
// SWITCH_PROTO_TO: Replace all old protos with a new single proto object
void switch_proto_to(isp ist, obj_p obj, obj_p new_proto);
@@ -558,7 +558,7 @@
// NEW_DICT_OBJ: Create a new dictionary object
// A dictionary stores objects much like the attributes are stored except that
// any immutable object can be the key, not just a symbol. Lookups are more
-// expensive since hashes are used and an __eq__ call must be made during the
+// expensive since hashes are used and an __eq__QUES call must be made during the
// lookup unlike attributes that just use the key identity for comparisom.
// Make sure the initial size is at least twice as large as the intended number
// of objects you will be adding initially. Expanding a dictionary is an expensive
@@ -566,7 +566,7 @@
obj_p new_dict_obj(int initial_size);
// DICT_ADD: Add a key/value pair to the dictionary. Replace old one if key exists.
-// Key equality is determined by the __eq__ function on the key objects. The __eq__
+// Key equality is determined by the __eq__QUES function on the key objects. The __eq__QUES
// function is called on the existing key in the dict with the passed key as the parameter.
// If the keys match, then the value in the dictionary is replaced and the existing key
// is left in place. If there is no match the ky and value are added.
@@ -578,7 +578,7 @@
size_t dict_len(isp ist, obj_p dict);
// DICT_ITEM: Look up a value in the dictionary for the given key.
-// Find a key using the same __eq__ match criteria given for dict_add and return the
+// Find a key using the same __eq__QUES match criteria given for dict_add and return the
// corresponding value object. If no key matches then return null.
obj_p dict_item(isp ist, obj_p dict, obj_p key);
@@ -763,7 +763,7 @@
// represent. For example, float type "covers" int type and long type "covers"
// int type. Covering a value does not mean that some precision will not be lost.
// This test determines when coercion is allowed. It is up to the prototype
-// objects to decide which objects they cover by offering the __covers__ function.
+// objects to decide which objects they cover by offering the __covers__QUES function.
#define covers(o1, o2) (call_func1((ist), (o1), SYM(__COVERS__), (o2)) == OBJ(PR_TRUE))
//********************************* EXCEPTIONS ******************************************
Modified: trunk/include/prothon/prothon_dll.h
===================================================================
--- trunk/include/prothon/prothon_dll.h 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/include/prothon/prothon_dll.h 2004-03-31 06:14:45 UTC (rev 224)
@@ -65,7 +65,7 @@
int (*del_attr)(isp ist, obj_p obj, obj_p key);
int (*ins_proto)(isp ist, obj_p obj, obj_p proto, int pos);
int (*del_proto)(isp ist, obj_p obj, obj_p proto);
- int (*has_proto)(isp ist, obj_p obj, obj_p obj_proto);
+ int (*has_proto_QUES)(isp ist, obj_p obj, obj_p obj_proto);
void (*switch_proto_to)(isp ist, obj_p obj, obj_p new_proto);
obj_p (*list_append)(isp ist, obj_p list_obj, obj_p item);
obj_p (*list_item)(isp ist, obj_p list, int i);
@@ -202,7 +202,7 @@
#define del_attr (*services->del_attr)
#define ins_proto (*services->ins_proto)
#define del_proto (*services->del_proto)
-#define has_proto (*services->has_proto)
+#define has_proto_QUES (*services->has_proto_QUES)
#define switch_proto_to (*services->switch_proto_to)
#define list_append (*services->list_append)
#define list_item (*services->list_item)
Modified: trunk/modules/File/File.c
===================================================================
--- trunk/modules/File/File.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/modules/File/File.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -124,11 +124,11 @@
char *file, *mode;
char err_buf[1024];
- if (!has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "File init path parameter must be a string");
return NULL;
}
- if (!has_proto(ist, parms[3], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[3], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "File init mode parameter must be a string");
return NULL;
}
@@ -136,7 +136,7 @@
raise_exception(ist, OBJ(TYPE_EXC), "File and mode parameters cannot be empty");
return NULL;
}
- if (!has_proto(ist, parms[5], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[5], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "File init bufsize parameter must be an integer");
return NULL;
}
@@ -194,8 +194,8 @@
return OBJ(NONE);
}
-DEF(File, closed, NULL) {
- if (!has_proto(ist, self, File_OBJ)) {
+DEF(File, closed_QUES, NULL) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "closed can only be called on a File object");
return NULL;
}
@@ -204,7 +204,7 @@
}
DEF(File, flush, NULL) {
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "flush can only be called on a File object");
return NULL;
}
@@ -220,7 +220,7 @@
}
#if 0
DEF(File, fileno, NULL) {
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "fileno can only be called on a File object");
return NULL;
}
@@ -231,7 +231,7 @@
return new_int_obj(_fileno(STREAM(self)));
}
-DEF(File, isatty, NULL) {
+DEF(File, isatty_QUES, NULL) {
if (!OPEN(self)) {
raise_exception(ist, OBJ(IOEXCEPTION), "isatty called on closed stream");
return NULL;
@@ -250,11 +250,11 @@
apr_status_t aprerr;
char err_buf[1024];
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
return NULL;
}
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "read can only be called on a File object");
return NULL;
}
@@ -330,11 +330,11 @@
apr_status_t aprerr;
char err_buf[1024];
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
return NULL;
}
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "readline can only be called on a File object");
return NULL;
}
@@ -408,11 +408,11 @@
apr_status_t aprerr;
char err_buf[1024];
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file read size parameter must be an integer");
return NULL;
}
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "readlines can only be called on a File object");
return NULL;
}
@@ -491,15 +491,15 @@
apr_status_t aprerr;
char err_buf[1024];
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file seek pos parameter must be an integer");
return NULL;
}
- if (!has_proto(ist, parms[3], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file seek how parameter must be an integer");
return NULL;
}
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "seek can only be called on a File object");
return NULL;
}
@@ -539,11 +539,11 @@
char err_buf[1024];
apr_off_t size;
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file truncate size parameter must be an integer");
return NULL;
}
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "truncate can only be called on a File object");
return NULL;
}
@@ -575,11 +575,11 @@
apr_status_t aprerr;
char err_buf[1024];
- if (!has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file write str parameter must be a string");
return NULL;
}
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "write can only be called on a File object");
return NULL;
}
@@ -609,11 +609,11 @@
apr_status_t aprerr;
char err_buf[1024];
- if (!has_proto(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file writelines parameter must be a sequence or a string");
return NULL;
}
- if (!has_proto(ist, self, File_OBJ)) {
+ if (!has_proto_QUES(ist, self, File_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "writelines can only be called on a File object");
return NULL;
}
@@ -625,7 +625,7 @@
raise_exception(ist, OBJ(IOEXCEPTION), "writelines called on file opened without write perms");
return NULL;
}
- if (has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
str = strch(parms[1]);
size = pr_strlen(parms[1]);
aprerr = apr_file_write(STREAM(self), str, &size);
@@ -638,7 +638,7 @@
int i, llen = list_len(ist, parms[1]);
for(i = 0; i < llen; i++) {
obj_p item = list_item(ist, parms[1], i);
- if (!has_proto(ist, item, OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, item, OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "file writelines lst item must be a string");
return NULL;
}
Modified: trunk/modules/Float/Float.c
===================================================================
--- trunk/modules/Float/Float.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/modules/Float/Float.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -62,7 +62,7 @@
#define FLOAT_DATA_SIZE 8
-#define is_Float(objid) (has_proto(ist, objid, Float_OBJ))
+#define is_Float(objid) (has_proto_QUES(ist, objid, Float_OBJ))
#define Float_value(objid) (objid->data.f64)
MODULE_DECLARE(Float);
@@ -73,7 +73,7 @@
Float_OBJ = OBJ(FLOAT_PROTO);
}
-DEF(Float, __bool__, NULL) {
+DEF(Float, __bool__QUES, NULL) {
if (Float_value(self) != 0.0 )
return OBJ(PR_TRUE);
else
@@ -107,7 +107,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -124,7 +124,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -145,7 +145,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
raise_exception(ist, OBJ(TYPE_EXC), "Float cannot be divided into this object");
@@ -164,7 +164,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -181,7 +181,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -198,7 +198,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
raise_exception(ist, OBJ(TYPE_EXC), "this object cannot be subtracted from a float");
@@ -213,7 +213,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -230,7 +230,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
raise_exception(ist, OBJ(TYPE_EXC), "this object cannot be in a pow function with a float");
@@ -246,7 +246,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
@@ -268,7 +268,7 @@
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
raise_exception(ist, OBJ(TYPE_EXC), "this object cannot compared to a float");
@@ -283,16 +283,16 @@
return new_int_obj(-1);
}
-DEF(Float, __eq__, FORM_RPARAM){
+DEF(Float, __eq__QUES, FORM_RPARAM){
double float_other;
obj_p other = parms[1];
if (is_Float(other)) float_other = Float_value(other);
else {
- if (has_proto(ist, other, OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, other, OBJ(INT_PROTO)))
float_other = (double)other->data.i64;
else {
if (covers(other, self))
- return call_func1(ist, other, SYM(__EQ__), self);
+ return call_func1(ist, other, SYM(__EQ__QUES), self);
return OBJ(PR_FALSE);
}
}
@@ -306,15 +306,15 @@
return new_string_obj(str);
}
-DEF(Float, __covers__, FORM_RPARAM) {
- if (has_proto(ist, parms[1], OBJ(INT_PROTO))) return OBJ(PR_TRUE);
+DEF(Float, __covers__QUES, FORM_RPARAM) {
+ if (has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
DEF(Float, __coerce__, FORM_RPARAM) {
- if (has_proto(ist, parms[1], OBJ(INT_PROTO)))
+ if (has_proto_QUES(ist, parms[1], OBJ(INT_PROTO)))
return new_float_obj((double)(parms[1]->data.i64));
- else if (has_proto(ist, parms[1], Float_OBJ))
+ else if (has_proto_QUES(ist, parms[1], Float_OBJ))
return new_float_obj(parms[1]->data.f64);
else
raise_exception(ist, OBJ(TYPE_EXC), "This object cannot be coerced to a Float");
Modified: trunk/modules/List/List.c
===================================================================
--- trunk/modules/List/List.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/modules/List/List.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -68,7 +68,7 @@
DEF(List, __add__, FORM_RPARAM) {
int i;
obj_p res = clone_list_obj(ist, self);
- if (has_proto(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto(ist, parms[1], OBJ(STRING_PROTO)))
+ if (has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)))
for(i=0; i < list_len(ist, parms[1]); i++)
list_append(ist, res, list_item(ist, parms[1], i));
else
@@ -80,7 +80,7 @@
obj_p res;
list_p lstp, selfp = ((list_p)(self->data.ptr))+LIST_OVERHEAD;
int i, size, times, len = list_len(ist, self);
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "multiply times parameter must be an integer");
return NULL;
}
@@ -120,7 +120,7 @@
list_p selfp, otherp;
int self_len, other_len;
read_unlock(ist, self); write_lock(ist, self);
- if (!has_proto(ist, parms[1], OBJ(TUPLE_PROTO)) && !has_proto(ist, parms[1], List_OBJ)) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(TUPLE_PROTO)) && !has_proto_QUES(ist, parms[1], List_OBJ)) {
raise_exception(ist, OBJ(TYPE_EXC), "extend parameter must be a tuple or list");
return NULL;
}
@@ -142,7 +142,7 @@
DEF(List, insert_BANG, FORM_PARAM2) {
int index, self_len;
list_p selfp;
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "index (i) parameter must be an integer");
return NULL;
}
@@ -176,7 +176,7 @@
selfp = self->data.ptr;
self_len = lstplen(selfp);
for (i=0; i < self_len; i++) {
- if (call_func1(ist, listitem(self, i), SYM(__EQ__), parms[1]) == OBJ(PR_TRUE)) break;
+ if (call_func1(ist, listitem(self, i), SYM(__EQ__QUES), parms[1]) == OBJ(PR_TRUE)) break;
if_exc_return NULL;
}
if (i == self_len) {
@@ -196,7 +196,7 @@
int index, self_len;
list_p selfp;
obj_p res;
- if (parms[1] != OBJ(NONE) && !has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (parms[1] != OBJ(NONE) && !has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "pop index (i) parameter must be an integer");
return NULL;
}
Modified: trunk/modules/Re/Re.c
===================================================================
--- trunk/modules/Re/Re.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/modules/Re/Re.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -94,11 +94,11 @@
obj_p re_obj;
regex_t* e = pr_malloc(sizeof(regex_t));
int flags_in, flags=0, err;
- if (!has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "Re.compile pattern parameter must be a string");
return NULL;
}
- if (!has_proto(ist, parms[3], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "Re.compile flags parameter must be an integer");
return NULL;
}
@@ -146,7 +146,7 @@
regoff_t sp, ep;
int i, err, ngrps = numgrps(self);
regex_t* e = self->data.ptr;
- if (!has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "findall s parameter must be a string");
return NULL;
}
@@ -204,15 +204,15 @@
char* s;
regmatch_t* m;
regex_t* e = self->data.ptr;
- if (!has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "Re.search s parameter must be a string");
return NULL;
}
- if (!has_proto(ist, parms[3], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "Re.search start parameter must be an integer");
return NULL;
}
- if (!has_proto(ist, parms[5], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[5], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "Re.search end parameter must be an integer");
return NULL;
}
@@ -260,11 +260,11 @@
regoff_t sp, ep, last_split;
int i, split_count=0, maxsplit, err, ngrps = numgrps(self);
regex_t* e = self->data.ptr;
- if (!has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "split function s parameter must be a string");
return NULL;
}
- if (!has_proto(ist, parms[3], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[3], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "split function maxsplit parameter must be an integer");
return NULL;
}
@@ -403,16 +403,16 @@
int i, last_index=0, repl_is_func=FALSE, count, err, ngrps = numgrps(self);
obj_p lastindex_obj, repl_obj, res_obj, match_obj, arr[2];
regex_t* e = self->data.ptr;
- if ( !has_proto(ist, parms[1], OBJ(STRING_PROTO)) &&
- !(repl_is_func=has_proto(ist, parms[1], OBJ(FUNC_PROTO))) ) {
+ if ( !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)) &&
+ !(repl_is_func=has_proto_QUES(ist, parms[1], OBJ(FUNC_PROTO))) ) {
raise_exception(ist, OBJ(TYPE_EXC), "sub repl parameter must be a string or function");
return NULL;
}
- if (!has_proto(ist, parms[3], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[3], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sub function s parameter must be a string");
return NULL;
}
- if (!has_proto(ist, parms[5], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[5], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sub function count parameter must be an integer");
return NULL;
}
@@ -470,7 +470,7 @@
read_lock(ist, parms[1]);
if (repl_obj == OBJ(NONE)) repl = "";
else {
- if (!has_proto(ist, repl_obj, OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, repl_obj, OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "repl callback function must return a string");
return NULL;
}
@@ -525,7 +525,7 @@
DEF(ReMatch, start, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
int grp;
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "start function groupid parameter must be an integer");
return NULL;
}
@@ -539,7 +539,7 @@
DEF(ReMatch, end, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
int grp;
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "end function groupid parameter must be an integer");
return NULL;
}
@@ -554,7 +554,7 @@
DEF(ReMatch, span, list2(sym(ist, "groupid"),OBJ(ZERO_INT))) {
int grp;
obj_p res;
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "span function groupid parameter must be an integer");
return NULL;
}
@@ -574,7 +574,7 @@
size_t size;
char *p1, *p2, *s, *s_lim, *orig_s;
obj_p orig_s_obj, res;
- if (!has_proto(ist, parms[1], OBJ(STRING_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "expand s parameter must be a string");
return NULL;
}
@@ -596,7 +596,7 @@
int i, j, llen, ngrps = list_len(ist, self)/2, sp, ep;
char* orig_s;
obj_p orig_s_obj, res;
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "groupid parameters must be integers");
return NULL;
}
@@ -609,7 +609,7 @@
int llen = list_len(ist, parms[3]);
for (i=0; i < llen; i++) {
obj_p item = list_item(ist, parms[3], i);
- if (!has_proto(ist, item, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, item, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "groupid parameters must be integers");
return NULL;
}
Modified: trunk/modules/String/String.c
===================================================================
--- trunk/modules/String/String.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/modules/String/String.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -57,7 +57,7 @@
#include <string.h>
#include <prothon/prothon_dll.h>
-#define is_String(objid) (has_proto(ist, objid, String_OBJ))
+#define is_String(objid) (has_proto_QUES(ist, objid, String_OBJ))
MODULE_DECLARE(String);
MODULE_DECLARE(StringGen);
@@ -107,7 +107,7 @@
obj_p obj;
pr_str_p obj_str;
size_t i, times, tlen, len = pr_strlen(self);
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "multiply times parameter must be an integer");
return NULL;
}
@@ -155,7 +155,7 @@
obj_p obj, list, str_list;
int i, llen;
size_t ofs, self_len, tlen;
- if (!has_proto(ist, parms[1], OBJ(LIST_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(LIST_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "join function parameter must be a list");
return NULL;
}
@@ -202,16 +202,16 @@
return obj;
}
-DEF(String, __in__, FORM_RPARAM) {
- if (!has_proto(ist, parms[1], String_OBJ))
- return call_func1(ist, parms[1], SYM(__RIN__), self);
+DEF(String, __in__QUES, FORM_RPARAM) {
+ if (!has_proto_QUES(ist, parms[1], String_OBJ))
+ return call_func1(ist, parms[1], SYM(__RIN__QUES), self);
if (strstr(strch(parms[1]), strch(self))) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(String, __notin__, FORM_RPARAM) {
- if (!has_proto(ist, parms[1], String_OBJ))
- return call_func1(ist, parms[1], SYM(__RNOTIN__), self);
+DEF(String, __notin__QUES, FORM_RPARAM) {
+ if (!has_proto_QUES(ist, parms[1], String_OBJ))
+ return call_func1(ist, parms[1], SYM(__RNOTIN__QUES), self);
if (strstr(strch(parms[1]), strch(self))) return OBJ(PR_FALSE);
else return OBJ(PR_TRUE);
}
Modified: trunk/modules/Tuple/Tuple.c
===================================================================
--- trunk/modules/Tuple/Tuple.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/modules/Tuple/Tuple.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -66,24 +66,24 @@
Tuple_OBJ = OBJ(TUPLE_PROTO);
}
-DEF(Tuple, __rin__, FORM_RPARAM) {
+DEF(Tuple, __rin__QUES, FORM_RPARAM) {
int i, llen = list_len(ist, self);
obj_p item, tgt = parms[1];
for(i=0; i < llen; i++) {
item = list_item(ist, self, i);
- if (call_func1(ist, item, SYM(__EQ__), tgt) == OBJ(PR_TRUE))
+ if (call_func1(ist, item, SYM(__EQ__QUES), tgt) == OBJ(PR_TRUE))
return OBJ(PR_TRUE);
else if_exc_return NULL;
}
return OBJ(PR_FALSE);
}
-DEF(Tuple, __rnotin__, FORM_RPARAM) {
+DEF(Tuple, __rnotin__QUES, FORM_RPARAM) {
int i, llen = list_len(ist, self);
obj_p item, tgt = parms[1];
for(i=0; i < llen; i++) {
item = list_item(ist, self, i);
- if (call_func1(ist, item, SYM(__EQ__), tgt) == OBJ(PR_TRUE))
+ if (call_func1(ist, item, SYM(__EQ__QUES), tgt) == OBJ(PR_TRUE))
return OBJ(PR_FALSE);
else if_exc_return NULL;
}
@@ -93,7 +93,7 @@
DEF(Tuple, __add__, FORM_RPARAM) {
int i;
obj_p res = clone_list_obj(ist, self);
- if (has_proto(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto(ist, parms[1], OBJ(STRING_PROTO)))
+ if (has_proto_QUES(ist, parms[1], OBJ(SEQ_PROTO)) && !has_proto_QUES(ist, parms[1], OBJ(STRING_PROTO)))
for(i=0; i < list_len(ist, parms[1]); i++)
list_append(ist, res, list_item(ist, parms[1], i));
else
@@ -106,7 +106,7 @@
obj_p res;
list_p lstp, selfp = ((list_p)(self->data.ptr))+LIST_OVERHEAD;
int i, size, times, len = list_len(ist, self);
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "multiply times parameter must be an integer");
return NULL;
}
@@ -169,7 +169,7 @@
DEF(Tuple, count, FORM_RPARAM) {
int i, cnt=0, llen = list_len(ist, self);
for (i=0; i < llen; i++) {
- if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__), parms[1]) == OBJ(PR_TRUE))
+ if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__QUES), parms[1]) == OBJ(PR_TRUE))
cnt++;
if_exc_return NULL;
}
@@ -179,7 +179,7 @@
DEF(Tuple, index, FORM_RPARAM) {
int i, llen = list_len(ist, self);
for (i=0; i < llen; i++) {
- if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__), parms[1]) == OBJ(PR_TRUE))
+ if (call_func1(ist, list_item(ist, self, i), SYM(__EQ__QUES), parms[1]) == OBJ(PR_TRUE))
return new_int_obj(i);
if_exc_return NULL;
}
Modified: trunk/pr/hex.pr
===================================================================
--- trunk/pr/hex.pr 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/pr/hex.pr 2004-03-31 06:14:45 UTC (rev 224)
@@ -3,16 +3,16 @@
import String
def hex(n):
- s = ""
- while n:
- d = n & 0xf
- n = n >> 4
- if d < 10: s = ('0'.ord()+d).chr() + s
- else: s = ('a'.ord()+d-10).chr() + s
- return s
-
+ s = ""
+ while n:
+ d = n & 0xf
+ n = n >> 4
+ if d < 10: s = ('0'.ord()+d).chr() + s
+ else: s = ('a'.ord()+d-10).chr() + s
+ return s
+
print hex(0x100)
-
+
n=0x0123456789abcdef
print hex(n & 0x0f0f0f0f0f0f0f0f)
Modified: trunk/pr/re_test.pr
===================================================================
--- trunk/pr/re_test.pr 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/pr/re_test.pr 2004-03-31 06:14:45 UTC (rev 224)
@@ -36,9 +36,4 @@
print "[mark, muck, mink]"
print "[this , likes to , around in minks]"
print "mark (mark)"
-print " mark like ( mark like, mark, like) grp1:<mark> grp2:<like>"
-
-
-
-
-
+print " mark like ( mark like, mark, like) grp1:<mark> grp2:<like>"
\ No newline at end of file
Modified: trunk/src/builtins.c
===================================================================
--- trunk/src/builtins.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/builtins.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -102,8 +102,8 @@
return self;
}
-DEF(Object, has_proto, FORM_RPARAM) {
- if (has_proto(ist, self, parms[1]))
+DEF(Object, has_proto_QUES, FORM_RPARAM) {
+ if (has_proto_QUES(ist, self, parms[1]))
return OBJ(PR_TRUE);
else
return OBJ(PR_FALSE);
@@ -156,21 +156,21 @@
return proto_list(ist, self);
}
-DEF(Object, __bool__, NULL) { return OBJ(PR_TRUE); }
-DEF(Object, __not__, NULL)
+DEF(Object, __bool__QUES, NULL) { return OBJ(PR_TRUE); }
+DEF(Object, __not__QUES, NULL)
{
- if (call_func0(ist, self, SYM(__BOOL__)) == OBJ(PR_TRUE))
+ if (call_func0(ist, self, SYM(__BOOL__QUES)) == OBJ(PR_TRUE))
return OBJ(PR_FALSE);
else
return OBJ(PR_TRUE);
}
-DEF(Object, __is__, FORM_RPARAM) {
+DEF(Object, __is__QUES, FORM_RPARAM) {
if (self == parms[1]) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, __isnot__, FORM_RPARAM) {
+DEF(Object, __isnot__QUES, FORM_RPARAM) {
if (self != parms[1]) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
@@ -190,7 +190,7 @@
return new_hash_obj((i32_t)(uintptr_t) self);
}
-DEF(Object, __eq__, FORM_RPARAM) {
+DEF(Object, __eq__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) == 0)
return OBJ(PR_TRUE);
@@ -198,44 +198,44 @@
return OBJ(PR_FALSE);
}
-DEF(Object, __ne__, FORM_RPARAM) {
- obj_p cmp_obj = call_func1(ist, self, SYM(__EQ__), parms[1]); if_exc_return NULL;
+DEF(Object, __ne__QUES, FORM_RPARAM) {
+ obj_p cmp_obj = call_func1(ist, self, SYM(__EQ__QUES), parms[1]); if_exc_return NULL;
if (cmp_obj == OBJ(PR_TRUE))
return OBJ(PR_FALSE);
else
return OBJ(PR_TRUE);
}
-DEF(Object, __lt__, FORM_RPARAM) {
+DEF(Object, __lt__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) < 0) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, __le__, FORM_RPARAM) {
+DEF(Object, __le__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) <= 0) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, __gt__, FORM_RPARAM) {
+DEF(Object, __gt__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) > 0) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, __ge__, FORM_RPARAM) {
+DEF(Object, __ge__QUES, FORM_RPARAM) {
obj_p cmp_obj = call_func1(ist, self, SYM(CMP), parms[1]); if_exc_return NULL;
if (cmp_obj && *((i64_t*)(obj_data_p(cmp_obj))) >= 0) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
-DEF(Object, __in__, FORM_RPARAM) {
- return call_func1(ist, parms[1], SYM(__RIN__), self);
+DEF(Object, __in__QUES, FORM_RPARAM) {
+ return call_func1(ist, parms[1], SYM(__RIN__QUES), self);
}
-DEF(Object, __notin__, FORM_RPARAM) {
- return call_func1(ist, parms[1], SYM(__RNOTIN__), self);
+DEF(Object, __notin__QUES, FORM_RPARAM) {
+ return call_func1(ist, parms[1], SYM(__RNOTIN__QUES), self);
}
DEF(Object, attrs, NULL) {
@@ -269,7 +269,7 @@
}
DEF(False, __str__, NULL) { return new_string_obj("False"); }
-DEF(False, __bool__, NULL) { return False_OBJ; }
+DEF(False, __bool__QUES, NULL) { return False_OBJ; }
DEF(False, cmp, FORM_RPARAM) {
if (parms[1] == False_OBJ)
return new_int_obj(0);
@@ -289,7 +289,7 @@
}
DEF(True, __str__, NULL) { return new_string_obj("True"); }
-DEF(True, __bool__, NULL) { return True_OBJ; }
+DEF(True, __bool__QUES, NULL) { return True_OBJ; }
DEF(True, cmp, FORM_RPARAM) {
if (parms[1] == OBJ(PR_FALSE))
return new_int_obj(1);
@@ -311,7 +311,7 @@
}
DEF(None, __str__, NULL) { return new_string_obj("None"); }
-DEF(None, __bool__, NULL) { return OBJ(PR_FALSE); }
+DEF(None, __bool__QUES, NULL) { return OBJ(PR_FALSE); }
MODULE_END(None);
// ***************************** EXCEPTION ************************************
@@ -389,14 +389,14 @@
}
static int seq_len(isp ist, obj_p seq) {
- if (has_proto(ist, seq, OBJ(STRING_PROTO)))
+ if (has_proto_QUES(ist, seq, OBJ(STRING_PROTO)))
return (int) strlen(strch(seq));
else return list_len(ist, seq);
}
static obj_p seq_item(isp ist, obj_p seq, int i) {
char s[2];
- if (has_proto(ist, seq, OBJ(STRING_PROTO))) {
+ if (has_proto_QUES(ist, seq, OBJ(STRING_PROTO))) {
s[0] = strch(seq)[i];
s[1] = 0;
return new_string_obj(s);
@@ -465,7 +465,7 @@
if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE))
slice1_empty=TRUE;
else {
- if (!has_proto(ist, slice_item1, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item1, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
return NULL;
}
@@ -486,7 +486,7 @@
slice_item3 = list_item(ist, slice,2);
if (slice_item3 == SLICEPARAM_EMPTY || slice_item3 == OBJ(NONE)) index3 = 1;
else {
- if (!has_proto(ist, slice_item3, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item3, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
return NULL;
}
@@ -501,7 +501,7 @@
if (slice_item2 == SLICEPARAM_EMPTY || slice_item2 == OBJ(NONE))
slice2_empty=TRUE;
else {
- if (!has_proto(ist, slice_item2, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item2, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
return NULL;
}
@@ -570,11 +570,12 @@
// ***************************** INT *******************************************
#define INT_DATA_SIZE 8
-#define is_Int(objid) (has_proto(ist, objid, Int_OBJ))
+#define is_Int(objid) (has_proto_QUES(ist, objid, Int_OBJ))
#define Int_value(objid) (objid->data.i64)
static obj_p SYM_LIMIT;
+
MODULE_START(Int)
{
Int_OBJ = OBJ(INT_PROTO);
@@ -596,7 +597,7 @@
set_attr(ist, OBJ(OBJECT), sym(ist, "Imaginary"), OBJ(IMAG_PROTO));
}
-DEF(Int, __bool__, NULL) {
+DEF(Int, __bool__QUES, NULL) {
if (Int_value(self)) return OBJ(PR_TRUE);
else return OBJ(PR_FALSE);
}
@@ -724,11 +725,11 @@
return new_int_obj(-1);
}
-DEF(Int, __eq__, FORM_RPARAM){
+DEF(Int, __eq__QUES, FORM_RPARAM){
obj_p other = parms[1];
if (!is_Int(other)) {
if (covers(other, self))
- return call_func1(ist, other, SYM(__EQ__), self);
+ return call_func1(ist, other, SYM(__EQ__QUES), self);
return OBJ(PR_FALSE);
}
if (Int_value(self) == Int_value(other)) return OBJ(PR_TRUE);
@@ -938,7 +939,7 @@
if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE))
slice1_empty=TRUE;
else {
- if (!has_proto(ist, slice_item1, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item1, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "List slice index must be an integer");
write_unlock(ist, self); read_lock(ist, self);
return NULL;
@@ -956,9 +957,9 @@
return NULL;
}
}
- if ( !has_proto(ist, value, List_OBJ) &&
- !has_proto(ist, value, OBJ(TUPLE_PROTO)) &&
- !has_proto(ist, value, OBJ(STRING_PROTO)) ) {
+ if ( !has_proto_QUES(ist, value, List_OBJ) &&
+ !has_proto_QUES(ist, value, OBJ(TUPLE_PROTO)) &&
+ !has_proto_QUES(ist, value, OBJ(STRING_PROTO)) ) {
raise_exception(ist, OBJ(TYPE_EXC), "list slices may only be replaced with a sequence");
write_unlock(ist, self); read_lock(ist, self);
return NULL;
@@ -967,7 +968,7 @@
slice_item3 = list_item(ist, slice,2);
if (slice_item3 == SLICEPARAM_EMPTY || slice_item3 == OBJ(NONE)) index3 = 1;
else {
- if (!has_proto(ist, slice_item3, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item3, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
write_unlock(ist, self); read_lock(ist, self);
return NULL;
@@ -984,7 +985,7 @@
if (slice_item2 == SLICEPARAM_EMPTY || slice_item2 == OBJ(NONE))
slice2_empty=TRUE;
else {
- if (!has_proto(ist, slice_item2, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item2, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
write_unlock(ist, self); read_lock(ist, self);
return NULL;
@@ -1048,7 +1049,7 @@
if (slice_item1 == SLICEPARAM_EMPTY || slice_item1 == OBJ(NONE))
slice1_empty=TRUE;
else {
- if (!has_proto(ist, slice_item1, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item1, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "List slice index must be an integer");
write_unlock(ist, self); read_lock(ist, self);
return NULL;
@@ -1074,7 +1075,7 @@
slice_item3 = list_item(ist, slice,2);
if (slice_item3 == SLICEPARAM_EMPTY || slice_item3 == OBJ(NONE)) index3 = 1;
else {
- if (!has_proto(ist, slice_item3, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item3, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
write_unlock(ist, self); read_lock(ist, self);
return NULL;
@@ -1091,7 +1092,7 @@
if (slice_item2 == SLICEPARAM_EMPTY || slice_item2 == OBJ(NONE))
slice2_empty=TRUE;
else {
- if (!has_proto(ist, slice_item2, OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, slice_item2, OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "sequence slice index must be an integer");
write_unlock(ist, self); read_lock(ist, self);
return NULL;
@@ -1239,7 +1240,7 @@
dict = (dict_p) self->data.ptr;
for(i=hash_in; (key=((dp=dictptr(dict,i))->entry.key)); i++){
if ( dp->entry.hash == hash_in &&
- call_func(ist, key, SYM(__EQ__), 2, rp, NULL) == OBJ(PR_TRUE) ) {
+ call_func(ist, key, SYM(__EQ__QUES), 2, rp, NULL) == OBJ(PR_TRUE) ) {
dp->entry.hash = ENTRY_DELETED;
dictlen(dict)--;
write_unlock(ist, self); read_lock(ist, self);
Modified: trunk/src/console.c
===================================================================
--- trunk/src/console.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/console.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -219,7 +219,7 @@
}
ind_level += ind_chg;
}
- colon_flg = (strlen(line) >= 2 && src[strlen(line)-2] == ':');
+ colon_flg = (strlen(line) >= 2 && line[strlen(line)-2] == ':');
}
res = exec_string(ist, src, TRUE, &frame);
if (check_exceptions(ist)) {
Modified: trunk/src/interp.c
===================================================================
--- trunk/src/interp.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/interp.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -664,7 +664,7 @@
case OP_SEQ_ASSIGN: {
obj_p list;
fr_sp -= param+1;
- if (has_proto(ist, list=fr_stack[fr_sp], OBJ(LIST_PROTO))){
+ if (has_proto_QUES(ist, list=fr_stack[fr_sp], OBJ(LIST_PROTO))){
if (list_len(ist, list) != param){
raise_exception(ist, OBJ(INTERPRETER_EXC), "For param list length doesn't match sequence length");
break;
@@ -799,7 +799,7 @@
fr_sp--;
exc_proto = fr_tos;
fr_sp--;
- if (!has_proto(ist, exc_waiting, exc_proto)) { // need to support list XXX
+ if (!has_proto_QUES(ist, exc_waiting, exc_proto)) { // need to support list XXX
if (intrp_exobj) break;
#ifdef TRACE_INTERPRETER
trace_step(frame);
@@ -824,7 +824,7 @@
obj_p str_obj;
exec_frame_t* new_frame;
str_obj = fr_pop;
- if (!has_proto(ist, str_obj, OBJ(STRING_PROTO))){
+ if (!has_proto_QUES(ist, str_obj, OBJ(STRING_PROTO))){
raise_exception(ist, OBJ(TYPE_EXC), "Exec parameter must be a string");
break;
}
@@ -852,7 +852,7 @@
post_call_unlock(frame->locals, plist);
free_clist(plist);
fr_push(res);
- } else if (has_proto(ist, func_obj, OBJ(FUNC_PROTO))) {
+ } else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
obj_p new_locals;
exec_frame_t* new_frame;
if (intrp_exobj) break;
@@ -868,7 +868,7 @@
load_frame_params(ist, frame, func_obj, param*2, fr_stack+fr_sp+1);
if (intrp_exobj) break;
switch_frame = new_frame;
- } else if (has_proto(ist, func_obj, OBJ(GEN_PROTO))) {
+ } else if (has_proto_QUES(ist, func_obj, OBJ(GEN_PROTO))) {
exec_frame_t* tmp_frame;
if (intrp_exobj) break;
tmp_frame = func_obj->data.ptr;
@@ -892,16 +892,16 @@
break;
case OP_CALL: {
fr_sp -= 2+(2*param);
- if (has_proto(ist, fr_stack[fr_sp+1], OBJ(SUPER_PROTO))) {
+ if (has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(SUPER_PROTO))) {
obj_p proto_list_obj = proto_list(ist, fr_stack[fr_sp]); if (intrp_exobj) break;
fr_stack[fr_sp] = list_item(ist, proto_list_obj,1); del_unlock(proto_list_obj);
fr_stack[fr_sp+1] = fr_stack[fr_sp+1]->data.ptr;
}
- if (!has_proto(ist, fr_stack[fr_sp+1], OBJ(SYMBOL_PROTO))) {
+ if (!has_proto_QUES(ist, fr_stack[fr_sp+1], OBJ(SYMBOL_PROTO))) {
raise_exception(ist, OBJ(INTERNAL_EXC), "Indexed function call not supported yet");
break;
}
- if (fr_stack[fr_sp+1] == SYM(NEXT) && has_proto(ist, fr_stack[fr_sp], OBJ(GEN_PROTO))) {
+ if (fr_stack[fr_sp+1] == SYM(NEXT) && has_proto_QUES(ist, fr_stack[fr_sp], OBJ(GEN_PROTO))) {
exec_frame_t* new_frame=(exec_frame_t*)(fr_stack[fr_sp]->data.ptr);
if (!new_frame) {
raise_exception(ist, OBJ(STOP_ITERATION_EXC), NULL);
@@ -935,7 +935,7 @@
post_call_unlock(slf, plist);
free_clist(plist);
fr_push(res);
- } else if (has_proto(ist, func_obj, OBJ(FUNC_PROTO))) {
+ } else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
obj_p new_locals;
exec_frame_t* new_frame;
if (intrp_exobj) break;
@@ -951,7 +951,7 @@
load_frame_params(ist, frame, func_obj, param*2, fr_stack+fr_sp+2);
if (intrp_exobj) break;
switch_frame = new_frame;
- } else if (has_proto(ist, func_obj, OBJ(GEN_PROTO))) {
+ } else if (has_proto_QUES(ist, func_obj, OBJ(GEN_PROTO))) {
exec_frame_t* tmp_frame;
if (intrp_exobj) break;
tmp_frame = func_obj->data.ptr;
@@ -1161,7 +1161,7 @@
free_clist(plist);
if (!func_sym) del_unlock(self);
return res;
- } else if (has_proto(ist, func_obj, OBJ(FUNC_PROTO))) {
+ } else if (has_proto_QUES(ist, func_obj, OBJ(FUNC_PROTO))) {
exec_frame_t *frame, *new_frame;
obj_p new_locals;
if (!ist) {
@@ -1222,7 +1222,7 @@
for (i = list_len(ist, bl) - 1; i >= 0; i--){
obj_p exc = list_item(ist, bl, i);
- if (exc && exc != OBJ(EXCEPTION) && has_proto(ist, exc, OBJ(EXCEPTION))) {
+ if (exc && exc != OBJ(EXCEPTION) && has_proto_QUES(ist, exc, OBJ(EXCEPTION))) {
obj_p doc = get_attr(ist, exc, SYM(__DOC__));
if (doc && exc != orig_excobj)
Modified: trunk/src/object.c
===================================================================
--- trunk/src/object.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/object.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -142,7 +142,7 @@
dll_services.del_attr = del_attr;
dll_services.ins_proto = ins_proto;
dll_services.del_proto = del_proto;
- dll_services.has_proto = has_proto;
+ dll_services.has_proto_QUES = has_proto_QUES;
dll_services.switch_proto_to = switch_proto_to;
dll_services.list_append = list_append;
dll_services.list_item = list_item;
@@ -258,11 +258,11 @@
if (exc_obj) {
if (!proto && !proto_list)
return exc_obj;
- if (proto && has_proto(ist, exc_obj, proto))
+ if (proto && has_proto_QUES(ist, exc_obj, proto))
return exc_obj;
if (proto_list)
for (i=0; i < list_len(ist, proto_list); i++){
- if (has_proto(ist, exc_obj, list_item(ist, proto_list, i)))
+ if (has_proto_QUES(ist, exc_obj, list_item(ist, proto_list, i)))
return exc_obj;
}
}
@@ -516,8 +516,8 @@
return list_obj;
}
-//********************************* has_proto **********************************
-int has_proto(isp ist, obj_p obj, obj_p obj_proto){
+//********************************* has_proto_QUES **********************************
+int has_proto_QUES(isp ist, obj_p obj, obj_p obj_proto){
i32_t i, j, len;
obj_p proto;
clist_t *pao_list;
@@ -775,7 +775,7 @@
//********************************* get_item ******************************
obj_p get_item(isp ist, obj_p ref_self, obj_p ref_key){
- if (has_proto(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+ if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
obj_p res;
if_exc_return NULL;
res = get_proto_attr(ist, ref_self, ref_key, NULL);
@@ -784,12 +784,12 @@
symch(ist, ref_key));
}
return res;
- } else if (has_proto(ist, ref_key, OBJ(SLICE_PROTO))) {
+ } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
obj_p param[2];
if_exc_return NULL;
param[0]=0; param[1]=ref_key;
return call_func(ist, ref_self, SYM(__GETITEM__), 2, param, 0);
- } else if (has_proto(ist, ref_key, OBJ(SUPER_PROTO))) {
+ } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
obj_p proto_list_obj; if_exc_return NULL;
proto_list_obj = proto_list(ist, ref_self); if_exc_return NULL;
return get_proto_attr(ist, list_item(ist, proto_list_obj,1), ref_key->data.ptr, NULL);
@@ -801,15 +801,15 @@
//********************************* set_item ******************************
void set_item(isp ist, obj_p value, obj_p ref_self, obj_p ref_key){
- if (has_proto(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+ if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
if_exc_return;
set_attr(ist, ref_self, ref_key, value);
- } else if (has_proto(ist, ref_key, OBJ(SLICE_PROTO))) {
+ } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
obj_p param[4];
param[0]=0; param[1]=ref_key;
param[2]=0; param[3]=value;
call_func(ist, ref_self, SYM(__SETITEM__), 4, param, 0);
- } else if (has_proto(ist, ref_key, OBJ(SUPER_PROTO))) {
+ } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
obj_p proto_list_obj, proto_obj; if_exc_return;
proto_list_obj = proto_list(ist, ref_self); if_exc_return;
get_proto_attr(ist, list_item(ist, proto_list_obj,1), ref_key->data.ptr, &proto_obj);
@@ -824,14 +824,14 @@
//********************************* del_item ***********************************
void del_item(isp ist, obj_p ref_self, obj_p ref_key){
- if (has_proto(ist, ref_key, OBJ(SYMBOL_PROTO))) {
+ if (has_proto_QUES(ist, ref_key, OBJ(SYMBOL_PROTO))) {
if_exc_return;
del_attr(ist, ref_self, ref_key);
- } else if (has_proto(ist, ref_key, OBJ(SLICE_PROTO))) {
+ } else if (has_proto_QUES(ist, ref_key, OBJ(SLICE_PROTO))) {
obj_p param[2];
param[0]=0; param[1]=ref_key;
call_func(ist, ref_self, SYM(__DELITEM__), 2, param, 0);
- } else if (has_proto(ist, ref_key, OBJ(SUPER_PROTO))) {
+ } else if (has_proto_QUES(ist, ref_key, OBJ(SUPER_PROTO))) {
obj_p proto_list_obj, proto_obj; if_exc_return;
proto_list_obj = proto_list(ist, ref_self); if_exc_return;
get_proto_attr(ist, list_item(ist, proto_list_obj,1), ref_key->data.ptr, &proto_obj);
@@ -1025,7 +1025,7 @@
hash = dp->entry.hash;
if (hash < 0) { hole = dp; continue; }
if ( hash == hash_in &&
- call_func(ist, key, SYM(__EQ__), 2, rp, NULL) == OBJ(PR_TRUE) ) {
+ call_func(ist, key, SYM(__EQ__QUES), 2, rp, NULL) == OBJ(PR_TRUE) ) {
match = PR_TRUE;
break;
}
@@ -1070,7 +1070,7 @@
dict = (dict_p) obj_data_p(dict_obj);
for (i=hash_in; (key=((dp=dictptr(dict,i))->entry.key)); i++){
if ( dp->entry.hash == hash_in &&
- call_func(ist, key, SYM(__EQ__), 2, rp, NULL) == OBJ(PR_TRUE) ) {
+ call_func(ist, key, SYM(__EQ__QUES), 2, rp, NULL) == OBJ(PR_TRUE) ) {
dict_rd_chk();
res = dp->entry.value;
read_unlock(ist, dict_obj);
Modified: trunk/src/parser.h
===================================================================
--- trunk/src/parser.h 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/parser.h 2004-03-31 06:14:45 UTC (rev 224)
@@ -100,6 +100,7 @@
int column;
int old_column;
int old_tab_count;
+ int file_indent_flag; // -1 -> tab, 0 -> unknown, + -> number of spaces per indent
int indents_needed;
FILE* stream;
int char_ptr;
@@ -110,7 +111,7 @@
int assert_enbld;
int defdoc_flag;
int eof_flag;
- clist_p const_objs;
+ clist_p const_objs;
} parse_state;
parse_state* parse_file_or_string(isp ist, char* filename, char* string);
Modified: trunk/src/parser_routines.c
===================================================================
--- trunk/src/parser_routines.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/parser_routines.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -76,21 +76,16 @@
//********************************* new_parse_state ***************************
parse_state* new_parse_state(isp ist, FILE* stream, char* in_buf) {
parse_state* state = pr_malloc(sizeof(parse_state));
+ memset(state, 0, sizeof(parse_state));
if (!state){raise_exception(ist, OBJ(OUTOFMEMORY_EXC), NULL); return NULL;}
state->ist = ist;
state->line = 1;
state->column = 1;
state->old_column = 1;
- state->old_tab_count = 0;
- state->indents_needed = 0;
state->stream = stream;
- state->char_ptr = 0;
state->in_buf = in_buf;
- state->parse_results = NULL;
state->num_errors = -1;
state->assert_enbld = TRUE;
- state->defdoc_flag = FALSE;
- state->eof_flag = FALSE;
state->const_objs = new_clist(10);
return state;
}
@@ -556,7 +551,7 @@
res->code_data[k++].bytecode.opcode = OP_DUPLICATE;
res->code_data[k ].bytecode.opcode = OP_PUSH;
res->code_data[k++].bytecode.param = 2;
- res->code_data[k++].data = SYM(__BOOL__);
+ res->code_data[k++].data = SYM(__BOOL__QUES);
res->code_data[k ].bytecode.opcode = OP_CALL;
res->code_data[k++].bytecode.param = 0;
res->code_data[k ].bytecode.opcode = OP_BEQ;
@@ -576,7 +571,7 @@
void add_skip_code1(code* body, code* res, int* k){
res->code_data[(*k) ].bytecode.opcode = OP_PUSH;
res->code_data[(*k)++].bytecode.param = 2;
- res->code_data[(*k)++].data = SYM(__BOOL__);
+ res->code_data[(*k)++].data = SYM(__BOOL__QUES);
res->code_data[(*k) ].bytecode.opcode = OP_CALL;
res->code_data[(*k)++].bytecode.param = 0;
res->code_data[(*k) ].bytecode.opcode = OP_BEQ;
@@ -828,7 +823,7 @@
add_code_to(expr, res, &k);
res->code_data[k ].bytecode.opcode = OP_PUSH;
res->code_data[k++].bytecode.param = 2;
- res->code_data[k++].data = SYM(__BOOL__);
+ res->code_data[k++].data = SYM(__BOOL__QUES);
res->code_data[k ].bytecode.opcode = OP_CALL;
res->code_data[k++].bytecode.param = 0;
res->code_data[k ].bytecode.opcode = OP_BEQ;
@@ -867,7 +862,7 @@
add_code_to(cond, res, &k);
res->code_data[k ].bytecode.opcode = OP_PUSH;
res->code_data[k++].bytecode.param = 2;
- res->code_data[k++].data = SYM(__BOOL__);
+ res->code_data[k++].data = SYM(__BOOL__QUES);
res->code_data[k ].bytecode.opcode = OP_CALL;
res->code_data[k++].bytecode.param = 0;
res->code_data[k ].bytecode.opcode = OP_BEQ;
Modified: trunk/src/prothon.y
===================================================================
--- trunk/src/prothon.y 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/prothon.y 2004-03-31 06:14:45 UTC (rev 224)
@@ -437,9 +437,9 @@
;
is_not_check:
- { $$ = (void *)(unsigned long)__IS__; }
+ { $$ = (void *)(unsigned long)__IS__QUES; }
| NOT
- { $$ = (void *)(unsigned long)__ISNOT__; }
+ { $$ = (void *)(unsigned long)__ISNOT__QUES; }
expr:
LAMBDA formal_params ':' expr
@@ -452,34 +452,34 @@
{ $$ = expr_andor_expr(yylex_param, $1, $3, AND_FLAG); }
| expr IN_ expr
- { $$ = binary(yylex_param, $1, __IN__, $3); }
+ { $$ = binary(yylex_param, $1, __IN__QUES, $3); }
| expr NOT IN_ expr %prec NOT_IN
- { $$ = binary(yylex_param, $1, __NOTIN__, $4); }
+ { $$ = binary(yylex_param, $1, __NOTIN__QUES, $4); }
| expr IS is_not_check expr
{ $$ = binary(yylex_param, $1, (int)(intptr_t)$3, $4); }
| NOT expr
- { $$ = unary(yylex_param, __NOT__, $2); }
+ { $$ = unary(yylex_param, __NOT__QUES, $2); }
| expr '<' expr
- { $$ = binary(yylex_param, $1, __LT__, $3); }
+ { $$ = binary(yylex_param, $1, __LT__QUES, $3); }
| expr LE expr
- { $$ = binary(yylex_param, $1, __LE__, $3); }
+ { $$ = binary(yylex_param, $1, __LE__QUES, $3); }
| expr '>' expr
- { $$ = binary(yylex_param, $1, __GT__ , $3); }
+ { $$ = binary(yylex_param, $1, __GT__QUES , $3); }
| expr GE expr
- { $$ = binary(yylex_param, $1, __GE__, $3); }
+ { $$ = binary(yylex_param, $1, __GE__QUES, $3); }
| expr NE expr
- { $$ = binary(yylex_param, $1, __NE__, $3); }
+ { $$ = binary(yylex_param, $1, __NE__QUES, $3); }
| expr EQ expr
- { $$ = binary(yylex_param, $1, __EQ__, $3); }
+ { $$ = binary(yylex_param, $1, __EQ__QUES, $3); }
| expr '|' expr
{ $$ = binary(yylex_param, $1, __OR__, $3); }
@@ -686,7 +686,8 @@
}
int yylex (YYSTYPE *lvalp, void* yylex_param){
- int c, tab_count=0, unknown_indent_flag=0, space_after_indent;
+ int c, tab_spc_count=0, unknown_indent_flag=0, wrong_char_in_indent, spaces_per_tab;
+ spaces_per_tab = state->file_indent_flag;
if (state->indents_needed > 0){
state->indents_needed--;
@@ -727,9 +728,31 @@
ungetch(c2, state);
}
if (c == '\n'){
- unknown_indent_flag = 0;
- for(tab_count=0; (c=getch(state)) == '\t'; tab_count++) ;
- space_after_indent = (c == ' ');
+ unknown_indent_flag = 0;
+ if (spaces_per_tab == 0) {
+ if ((c=getch(state)) == '\t') {
+ spaces_per_tab = state->file_indent_flag = -1;
+ tab_spc_count = 1;
+ } else if (c == ' ') {
+ spaces_per_tab++;
+ while ((c=getch(state)) == ' ') spaces_per_tab++;
+ state->file_indent_flag = spaces_per_tab;
+ tab_spc_count = 1;
+ }
+ } else if (spaces_per_tab < 0) {
+ for(tab_spc_count=0; (c=getch(state)) == '\t'; tab_spc_count++) ;
+ } else {
+ int tmp;
+ for(tmp=0; (c=getch(state)) == ' '; tmp++) ;
+ tab_spc_count = tmp / spaces_per_tab;
+ while (tmp != tab_spc_count * spaces_per_tab) {
+ ungetch(c, state);
+ c = ' ';
+ tmp--;
+ }
+ }
+ wrong_char_in_indent = ( spaces_per_tab < 0 && c == ' ' ||
+ spaces_per_tab > 0 && c == '\t' );
while (c == ' ' || c == '\t') c = getch(state);
if (c == '\n' || c == '#')
goto check_comment;
@@ -742,14 +765,14 @@
}
}
ungetch(c, state);
- if (tab_count > state->old_tab_count+1)
+ if (tab_spc_count > state->old_tab_count+1)
continue;
- if (space_after_indent){
- printf("Lexical error: only tabs allowed for indentation\n");
+ if (wrong_char_in_indent){
+ printf("Lexical error: mixed tabs and spaces in indentation\n");
return ERR;
}
- state->indents_needed = tab_count - state->old_tab_count;
- state->old_tab_count = tab_count;
+ state->indents_needed = tab_spc_count - state->old_tab_count;
+ state->old_tab_count = tab_spc_count;
return EOL;
}
break;
@@ -1022,14 +1045,14 @@
int str_index=0, cur_size=INITIAL_STRING_ALLOC;
char string[INITIAL_STRING_ALLOC], *str_ptr=string;
add_string(c, &str_ptr, &str_index, &cur_size);
- while ((c=getch(state)) == '_' || c == '!' ||
+ while ((c=getch(state)) == '_' || c == '!' || c == '?' ||
(c >= '0' && c <= '9') ||
(c >= 'a' && c <= 'z') ||
(c >= 'A' && c <= 'Z') ) {
add_string(c, &str_ptr, &str_index, &cur_size);
- if (c == '!') break;
+ if (c == '!' || c == '?') break;
}
- if (c != '!')
+ if (c != '!' && c != '?')
ungetch(c, state);
str_ptr[str_index++]=0;
if (!strcmp(str_ptr,"lambda")) return LAMBDA;
Modified: trunk/src/symbol.c
===================================================================
--- trunk/src/symbol.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/symbol.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -62,21 +62,21 @@
// this must match exact order in enum sym_enum_t in bytecodes.h
sym_id_entry_t sym_id_table[SYM_ENUM_COUNT] = {
{ "__string__", 0 }, // __string__ must be first (==0)
- { "__not__", 0 },
+ { "__not__QUES", 0 },
{ "__pos__", 0 },
{ "__neg__", 0 },
{ "__invert__", 0 },
- { "__in__", 0 },
- { "__notin__", 0 },
- { "__is__", 0 },
- { "__isnot__", 0 },
+ { "__in__QUES", 0 },
+ { "__notin__QUES", 0 },
+ { "__is__QUES", 0 },
+ { "__isnot__QUES", 0 },
{ "cmp", 0 },
- { "__lt__", 0 },
- { "__le__", 0 },
- { "__gt__", 0 },
- { "__ge__", 0 },
- { "__ne__", 0 },
- { "__eq__", 0 },
+ { "__lt__QUES", 0 },
+ { "__le__QUES", 0 },
+ { "__gt__QUES", 0 },
+ { "__ge__QUES", 0 },
+ { "__ne__QUES", 0 },
+ { "__eq__QUES", 0 },
{ "__or__", 0 },
{ "__xor__", 0 },
{ "__and__", 0 },
@@ -101,8 +101,8 @@
{ "__ifloordiv__", 0 },
{ "__imod__", 0 },
{ "__ipow__", 0 },
- { "__rin__", 0 },
- { "__rnotin__", 0 },
+ { "__rin__QUES", 0 },
+ { "__rnotin__QUES", 0 },
{ "__rlt__", 0 },
{ "__rle__", 0 },
{ "__rgt__", 0 },
@@ -116,7 +116,7 @@
{ "__rpow__", 0 },
{ "__rcmp__", 0 },
{ "__init__", 0 },
- { "__bool__", 0 },
+ { "__bool__QUES", 0 },
{ "__gen__", 0 },
{ "__doc__", 0 },
{ "__hash__", 0 },
@@ -130,7 +130,7 @@
{ "__poslist__", 0 },
{ "__new__", 0 },
{ "__copy__", 0 },
- { "__covers__", 0 },
+ { "__covers__QUES", 0 },
{ "__coerce__", 0 },
{ "__str__", 0 }, // cf
{ "next", 0 },
@@ -215,6 +215,7 @@
char* s = pr_malloc(len+1);
strcpy(s, s_in);
if (!strcmp(s+len-5, "_BANG")) strcpy(s+len-5, "!");
+ if (!strcmp(s+len-5, "_QUES")) strcpy(s+len-5, "?");
pr_lock(&symbol_tree_lock);
sym = search_trie(symbol_tree, s);
if (sym) {
Modified: trunk/src/sys.c
===================================================================
--- trunk/src/sys.c 2004-03-31 06:05:15 UTC (rev 223)
+++ trunk/src/sys.c 2004-03-31 06:14:45 UTC (rev 224)
@@ -87,7 +87,7 @@
static obj_p sys_exit(isp ist, obj_p self, int pcnt, obj_p* parms, obj_p dlocals) {
apr_thread_t* apr_thread;
- if (!has_proto(ist, parms[1], OBJ(INT_PROTO))) {
+ if (!has_proto_QUES(ist, parms[1], OBJ(INT_PROTO))) {
raise_exception(ist, OBJ(TYPE_EXC), "Sys.exit parameter must be an integer");
return NULL;
}