[PATCHES] Re: ORBit2, IDL compiler improvements
- From: Michael Rumpf <michael rumpfonline de>
- To: orbit-list gnome org
- Subject: [PATCHES] Re: ORBit2, IDL compiler improvements
- Date: Fri, 25 Aug 2000 01:49:39 +0200
Hi,
great news !
I'm currently working on a CORBA 2.2 conformance test suite for any kind of idl-compiler.
The tests with orbit-idl surfaced the following problems:
1. 1.5E+15 results in an error because the + sign has not been specified
in the rule from lexer.l
-> FIXED, by updating the rule in lexer.l.
2. octal constants having digits greater or equal 8 are recognized without
an error as floating point constants ( 088 is written as 88.000000 )
-> FIXED, by updating the regular expression in lexer.l
3. \n in string constants gets interpreted instead of just printed into the
header file (this applies to all escaped characters).
-> FIXED, by changing IDL_do_escapes() in libIDL.
4. The lexer connects the two string literals incorrectly:
"\xA" "B" to "\xAB". It should be "\x0AB".
-> Fixed, by changing IDL_do_escapes() in util.c
5. orbit-idl was not returning an error value (<>0) when the compilation
failed. I need this for automatic compilation of invalid IDL constructs.
-> FIXED, by returning -1 in this case (orbit-idl-main.c).
6. orbit-idl accepts \0 in a string constant
-> TODO (still working on that)
7. libIDL is matching const float x = 1;
This is illegal, because const_type is float and literal is an integer!
But worse, you can even write const float x = "test"; !!!!!
I found the following comment in the code (parser.y: const_dcl_def)
/* We should really do some type checking here */
Obviously the literal's type is not checked against the const_type
qualifier.
-> FIXED, by implementing the type checking.
TODO (what *I* will do next):
1. range checking
2. testing operators +, -, *, /, ...
So, more patches are likely to follow... ;-)
Michael
Index: lexer.l
===================================================================
RCS file: /cvs/gnome/libIDL/lexer.l,v
retrieving revision 1.75
diff -r1.75 lexer.l
100c100
< b8_int 0[0-9]*
---
> b8_int 0[0-7]*
103c103,104
< float_lit [0-9]*\.[0-9]+([eE]-?[0-9]+)?|[0-9]+\.?([eE]-?[0-9]+)?
---
> expo [eE][-+]?[0-9]+
> float_lit -?(([0-9]+{expo})|((([0-9]*\.[0-9]+)|([0-9]+\.[0-9]*)){expo}?))
113c114,115
< dqstring \"[^\"\n]*[\"\n]
---
> dqstring \"(([^\"\n\t\0])|("\\"[ntvbrfa\\\?\'\"])|("\\"(([1-7][0-7]?[0-7]?)|([0-7][1-7][0-7]?)|([0-7][0-7][1-7])))|("\\"[xX][0-9a-fA-F]{1,2}))*\"
Index: orbit-idl-main.c
===================================================================
RCS file: /cvs/gnome/ORBit/src/orbit-idl-compiler/orbit-idl-main.c,v
retrieving revision 1.10
diff -r1.10 orbit-idl-main.c
130c130
< int rc;
---
> int rc=0;
152c152
< exit(0);
---
> exit(rc);
176c176
< if (!orbit_idl_to_backend(arg, &rinfo)) {
---
> if (!(rc=orbit_idl_to_backend(arg, &rinfo))) {
177a178
> exit(-1);
Index: parser.y
===================================================================
RCS file: /cvs/gnome/libIDL/parser.y,v
retrieving revision 1.156
diff -r1.156 parser.y
683a684,721
> switch(IDL_NODE_TYPE ($2))
> {
> case IDLN_TYPE_INTEGER:
> if(IDL_NODE_TYPE ($5) != IDLN_INTEGER)
> yyerrorv ("Type mismatch in const long declaration!");
> break;
> case IDLN_TYPE_CHAR:
> if(IDL_NODE_TYPE ($5) != IDLN_CHAR)
> yyerrorv ("Type mismatch in const char declaration!");
> break;
> case IDLN_TYPE_WIDE_CHAR:
> if(IDL_NODE_TYPE ($5) != IDLN_WIDE_CHAR)
> yyerrorv ("Type mismatch in const wchar declaration!");
> break;
> case IDLN_TYPE_BOOLEAN:
> if(IDL_NODE_TYPE ($5) != IDLN_BOOLEAN)
> yyerrorv ("Type mismatch in const boolean declaration!");
> break;
> case IDLN_TYPE_FLOAT:
> if(IDL_NODE_TYPE ($5) != IDLN_FLOAT)
> yyerrorv ("Type mismatch in const float declaration!");
> break;
> case IDLN_TYPE_STRING:
> if(IDL_NODE_TYPE ($5) != IDLN_STRING)
> yyerrorv ("Type mismatch in const string declaration!");
> break;
> case IDLN_TYPE_WIDE_STRING:
> if(IDL_NODE_TYPE ($5) != IDLN_WIDE_STRING)
> yyerrorv ("Type mismatch in const wstring declaration!");
> break;
> case IDLN_TYPE_FIXED:
> if(IDL_NODE_TYPE ($5) != IDLN_FIXED)
> yyerrorv ("Type mismatch in const fixed declaration!");
> break;
> default:
> yyerrorv ("Illegal type for const declaration!");
> break;
> }
685,686c723
< /* Should probably do some type checking here... */
< }
---
> }
Index: util.c
===================================================================
RCS file: /cvs/gnome/libIDL/util.c,v
retrieving revision 1.120
diff -r1.120 util.c
2118d2117
< #define C_ESC(a,b) case a: *p++ = b; ++s; break
2121c2120
< char *p, *q;
---
> char *temp = s, *ret;
2123,2124c2122
< if (!s)
< return NULL;
---
> GString *gstr = g_string_new( "" );
2126c2124,2125
< p = q = g_malloc (strlen (s) + 1);
---
> if (!s)
> return NULL;
2128,2169c2127,2166
< while (*s) {
< if (*s != '\\') {
< *p++ = *s++;
< continue;
< }
< ++s;
< if (*s == 'x') {
< char hex[3];
< int n;
< hex[0] = 0;
< ++s;
< sscanf (s, "%2[0-9a-fA-F]", hex);
< s += strlen (hex);
< sscanf (hex, "%x", &n);
< *p++ = n;
< continue;
< }
< if (*s >= '0' && *s <= '7') {
< char oct[4];
< int n;
< oct[0] = 0;
< sscanf (s, "%3[0-7]", oct);
< s += strlen (oct);
< sscanf (oct, "%o", &n);
< *p++ = n;
< continue;
< }
< switch (*s) {
< C_ESC ('n','\n');
< C_ESC ('t','\t');
< C_ESC ('v','\v');
< C_ESC ('b','\b');
< C_ESC ('r','\r');
< C_ESC ('f','\f');
< C_ESC ('a','\a');
< C_ESC ('\\','\\');
< C_ESC ('?','?');
< C_ESC ('\'','\'');
< C_ESC ('"','"');
< }
< }
< *p = 0;
---
> while( *temp )
> {
> if( *temp == '\\' )
> {
> g_string_append_c( gstr, '\\' );
> ++temp;
> if( *temp == 'x' )
> {
> char hex[3];
> int c = 0;
> g_string_append_c( gstr, 'x' );
> hex[0] = 0;
> ++temp;
> sscanf(temp, "%2[0-9a-fA-F]", hex);
> c = strlen( hex );
> temp += c;
> if( c == 1 )
> g_string_append_c( gstr, '0' );
> g_string_append( gstr, hex );
> continue;
> }
> if( *temp >= '0' && *temp <= '7' )
> {
> char oct[4];
> int c = 0;
> oct[0] = 0;
> sscanf(temp, "%3[0-7]", oct);
> c = strlen( oct );
> temp += c;
> for( c; c < 3; c++ )
> g_string_append_c( gstr, '0' );
> g_string_append( gstr, oct );
> continue;
> }
> g_string_append_c( gstr, *temp );
> }
> else
> g_string_append_c( gstr, *temp );
> temp++;
> }
2171c2168,2170
< return q;
---
> ret = g_strdup( gstr->str );
> g_string_free( gstr, FALSE );
> return ret;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]