SOURCES: baci-20051026.patch (NEW) - patch from author to current ...

undefine undefine at pld-linux.org
Thu Oct 27 00:30:47 CEST 2005


Author: undefine                     Date: Wed Oct 26 22:30:47 2005 GMT
Module: SOURCES                       Tag: HEAD
---- Log message:
- patch from author to current version, many fixes.

---- Files affected:
SOURCES:
   baci-20051026.patch (NONE -> 1.1)  (NEW)

---- Diffs:

================================================================
Index: SOURCES/baci-20051026.patch
diff -u /dev/null SOURCES/baci-20051026.patch:1.1
--- /dev/null	Thu Oct 27 00:30:47 2005
+++ SOURCES/baci-20051026.patch	Thu Oct 27 00:30:42 2005
@@ -0,0 +1,6270 @@
+diff -ur bacisrc/ccomp/baccutil.c bacisrc.ok/ccomp/baccutil.c
+--- bacisrc/ccomp/baccutil.c	2004-04-15 13:31:24.000000000 +0200
++++ bacisrc.ok/ccomp/baccutil.c	2005-10-26 22:11:03.000000000 +0200
+@@ -13,6 +13,7 @@
+ #include "../include/computil.h"
+ #include "../include/pcode.h"
+ #include "../include/incfiles.h"
++#include "../include/writetab.h"
+ 
+ extern   int fprintf(FILE*,const char*,...);
+ 
+@@ -165,9 +166,13 @@
+    /* when name of main pgm is seen in parsing, it's next stid */
+ } /* global_init */ 
+ 
++
+ /*
+  *
+  *  $Log$
+  *  Revision 1.1  2005/10/26 22:30:42  undefine
+  *  - patch from author to current version, many fixes.
+  *
++ *  Revision 2.6  2004/07/21 19:16:54  bynum
++ *  add writetab.h include
++ *
+  *  Revision 2.5  2003/06/25 17:09:46  bynum
+  *  change to Moti Ben-Ari's filename suffix convention
+  *
+diff -ur bacisrc/ccomp/bac.l bacisrc.ok/ccomp/bac.l
+--- bacisrc/ccomp/bac.l	2004-04-15 13:31:23.000000000 +0200
++++ bacisrc.ok/ccomp/bac.l	2005-10-26 22:11:03.000000000 +0200
+@@ -342,7 +342,7 @@
+          }
+       } while (reading);
+    }
+-   return ((esc < 256) ? esc : 0x20);
++   return esc;
+ }
+ 
+ 
+@@ -409,6 +409,9 @@
+ /*
+  *
+  *  $Log$
+  *  Revision 1.1  2005/10/26 22:30:42  undefine
+  *  - patch from author to current version, many fixes.
+  *
++ *  Revision 2.15  2005/10/26 20:03:23  bynum
++ *  remove extraneous test in get_escape
++ *
+  *  Revision 2.14  2004/04/13 15:39:50  bynum
+  *  add \r case to get rid of errors when reading MS-DOS/WIN source files
+  *
+diff -ur bacisrc/ccomp/bac.y bacisrc.ok/ccomp/bac.y
+--- bacisrc/ccomp/bac.y	2004-04-15 13:31:23.000000000 +0200
++++ bacisrc.ok/ccomp/bac.y	2005-10-26 22:11:03.000000000 +0200
+@@ -49,6 +49,7 @@
+ BUFFER   pbuf;   /* string buffer for parsing */
+ /* constants for passing synthesized information back up the parse tree */
+ int   dx,level=0;
++int maxlevel = 0;
+ /* for passing type of constant back to constant productions */
+ TYPES consttype;
+ /* for passing back information to productions using 'type' prod */
+@@ -103,7 +104,6 @@
+ 
+ int   in_func_decl;     /* 1 if declaring a function, 0 otherwise */
+ int   void_function;    /* 1 if function has VOID return type, 0 otherwise */
+-int   func_tab;         /* tab index of function being declared */
+ 
+ #define MAXBREAK  200   
+    /* max # breaks in a nest of loop and switch stmts */
+@@ -360,6 +360,7 @@
+             prt = last_tab;
+             enter_block(&last_btab,&level,last_tab);
+             btab[last_btab].lastpar = last_tab; /* no parms */
++            if (maxlevel < level) maxlevel = level;
+             main_declared = 1;
+             $$ = prt;
+             btab[0].lastpar = prt;  /* save main's tabix for the interp */
+@@ -385,6 +386,7 @@
+             if (main_declared)
+                yyerror("main() proc must be last");
+             if (void_function) {
++               if (curr_ret >= 0) process_returns();
+                if (tab[$1].mon) emit(EXITMON);
+                emit(EXIT_PROC);
+             }
+@@ -464,9 +466,9 @@
+                vis_level = real_level = level;
+             }
+             $$ = prt = enter(lastident(),function,real_level,vis_level);
+-            func_tab = prt;
+             if (in_mon_decl) tab[prt].mon = mtab[mon] - last_predeclared;
+             enter_block(&last_btab,&level,prt);
++            if (maxlevel < level) maxlevel = level;
+             curr_parm_offset = btab[display[level]].vsize;
+             delta_vsize = curr_parm_offset - btab[display[level]].psize;
+             tab[$$].adr = (extern_decl ?  -1 : lc);
+@@ -511,8 +513,9 @@
+             elem_ref = 0;
+             elem_size = 1;  /* a pointer */
+             elem_typ  = strings;
+-            elem_tix = -1;
++            elem_tix = -1; /* not in symbol table */
+             by_value = 0;  /* pass-by-reference */
++            $$ = -1;       /* not in symbol table */
+          }
+       ;
+       
+@@ -536,6 +539,7 @@
+                yyerror("Monitors can only be declared at the global level");
+             enter_block(&last_btab,&level,last_tab);
+             btab[last_btab].lastpar = last_tab;  /* no parms */
++            if (maxlevel < level) maxlevel = level;
+          }
+       ; 
+ 
+@@ -868,7 +872,9 @@
+       ;
+ 
+ for_expr_list  :  expr
++         { free_expr($1); }
+       |  for_expr_list  ','  expr
++         { free_expr($3); }
+       ;
+ 
+ stmt  :  selection_stmt
+@@ -1014,10 +1020,10 @@
+                /* the current case of the enclosing switch block is one */
+                /* less than the first case of this block                */
+             curr_case = switch_block[switch_level].first_case - 1;
++            free_expr(switch_block[switch_level].expr_index);
+             switch_level--;
+             process_breaks();
+             leave_break_block(&break_level,&curr_break,&curr_cont);
+-            free_expr($1);
+          }
+       ;
+ 
+@@ -1297,23 +1303,31 @@
+ return_stmt  :  the_return  opt_expr  ';'
+          {  
+             if (void_function) {
+-               if ($2 < 0)
+-                  emit(EXIT_PROC); 
++               if ($2 < 0) {
++                  if (++curr_ret == MAXRETURN)
++                     cfatal(
++   "No more thn %d 'return' statements can appear in a function",MAXRETURN);
++                  else
++                     return_loc[curr_ret] = lc;    /* mark the JUMP loc */
++                  emit(JUMP);
++               }
+                else
+                   yyerror("Cannot return a value from a 'void' function");
+             }
+-            if ($2 >= 0) 
+-               gen_exprval($2); 
+-            else  /* no expression to push */
+-               emit1(PUSH_LIT,0); 
+-            emit(STORE); 
+-            if (++curr_ret == MAXRETURN)
+-               cfatal(
++            else {   // non void function
++               if ($2 >= 0) 
++                  gen_exprval($2); 
++               else  /* no expression to push */
++                  emit1(PUSH_LIT,0); 
++               emit(STORE); 
++               if (++curr_ret == MAXRETURN)
++                  cfatal(
+    "No more thn %d 'return' statements can appear in a function",MAXRETURN);
+-            else
+-               return_loc[curr_ret] = lc;    /* mark the JUMP loc */
+-            emit(JUMP);   /* jump to fcn exit*/ 
+-         } 
++               else
++                  return_loc[curr_ret] = lc;    /* mark the JUMP loc */
++               emit(JUMP);   /* jump to fcn exit*/ 
++            } 
++         }
+          ; 
+          
+ the_return  :  RETURN 
+@@ -1321,7 +1335,7 @@
+             if (!in_func_decl)
+                yyerror("'return' is inappropriate outside a function");
+             else if (!void_function)
+-                  emit2(LOAD_ADDR,tab[func_tab].lev+1,0);
++                  emit2(LOAD_ADDR,tab[prt].lev+1,0);
+          }
+       ;
+ 
+@@ -1369,6 +1383,7 @@
+                emit1(READ,expr[$3].typ);
+             } else   /* array element */
+                emit1(READ,expr[$3].typ);
++            free_expr($3);
+          }
+       ;
+ 
+@@ -1377,6 +1392,7 @@
+ opt_expr  :  /* empty */
+          { $$ = -1; }
+       |  expr
++         { free_expr($1); }
+       ;
+ 
+ expr_stmt  :  expr  ';'
+@@ -1410,6 +1426,7 @@
+             else
+                yyerror("Type mismatch in assignment");
+             $$ = $2;
++            expr[$$].tix = $1;
+             assign_cnt--;
+          }
+       |  array_var_becomes  expr
+@@ -1420,7 +1437,7 @@
+                    (expr[$1].typ == conds))
+                   yyerror("Cannot assign to 'semaphore' or 'condition'");
+                else if (expr[$1].typ == arrays)
+-                  emit1(COPY_BLOCK,atab[tab[$1].ref].size);
++                  emit1(COPY_BLOCK,atab[expr[$1].ref].size);
+                else  /* standard types */
+                   if (assign_cnt > 1)  /* multiple assignments */
+                      emit(STORE_KEEP);
+@@ -1429,6 +1446,7 @@
+             }
+             else
+                yyerror("Type mismatch in assignment");
++            free_expr($2);
+             expr[$1].isval = 1;
+             $$ = $1;
+             assign_cnt--;
+@@ -1439,9 +1457,6 @@
+          {
+             assign_cnt++;
+             if ((tab[$1].obj == variable)||(tab[$1].obj == ext_variable)) {
+-               if ((tab[$1].typ == sems)||(tab[$1].typ == bsems))
+-                  yyerror("Must use `initialsem' to initialize a 'semaphore'");
+-               else
+                   emit_push_addr(tab[$1]);
+             }
+             else
+@@ -1758,7 +1773,7 @@
+                else{  /* legal func call */
+                   pfstack[toppfs].tix = last_pf; 
+                   pfstack[toppfs].pct = parmct = 0;
+-                  first_stringerr = first_parmcterr = 1;
++                  first_parmcterr = 1;
+                   if (tab[$1].lev != -1){ /* regular proc call */
+                      if ((tab[$1].mon)&&(tab[prt].mon)&&
+                          (tab[$1].mon != tab[prt].mon))
+@@ -1811,6 +1826,7 @@
+ 
+ right_stringparm  :  ','  expr  ')'
+          {
++            $$ = $2;
+             if (expr[$2].typ != strings) {
+                yyerror("right parameter is not of type 'string'");
+                last_eltyp = notyp;
+@@ -2174,6 +2190,9 @@
+ /*
+  *
+  *  $Log$
+  *  Revision 1.1  2005/10/26 22:30:42  undefine
+  *  - patch from author to current version, many fixes.
+  *
++ *  Revision 2.26  2004/07/21 19:17:28  bynum
++ *  correct minor errors discovered in writing the Java version of bacc
++ *
+  *  Revision 2.25  2004/04/13 18:18:40  bynum
+  *  revise grammar to handle C-style expressions
+  *
+diff -ur bacisrc/ccomp/gram.c bacisrc.ok/ccomp/gram.c
+--- bacisrc/ccomp/gram.c	2004-04-15 13:31:23.000000000 +0200
++++ bacisrc.ok/ccomp/gram.c	2005-10-26 22:11:03.000000000 +0200
+@@ -1,61 +1,169 @@
+-/* A Bison parser, made from bac.y
+-   by GNU bison 1.35.  */
++/* A Bison parser, made by GNU Bison 1.875.  */
+ 
+-#define YYBISON 1  /* Identify Bison output.  */
++/* Skeleton parser for Yacc-like parsing with Bison,
++   Copyright (C) 1984, 1989, 1990, 2000, 2001, 2002 Free Software Foundation, Inc.
+ 
+-# define	UNSIGNED_INT	257
+-# define	STRING	258
+-# define	RAWSTRING	259
+-# define	STRINGCONCAT	260
+-# define	STRINGCOMPARE	261
+-# define	STRINGCOPY	262
+-# define	STRINGLENGTH	263
+-# define	IDENTIFIER	264
+-# define	CHARCON	265
+-# define	INCLUDE	266
+-# define	FNSTRING	267
+-# define	NE	268
+-# define	LE	269
+-# define	GE	270
+-# define	EQ	271
+-# define	OR	272
+-# define	AND	273
+-# define	PLPL	274
+-# define	MIMI	275
+-# define	IF	276
+-# define	ELSE	277
+-# define	SWITCH	278
+-# define	CASE	279
+-# define	DEFAULT	280
+-# define	WHILE	281
+-# define	DO	282
+-# define	FOR	283
+-# define	CBEGIN	284
+-# define	CONST	285
+-# define	TYPEDEF	286
+-# define	VOID	287
+-# define	INT	288
+-# define	CHAR	289
+-# define	CONTINUE	290
+-# define	BREAK	291
+-# define	RETURN	292
+-# define	COUT	293
+-# define	LTLT	294
+-# define	ENDL	295
+-# define	CIN	296
+-# define	GTGT	297
+-# define	MAIN	298
+-# define	MONITOR	299
+-# define	INIT	300
+-# define	ATOMIC	301
+-# define	SEND	302
+-# define	RECEIVE	303
+-# define	BROADCAST	304
+-# define	EXTERN	305
+-# define	SSCANF	306
+-# define	SPRINTF	307
+-# define	LOWER_THAN_ELSE	308
++   This program is free software; you can redistribute it and/or modify
++   it under the terms of the GNU General Public License as published by
++   the Free Software Foundation; either version 2, or (at your option)
++   any later version.
++
++   This program is distributed in the hope that it will be useful,
++   but WITHOUT ANY WARRANTY; without even the implied warranty of
++   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++   GNU General Public License for more details.
++
++   You should have received a copy of the GNU General Public License
++   along with this program; if not, write to the Free Software
++   Foundation, Inc., 59 Temple Place - Suite 330,
++   Boston, MA 02111-1307, USA.  */
++
++/* As a special exception, when this file is copied by Bison into a
++   Bison output file, you may use that output file without restriction.
++   This special exception was added by the Free Software Foundation
++   in version 1.24 of Bison.  */
++
++/* Written by Richard Stallman by simplifying the original so called
++   ``semantic'' parser.  */
++
++/* All symbols defined below should begin with yy or YY, to avoid
++   infringing on user name space.  This should be done even for local
++   variables, as they might otherwise be expanded by user macros.
++   There are some unavoidable exceptions within include files to
++   define necessary library symbols; they are noted "INFRINGES ON
++   USER NAME SPACE" below.  */
++
++/* Identify Bison output.  */
++#define YYBISON 1
++
++/* Skeleton name.  */
++#define YYSKELETON_NAME "yacc.c"
++
++/* Pure parsers.  */
++#define YYPURE 0
++
++/* Using locations.  */
++#define YYLSP_NEEDED 0
++
++
++
++/* Tokens.  */
++#ifndef YYTOKENTYPE
++# define YYTOKENTYPE
++   /* Put the tokens into the symbol table, so that GDB and other debuggers
++      know about them.  */
++   enum yytokentype {
++     UNSIGNED_INT = 258,
++     STRING = 259,
++     RAWSTRING = 260,
++     STRINGCONCAT = 261,
++     STRINGCOMPARE = 262,
++     STRINGCOPY = 263,
++     STRINGLENGTH = 264,
++     IDENTIFIER = 265,
++     CHARCON = 266,
++     INCLUDE = 267,
++     FNSTRING = 268,
++     NE = 269,
++     LE = 270,
++     GE = 271,
++     EQ = 272,
++     OR = 273,
++     AND = 274,
++     PLPL = 275,
++     MIMI = 276,
++     IF = 277,
++     ELSE = 278,
++     SWITCH = 279,
++     CASE = 280,
++     DEFAULT = 281,
++     WHILE = 282,
++     DO = 283,
++     FOR = 284,
++     CBEGIN = 285,
++     CONST = 286,
++     TYPEDEF = 287,
++     VOID = 288,
++     INT = 289,
++     CHAR = 290,
++     CONTINUE = 291,
++     BREAK = 292,
++     RETURN = 293,
++     COUT = 294,
++     LTLT = 295,
++     ENDL = 296,
++     CIN = 297,
++     GTGT = 298,
++     MAIN = 299,
++     MONITOR = 300,
++     INIT = 301,
++     ATOMIC = 302,
++     SEND = 303,
++     RECEIVE = 304,
++     BROADCAST = 305,
++     EXTERN = 306,
++     SSCANF = 307,
++     SPRINTF = 308,
++     LOWER_THAN_ELSE = 309
++   };
++#endif
++#define UNSIGNED_INT 258
++#define STRING 259
++#define RAWSTRING 260
++#define STRINGCONCAT 261
++#define STRINGCOMPARE 262
++#define STRINGCOPY 263
++#define STRINGLENGTH 264
++#define IDENTIFIER 265
++#define CHARCON 266
++#define INCLUDE 267
++#define FNSTRING 268
++#define NE 269
++#define LE 270
++#define GE 271
++#define EQ 272
++#define OR 273
++#define AND 274
++#define PLPL 275
++#define MIMI 276
++#define IF 277
++#define ELSE 278
++#define SWITCH 279
++#define CASE 280
++#define DEFAULT 281
++#define WHILE 282
++#define DO 283
++#define FOR 284
++#define CBEGIN 285
++#define CONST 286
++#define TYPEDEF 287
++#define VOID 288
++#define INT 289
++#define CHAR 290
++#define CONTINUE 291
++#define BREAK 292
++#define RETURN 293
++#define COUT 294
++#define LTLT 295
++#define ENDL 296
++#define CIN 297
++#define GTGT 298
++#define MAIN 299
++#define MONITOR 300
++#define INIT 301
++#define ATOMIC 302
++#define SEND 303
++#define RECEIVE 304
++#define BROADCAST 305
++#define EXTERN 306
++#define SSCANF 307
++#define SPRINTF 308
++#define LOWER_THAN_ELSE 309
+ 
++
++
++
++/* Copy the first part of user declarations.  */
+ #line 1 "bac.y"
+ 
+        /* yacc grammar for BenAri Concurrent C */
+@@ -108,6 +216,7 @@
+ BUFFER   pbuf;   /* string buffer for parsing */
+ /* constants for passing synthesized information back up the parse tree */
+ int   dx,level=0;
++int maxlevel = 0;
+ /* for passing type of constant back to constant productions */
+ TYPES consttype;
+ /* for passing back information to productions using 'type' prod */
+@@ -162,7 +271,6 @@
+ 
+ int   in_func_decl;     /* 1 if declaring a function, 0 otherwise */
+ int   void_function;    /* 1 if function has VOID return type, 0 otherwise */
+-int   func_tab;         /* tab index of function being declared */
+ 
+ #define MAXBREAK  200   
+    /* max # breaks in a nest of loop and switch stmts */
+@@ -293,25 +401,153 @@
+ emit2(((x).normal ? LOAD_ADDR : LOAD_VALUE), (x).lev, (x).adr))
+ 
+ 
+-#ifndef YYSTYPE
+-# define YYSTYPE int
+-# define YYSTYPE_IS_TRIVIAL 1
+-#endif
++
++
++/* Enabling traces.  */
+ #ifndef YYDEBUG
+ # define YYDEBUG 1
+ #endif
+ 
++/* Enabling verbose error messages.  */
++#ifdef YYERROR_VERBOSE
++# undef YYERROR_VERBOSE
++# define YYERROR_VERBOSE 1
++#else
++# define YYERROR_VERBOSE 0
++#endif
++
++#if ! defined (YYSTYPE) && ! defined (YYSTYPE_IS_DECLARED)
++typedef int YYSTYPE;
++# define yystype YYSTYPE /* obsolescent; will be withdrawn */
++# define YYSTYPE_IS_DECLARED 1
++# define YYSTYPE_IS_TRIVIAL 1
++#endif
++
++
++
++/* Copy the second part of user declarations.  */
++
++
++/* Line 214 of yacc.c.  */
++#line 432 "y.tab.c"
++
++#if ! defined (yyoverflow) || YYERROR_VERBOSE
++
++/* The parser invokes alloca or malloc; define the necessary symbols.  */
++
++# if YYSTACK_USE_ALLOCA
++#  define YYSTACK_ALLOC alloca
++# else
++#  ifndef YYSTACK_USE_ALLOCA
++#   if defined (alloca) || defined (_ALLOCA_H)
++#    define YYSTACK_ALLOC alloca
++#   else
++#    ifdef __GNUC__
++#     define YYSTACK_ALLOC __builtin_alloca
++#    endif
++#   endif
++#  endif
++# endif
++
++# ifdef YYSTACK_ALLOC
++   /* Pacify GCC's `empty if-body' warning. */
++#  define YYSTACK_FREE(Ptr) do { /* empty */; } while (0)
++# else
++#  if defined (__STDC__) || defined (__cplusplus)
++#   include <stdlib.h> /* INFRINGES ON USER NAME SPACE */
++#   define YYSIZE_T size_t
++#  endif
++#  define YYSTACK_ALLOC malloc
++#  define YYSTACK_FREE free
++# endif
++#endif /* ! defined (yyoverflow) || YYERROR_VERBOSE */
++
++
++#if (! defined (yyoverflow) \
++     && (! defined (__cplusplus) \
<<Diff was trimmed, longer than 597 lines>>



More information about the pld-cvs-commit mailing list