Am Sonntag, 23. Juli 2006 18:09 schrieb Vishal Soni:
Hi,
Can some one help me with Flex debugging?
Previously if I recall correctly the adding %option debug in imcc.l use
to spit out debug information to the console. This does not seem to work
now.
$ info flex
sayeth:
`-d, --debug, `%option debug''
makes the generated scanner run in debug mode. Whenever a
pattern is recognized and the global variable `yy_flex_debug' is
non-zero (which is the default), the scanner will write to
`stderr' a line of the form:
i.e. differently to previous versions, `yy_flex_debug' also needs turning on,
which could probably done along with turning on 'yydebug' with the -y
commandline switch. While above states that `yy_flex_debug' would be turned
on by default, a 'find ... grep' shows no indications for that.
*But* trying that [1], it seems that it's just not working.
-Vishal
leo
[1] the patch w/o func proto
Index: src/dynoplibs/myops.ops
===
--- src/dynoplibs/myops.ops (Revision 13449)
+++ src/dynoplibs/myops.ops (Arbeitskopie)
@@ -101,6 +101,23 @@
goto NEXT();
}
+=item Bif_else(in INT, labelconst INT, labelconst INT)
+
+Opcode to test multiple lables. Branch to 1st label on true $1, else to 2nd.
+
+=cut
+
+op if_else(in INT, labelconst INT, labelconst INT) {
+if ($1) {
+ goto OFFSET($2);
+}
+else {
+ goto OFFSET($3);
+}
+ goto NEXT(); /* unused */
+}
+
+
=back
=cut
Index: compilers/imcc/imclexer.c
===
--- compilers/imcc/imclexer.c (Revision 13449)
+++ compilers/imcc/imclexer.c (Arbeitskopie)
@@ -14,16 +14,32 @@
#define FLEX_BETA
#endif
+/* %if-c++-only */
+/* %endif */
+
+/* %if-c-only */
+
+/* %endif */
+
+/* %if-c-only */
+
+/* %endif */
+
/* First, we deal with platform-specific or compiler-specific issues. */
/* begin standard C headers. */
+/* %if-c-only */
#include stdio.h
#include string.h
#include errno.h
#include stdlib.h
+/* %endif */
+/* %if-tables-serialization */
+/* %endif */
/* end standard C headers. */
+/* %if-c-or-c++ */
/* flex integer type definitions */
#ifndef FLEXINT_H
@@ -87,6 +103,11 @@
#endif /* ! FLEXINT_H */
+/* %endif */
+
+/* %if-c++-only */
+/* %endif */
+
#ifdef __cplusplus
/* The const storage-class-modifier is valid. */
@@ -107,16 +128,24 @@
#define yyconst
#endif
+/* %not-for-header */
+
/* Returned upon end-of-file. */
#define YY_NULL 0
+/* %ok-for-header */
+/* %not-for-header */
+
/* Promotes a possibly negative, possibly signed char to an unsigned
* integer for use as an array index. If the signed char is negative,
* we want to instead treat it as an 8-bit unsigned char, hence the
* double cast.
*/
#define YY_SC_TO_UI(c) ((unsigned int) (unsigned char) c)
+/* %ok-for-header */
+/* %if-reentrant */
+
/* An opaque pointer. */
#ifndef YY_TYPEDEF_YY_SCANNER_T
#define YY_TYPEDEF_YY_SCANNER_T
@@ -135,7 +164,11 @@
#define yy_flex_debug yyg-yy_flex_debug_r
int yylex_init (yyscan_t* scanner);
+/* %endif */
+/* %if-not-reentrant */
+/* %endif */
+
/* Enter a start condition. This macro really ought to take a parameter,
* but we do it the disgusting crufty way forced on us by the ()-less
* definition of BEGIN.
@@ -171,6 +204,14 @@
typedef struct yy_buffer_state *YY_BUFFER_STATE;
#endif
+/* %if-not-reentrant */
+/* %endif */
+
+/* %if-c-only */
+/* %if-not-reentrant */
+/* %endif */
+/* %endif */
+
#define EOB_ACT_CONTINUE_SCAN 0
#define EOB_ACT_END_OF_FILE 1
#define EOB_ACT_LAST_MATCH 2
@@ -207,8 +248,13 @@
#define YY_STRUCT_YY_BUFFER_STATE
struct yy_buffer_state
{
+/* %if-c-only */
FILE *yy_input_file;
+/* %endif */
+/* %if-c++-only */
+/* %endif */
+
char *yy_ch_buf; /* input buffer */
char *yy_buf_pos; /* current position in input buffer */
@@ -268,6 +314,15 @@
};
#endif /* !YY_STRUCT_YY_BUFFER_STATE */
+/* %if-c-only Standard (non-C++) definition */
+/* %not-for-header */
+
+/* %if-not-reentrant */
+/* %endif */
+/* %ok-for-header */
+
+/* %endif */
+
/* We provide macros for accessing buffer states in case in the
* future we want to put the buffer states in a more general
* scanner state.
@@ -283,6 +338,15 @@
*/
#define YY_CURRENT_BUFFER_LVALUE yyg-yy_buffer_stack[yyg-yy_buffer_stack_top]
+/* %if-c-only Standard (non-C++) definition */
+
+/* %if-not-reentrant */
+/* %not-for-header */
+
+/* %ok-for-header */
+
+/* %endif */
+
void yyrestart (FILE *input_file ,yyscan_t yyscanner );
void yy_switch_to_buffer (YY_BUFFER_STATE new_buffer ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_create_buffer (FILE *file,int size ,yyscan_t yyscanner );
@@ -301,6 +365,8 @@
YY_BUFFER_STATE yy_scan_string (yyconst char *yy_str ,yyscan_t yyscanner );
YY_BUFFER_STATE yy_scan_bytes (yyconst char *bytes,int len ,yyscan_t yyscanner );
+/* %endif */
+
void *yyalloc (yy_size_t ,yyscan_t yyscanner );
void *yyrealloc