[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
gnue/geas/lib/classdefs classdata.c gcdparser.c...
From: |
Neil Tiffin |
Subject: |
gnue/geas/lib/classdefs classdata.c gcdparser.c... |
Date: |
Tue, 15 May 2001 10:59:07 -0700 |
CVSROOT: /home/cvs
Module name: gnue
Changes by: Neil Tiffin <address@hidden> 01/05/15 10:59:07
Modified files:
geas/lib/classdefs: classdata.c gcdparser.c gcdparser.h
lparser.l
Log message:
Minor changes to remove and clean up code.
CVSWeb URLs:
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/classdata.c.diff?cvsroot=OldCVS&tr1=1.43&tr2=1.44&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/gcdparser.c.diff?cvsroot=OldCVS&tr1=1.29&tr2=1.30&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/gcdparser.h.diff?cvsroot=OldCVS&tr1=1.21&tr2=1.22&r1=text&r2=text
http://savannah.gnu.org/cgi-bin/viewcvs/gnue/geas/lib/classdefs/lparser.l.diff?cvsroot=OldCVS&tr1=1.17&tr2=1.18&r1=text&r2=text
Patches:
Index: gnue/geas/lib/classdefs/classdata.c
diff -u gnue/geas/lib/classdefs/classdata.c:1.43
gnue/geas/lib/classdefs/classdata.c:1.44
--- gnue/geas/lib/classdefs/classdata.c:1.43 Mon May 7 09:34:12 2001
+++ gnue/geas/lib/classdefs/classdata.c Tue May 15 10:59:07 2001
@@ -22,7 +22,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: classdata.c,v 1.43 2001/05/07 16:34:12 ntiffin Exp $
+ $Id: classdata.c,v 1.44 2001/05/15 17:59:07 ntiffin Exp $
*/
@@ -74,11 +74,12 @@
case ODL_ACCESS_SYSTEM:
return ("system");
}
+ g_assert_not_reached();
return ("(unknown access)");
}
/* ------------------------------------------------------------------------- *\
- *
+ * Convert item type int to string value.
\* ------------------------------------------------------------------------- */
const char *
odl_itemtype_name (enum odl_itemtype type)
@@ -86,7 +87,9 @@
switch (type)
{
case IT_type: /* added this to satisify compiler warnings
neilt */
+ return ("type");
case IT_ignore: /* added this to satisify compiler warnings
neilt */
+ return ("ignore");
case IT_unknown:
return ("unknown");
case IT_module:
@@ -98,34 +101,25 @@
case IT_enum:
return ("enum");
}
+ g_assert_not_reached();
return ("unknown");
}
/* ------------------------------------------------------------------------- *\
- *
+ * Convert odl_item_type string to int value.
\* ------------------------------------------------------------------------- */
enum odl_itemtype
odl_itemtype_id (const char *name)
{
-#ifdef DEBUG
- assert (name != NULL);
-#endif
- if (g_strcasecmp (name, "module") == 0)
- {
- return (IT_module);
- }
- if (g_strcasecmp (name, "class") == 0)
- {
- return (IT_class);
- }
- if (g_strcasecmp (name, "field") == 0)
- {
- return (IT_field);
- }
- if (g_strcasecmp (name, "enum") == 0)
- {
- return (IT_enum);
- }
+ g_assert (name != NULL);
+
+ if (g_strcasecmp (name, "module") == 0) return (IT_module);
+ if (g_strcasecmp (name, "class") == 0) return (IT_class);
+ if (g_strcasecmp (name, "field") == 0) return (IT_field);
+ if (g_strcasecmp (name, "enum") == 0) return (IT_enum);
+ if (g_strcasecmp (name, "type") == 0) return (IT_type);
+ if (g_strcasecmp (name, "ignore") == 0) return (IT_ignore);
+ g_assert_not_reached();
return (IT_unknown);
}
@@ -168,6 +162,7 @@
case DT_type:
return ("compound datatype");
}
+ g_assert_not_reached();
return ("unknown");
}
@@ -180,58 +175,21 @@
#ifdef DEBUG
assert (name != NULL);
#endif
- if (g_strcasecmp (name, "char") == 0)
- {
- return (DT_char);
- }
- if (g_strcasecmp (name, "int") == 0)
- {
- return (DT_int);
- }
- if (g_strcasecmp (name, "text") == 0)
- {
- return (DT_text);
- }
- if (g_strcasecmp (name, "float") == 0)
- {
- return (DT_float);
- }
- if (g_strcasecmp (name, "bool") == 0)
- {
- return (DT_bool);
- }
- if (g_strcasecmp (name, "date") == 0)
- {
- return (DT_date);
- }
- if (g_strcasecmp (name, "time") == 0)
- {
- return (DT_time);
- }
- if (g_strcasecmp (name, "datetime") == 0)
- {
- return (DT_datetime);
- }
- if (g_strcasecmp (name, "class") == 0)
- {
- return (DT_class);
- }
- if (g_strcasecmp (name, "void") == 0)
- {
- return (DT_void);
- }
- if (g_strcasecmp (name, "enum") == 0)
- {
- return (DT_enum);
- }
- if (g_strcasecmp (name, "object") == 0)
- {
- return (DT_object);
- }
- if (g_strcasecmp (name, "unsignedint") == 0)
- {
- return (DT_unsignedint);
- }
+ if (g_strcasecmp (name, "char") == 0) return (DT_char);
+ if (g_strcasecmp (name, "int") == 0) return (DT_int);
+ if (g_strcasecmp (name, "text") == 0) return (DT_text);
+ if (g_strcasecmp (name, "class") == 0) return (DT_class);
+ if (g_strcasecmp (name, "date") == 0) return (DT_date);
+ if (g_strcasecmp (name, "time") == 0) return (DT_time);
+ if (g_strcasecmp (name, "datetime") == 0) return (DT_datetime);
+ if (g_strcasecmp (name, "bool") == 0) return (DT_bool);
+ if (g_strcasecmp (name, "float") == 0) return (DT_float);
+ if (g_strcasecmp (name, "void") == 0) return (DT_void);
+ if (g_strcasecmp (name, "object") == 0) return (DT_object);
+ if (g_strcasecmp (name, "enum") == 0) return (DT_enum);
+ if (g_strcasecmp (name, "unsignedint") == 0) return (DT_unsignedint);
+ if (g_strcasecmp (name, "type") == 0) return (DT_type);
+ /* g_assert_not_reached(); /* parser requires 'unknown' return */
return (DT_unknown);
}
@@ -243,8 +201,8 @@
{
switch (type)
{
- case FT_unknown:
- return ("unknown");
+ case FT_basic:
+ return ("basic");
case FT_lookup:
return ("lookup");
case FT_reference:
@@ -257,9 +215,10 @@
return ("calculated");
case FT_readonly:
return ("readonly");
- case FT_basic:
- return ("basic");
+ case FT_unknown:
+ return ("unknown");
}
+ g_assert_not_reached();
return ("unknown");
}
@@ -272,34 +231,14 @@
#ifdef DEBUG
assert (name != NULL);
#endif
- if (g_strcasecmp (name, "lookup") == 0)
- {
- return (FT_lookup);
- }
- if (g_strcasecmp (name, "reference") == 0)
- {
- return (FT_reference);
- }
- if (g_strcasecmp (name, "list") == 0)
- {
- return (FT_list);
- }
- if (g_strcasecmp (name, "method") == 0)
- {
- return (FT_method);
- }
- if (g_strcasecmp (name, "calculated") == 0)
- {
- return (FT_calculated);
- }
- if (g_strcasecmp (name, "readonly") == 0)
- {
- return (FT_readonly);
- }
- if (g_strcasecmp (name, "basic") == 0)
- {
- return (FT_basic);
- }
+ if (g_strcasecmp (name, "lookup") == 0) return (FT_lookup);
+ if (g_strcasecmp (name, "reference") == 0) return (FT_reference);
+ if (g_strcasecmp (name, "list") == 0) return (FT_list);
+ if (g_strcasecmp (name, "method") == 0) return (FT_method);
+ if (g_strcasecmp (name, "calculated") == 0) return (FT_calculated);
+ if (g_strcasecmp (name, "readonly") == 0) return (FT_readonly);
+ if (g_strcasecmp (name, "basic") == 0) return (FT_basic);
+ g_assert_not_reached();
return (FT_unknown);
}
@@ -1592,6 +1531,7 @@
/* ------------------------------------------------------------------------- *\
* Scan the data base and replace all fields that are TYPES (not real fields)
* with the wanted exploded fields from the TYPE definition.
+ * TODO move to gcdparser.c
\* ------------------------------------------------------------------------- */
static void
odl_process_coumpound_types (odl_container * c)
@@ -2219,9 +2159,7 @@
void
odl_free_tree (odl_tree * tree)
{
-#ifdef DEBUG
- assert (tree != NULL);
-#endif
+ g_assert (tree != NULL);
free_odl_tree (tree);
}
Index: gnue/geas/lib/classdefs/gcdparser.c
diff -u gnue/geas/lib/classdefs/gcdparser.c:1.29
gnue/geas/lib/classdefs/gcdparser.c:1.30
--- gnue/geas/lib/classdefs/gcdparser.c:1.29 Mon May 7 09:34:12 2001
+++ gnue/geas/lib/classdefs/gcdparser.c Tue May 15 10:59:07 2001
@@ -22,13 +22,12 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: gcdparser.c,v 1.29 2001/05/07 16:34:12 ntiffin Exp $
+ $Id: gcdparser.c,v 1.30 2001/05/15 17:59:07 ntiffin Exp $
*/
-/** \file gcdparser.h
- * \brief This file should not be used outside of the ODL class library
- * This contains functions used inside the GCD parser.
+/** \file gcdparser.c
+ * \brief This contains functions used inside the GCD parser.
*/
#include <glib.h>
@@ -48,20 +47,17 @@
alloc_odl_tree ()
{
struct _odl_tree *t = g_new0 (struct _odl_tree, 1);
-#ifdef DEBUG
- assert (t != NULL);
-#endif
+ g_assert (t != NULL);
if (t)
{
t->root = alloc_odl_container (NULL, -1);
-#ifdef DEBUG
- assert (t->root != NULL);
-#endif
+ g_assert (t->root != NULL);
if (t->root)
{
/* root module stores all other modules */
t->root->base.type = IT_module;
t->root->base.name = g_strdup ("root");
+ g_assert (t->root->base.name != NULL);
if (!t->root->base.name)
{
free_odl_tree (t);
@@ -465,7 +461,9 @@
}
/* ------------------------------------------------------------------------- *\
- *
+ * For list and reference fields (i.e. classname * fieldname or
+ * classname [] fieldname) makes
+ * actual fields that are used to implement the requested fields.
\* ------------------------------------------------------------------------- */
GList *
odl_reprocess_fields (_odl_datatype * datatype, GList * fields)
@@ -475,10 +473,9 @@
odl_item *i;
odl_item *a;
-#ifdef DEBUG
- assert (datatype != NULL);
- assert (fields != NULL);
-#endif
+ g_assert (datatype != NULL);
+ g_assert (fields != NULL);
+
f = fields;
while (f)
{
@@ -488,16 +485,10 @@
/* store the datatype in this field data */
i->datatype = datatype->dt;
i->bounds = datatype->bound;
-
- i->datatype = datatype->dt;
- if (datatype->unsignedval)
+ if ((datatype->unsignedval) && (i->datatype == DT_int))
{
- if (i->datatype == DT_int)
- {
- i->datatype = DT_unsignedint;
- }
+ i->datatype = DT_unsignedint;
}
-
/* skip 'type' created fields til later */
if (datatype->dt == DT_type)
{
@@ -506,13 +497,16 @@
i->datatype = DT_type;
i->datatypeclass = g_strdup (datatype->name);
}
-
- if ((datatype->dt == DT_class || datatype->dt == DT_enum)
- && datatype->dt != DT_type)
+ /* only do the reference and list types on pass 2 */
+ /* if (current_pass != 2) return fields; */
+ if ((datatype->dt == DT_class || datatype->dt == DT_enum))
{
if (i->fieldtype == FT_basic && i->datatype == DT_class)
{
- /* turn it into a reference or list class */
+ /* if -1 turn it into a reference */
+ /* else 0 or positive a list class */
+ /* else < -1 invalid */
+ g_assert( i->bounds > -2);
if (i->bounds == (-1))
{
/* reference */
Index: gnue/geas/lib/classdefs/gcdparser.h
diff -u gnue/geas/lib/classdefs/gcdparser.h:1.21
gnue/geas/lib/classdefs/gcdparser.h:1.22
--- gnue/geas/lib/classdefs/gcdparser.h:1.21 Mon May 14 11:40:47 2001
+++ gnue/geas/lib/classdefs/gcdparser.h Tue May 15 10:59:07 2001
@@ -21,7 +21,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: gcdparser.h,v 1.21 2001/05/14 18:40:47 ntiffin Exp $
+ $Id: gcdparser.h,v 1.22 2001/05/15 17:59:07 ntiffin Exp $
*/
@@ -100,7 +100,7 @@
};
/** \struct _odl_argument
- * \brief
+ * \brief Stores method arguments.
*/
struct _odl_argument
{
@@ -111,7 +111,7 @@
};
/** \struct _odl_tree
- * \brief
+ * \brief Root of the ODL definition tree.
*/
struct _odl_tree
{
@@ -119,7 +119,7 @@
};
/** \struct _odl_datatype
- * \brief
+ * \brief ODL data type structure for passing around in functions.
*/
typedef struct
{
Index: gnue/geas/lib/classdefs/lparser.l
diff -u gnue/geas/lib/classdefs/lparser.l:1.17
gnue/geas/lib/classdefs/lparser.l:1.18
--- gnue/geas/lib/classdefs/lparser.l:1.17 Sun May 6 16:20:42 2001
+++ gnue/geas/lib/classdefs/lparser.l Tue May 15 10:59:07 2001
@@ -24,7 +24,7 @@
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
- $Id: lparser.l,v 1.17 2001/05/06 23:20:42 ntiffin Exp $
+ $Id: lparser.l,v 1.18 2001/05/15 17:59:07 ntiffin Exp $
*/
@@ -131,18 +131,18 @@
<incl>{whitespace} { /* ignore */ token_pos += yyleng; }
<incl>{qstring} { char *p,*q;
p = yytext + 1;
- q = strchr( p , '"' );
- *q = '\0';
- if( is_file_done(p) ) BEGIN(endincl);
- else {
- /* not already processed, so start it now */
- record_file_processed(p);
- if( push_file(p) ) {
- BEGIN(FULLLINE);
- }
- else BEGIN(failinclude);
- }
- }
+ q = strchr( p , '"' );
+ *q = '\0';
+ if( is_file_done(p) ) BEGIN(endincl);
+ else {
+ /* not already processed, so start it now */
+ record_file_processed(p);
+ if( push_file(p) ) {
+ BEGIN(FULLLINE);
+ }
+ else BEGIN(failinclude);
+ }
+ }
<incl>{whitespace}{newline} { yywarn("No filename given for include
directive"); BEGIN(failinclude); }
<incl>{whitespace}[^\"\n]+\n |
@@ -158,10 +158,10 @@
<FULLLINE>\n |
<FULLLINE>[^\n]* { /* record the current line, truncating if necessary */
strncpy( linebuf , yytext , LINEBUF_LENGTH-1 );\
- linebuf[ strlen(linebuf) ] = '\0';
- token_pos = 1;
- BEGIN(INITIAL);
- yyless(0);
+ linebuf[ strlen(linebuf) ] = '\0';
+ token_pos = 1;
+ BEGIN(INITIAL);
+ yyless(0);
}
^{whitespace}{newline} |
@@ -179,7 +179,7 @@
[+-]?[0-9]+ { ST; yylval.integer = atol(yytext); return(INTEGER); }
[+-]?[0-9]+.[0-9]+ { ST; yylval.floating = atof(yytext); return(DOUBLE); }
- /* this set can be followed by more datatype fields, and the parser
must reset expecting_datatype */
+ /* this set can be followed by more datatype fields, and the parser
must reset expecting_datatype */
public { ST; if( expecting_datatype == 1 ) return(PUBLIC);
else return(SYMBOL); }
protected { ST; if( expecting_datatype == 1 ) return(PROTECTED);
else return(SYMBOL); }
private { ST; if( expecting_datatype == 1 ) return(PRIVATE);
else return(SYMBOL); }
@@ -189,11 +189,11 @@
singleton { ST; if( expecting_datatype == 1 ) return(SINGLETON);
else return(SYMBOL); }
readonly { ST; if( expecting_datatype == 1 ) return(READONLY);
else return(SYMBOL); }
- /* the same, except using expecting_fieldprop */
+ /* the same, except using expecting_fieldprop */
not { ST; if( expecting_fieldprop == 1 ) return(NOT); else
return(SYMBOL); }
null { ST; if( expecting_fieldprop == 1 ) return(NUL); else
return(SYMBOL); }
- /* this set is the final entry in a datatype, so can reset
expecting_datatype here */
+ /* this set is the final entry in a datatype, so can reset
expecting_datatype here */
module { ST; if( expecting_datatype == 1 ) { expecting_datatype =
0; return(MODULE); } else { yylval.string=g_strdup(yytext); return(SYMBOL);
} }
class { ST; if( expecting_datatype == 1 ) { expecting_datatype =
0; return(CLASS); } else { yylval.string=g_strdup(yytext); return(SYMBOL);
} }
type { ST; if( expecting_datatype == 1 ) { expecting_datatype =
0; return(CTYPE); } else { yylval.string=g_strdup(yytext); return(SYMBOL);
} }
@@ -216,7 +216,7 @@
if( expecting_datatype == 1 ) {
expecting_datatype = 0;
tmp = odl_datatype_id( yytext );
- yylval.string = g_strdup( yytext );
+ yylval.string = g_strdup( yytext );
if( tmp != DT_unknown ) return(DATATYPE);
}
else if(expect_triggertype == 1) {
@@ -233,23 +233,23 @@
if( expecting_datatype == 1 ) {
expecting_datatype = 0;
tmp = odl_datatype_id( yytext );
- yylval.string = g_strdup( yytext );
+ yylval.string = g_strdup( yytext );
if( tmp != DT_unknown ) return(DATATYPE);
}
else if(expect_triggertype == 1) {
- /* not valid symbol, but not expecting a symbol
*/
+ /* not valid symbol, but not expecting a
symbol */
/* so the more useful syntax error will be
generated */
return(SYMBOL);
}
/* not expecting a datatype or trigger type, or
didn't get one */
- if( current_pass == 1 ) {
- if( strstr(yytext,"__") != NULL )
- yyerror( "Double underscores are not allowed
in identifiers" );
- else if( yytext[0] == '_' )
- yyerror( "Leading underscores are not
allowed in identifiers" );
- else if( yytext[ strlen(yytext)-1 ] == '_' )
- yyerror( "Trailing underscores are not
allowed in identifiers" );
- }
+ if( current_pass == 1 ) {
+ if( strstr(yytext,"__") != NULL )
+ yyerror( "Double underscores are not
allowed in identifiers" );
+ else if( yytext[0] == '_' )
+ yyerror( "Leading underscores are not
allowed in identifiers" );
+ else if( yytext[ strlen(yytext)-1 ] == '_' )
+ yyerror( "Trailing underscores are not
allowed in identifiers" );
+ }
yylval.string = g_strdup( yytext );
return(SYMBOL);
}
@@ -276,18 +276,18 @@
if( yy_show_file_error == 1 ) {
fprintf( stderr , "%s\n" , linebuf );
for( i=1 ; i<token_pos ; i++ )
- {
- if( linebuf[i] == '\t' )
- fprintf( stderr , "\t" );
- else
- fprintf( stderr , " " );
- }
+ {
+ if( linebuf[i] == '\t' )
+ fprintf( stderr , "\t" );
+ else
+ fprintf( stderr , " " );
+ }
fprintf( stderr , "^\n" );
}
fprintf( stderr , "\n" );
return( 0 );
}
-
+
int yywarn( char *format , ... )
{
int i;
@@ -307,19 +307,19 @@
fprintf( stderr , "%s\n" , linebuf );
for( i=1 ; i<token_pos ; i++ )
- {
- if( linebuf[i] == '\t' )
- fprintf( stderr , "\t" );
- else
- fprintf( stderr , " " );
- }
+ {
+ if( linebuf[i] == '\t' )
+ fprintf( stderr , "\t" );
+ else
+ fprintf( stderr , " " );
+ }
fprintf( stderr , "^\n" );
}
fprintf( stderr , "\n" );
return( 0 );
}
-
+
int yymessage( char *format , ... )
{
int i;
@@ -436,9 +436,9 @@
/* printf( "fopen : %08lx\n" , fp ); */
/* ntiffin */ /* reset lexer state */
- expecting_datatype = 1;
- expecting_fieldprop = 0;
- expect_triggertype = 0;
+ expecting_datatype = 1;
+ expecting_fieldprop = 0;
+ expect_triggertype = 0;
/* setup lexer */
yyrestart( fp );
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- gnue/geas/lib/classdefs classdata.c gcdparser.c...,
Neil Tiffin <=