ansificated compiler sources
Warning, cannot access the index:
_darcs/index: opening of '_darcs/index' failed: permission denied (Permission denied)
diff -rN -u old-branch-2-0/src/snc/parse.c new-branch-2-0/src/snc/parse.c
--- old-branch-2-0/src/snc/parse.c 2022-09-26 04:11:50.681832038 +0200
+++ new-branch-2-0/src/snc/parse.c 2022-09-26 04:11:50.685832134 +0200
@@ -66,10 +66,10 @@
Expr *global_c_list; /* global C code following state program */
-Chan *build_db_struct();
-void alloc_db_lists();
-void addVar();
-void addChan();
+Chan *build_db_struct(Var *vp);
+void alloc_db_lists(Chan *cp, int length);
+void addVar(Var *vp);
+void addChan(Chan *cp);
/*+************************************************************************
* NAME: program_name
@@ -84,8 +84,7 @@
* FUNCTION: Save program name for global use.
*
*-*************************************************************************/
-void program_name(pname, pparam)
-char *pname, *pparam;
+void program_name(char *pname, char *pparam)
{
prog_name = pname;
prog_param = pparam;
@@ -96,13 +95,14 @@
}
/* Parsing a declaration statement */
-void decl_stmt(type, class, name, s_length1, s_length2, value)
-int type; /* variable type (e.g. V_FLOAT) */
-int class; /* variable class (e.g. VC_ARRAY) */
-char *name; /* ptr to variable name */
-char *s_length1; /* array lth (1st dim, arrays only) */
-char *s_length2; /* array lth (2nd dim, [n]x[m] arrays only) */
-char *value; /* initial value or NULL */
+void decl_stmt(
+ int type, /* variable type (e.g. V_FLOAT) */
+ int class, /* variable class (e.g. VC_ARRAY) */
+ char *name, /* ptr to variable name */
+ char *s_length1, /* array lth (1st dim, arrays only) */
+ char *s_length2, /* array lth (2nd dim, [n]x[m] arrays only) */
+ char *value /* initial value or NULL */
+)
{
Var *vp;
int length1, length2;
@@ -153,9 +153,10 @@
}
/* Option statement */
-void option_stmt(option, value)
-char *option; /* "a", "r", ... */
-int value; /* TRUE means +, FALSE means - */
+void option_stmt(
+ char *option, /* "a", "r", ... */
+ int value /* TRUE means +, FALSE means - */
+)
{
extern int async_opt, conn_opt, debug_opt, line_opt, init_reg_opt,
reent_opt, warn_opt, newef_opt, main_opt;
@@ -197,9 +198,10 @@
* Format: assign <variable> to <string;
* Note: Variable may be subscripted.
*/
-void assign_single(name, db_name)
-char *name; /* ptr to variable name */
-char *db_name; /* ptr to db name */
+void assign_single(
+ char *name, /* ptr to variable name */
+ char *db_name /* ptr to db name */
+)
{
Chan *cp;
Var *vp;
@@ -238,10 +240,11 @@
/* "Assign" statement: assign an array element to a DB channel.
* Format: assign <variable>[<subscr>] to <string>; */
-void assign_subscr(name, subscript, db_name)
-char *name; /* ptr to variable name */
-char *subscript; /* subscript value or NULL */
-char *db_name; /* ptr to db name */
+void assign_subscr(
+ char *name, /* ptr to variable name */
+ char *subscript, /* subscript value or NULL */
+ char *db_name /* ptr to db name */
+)
{
Chan *cp;
Var *vp;
@@ -312,9 +315,10 @@
* If db name list contains fewer names than the array dimension,
* the remaining elements receive NULL assignments.
*/
-void assign_list(name, db_name_list)
-char *name; /* ptr to variable name */
-Expr *db_name_list; /* ptr to db name list */
+void assign_list(
+ char *name, /* ptr to variable name */
+ Expr *db_name_list /* ptr to db name list */
+)
{
Chan *cp;
Var *vp;
@@ -376,8 +380,7 @@
}
/* Build a db structure for this variable */
-Chan *build_db_struct(vp)
-Var *vp;
+Chan *build_db_struct(Var *vp)
{
Chan *cp;
@@ -402,9 +405,7 @@
}
/* Allocate lists for assigning multiple pv's to a variable */
-void alloc_db_lists(cp, length)
-Chan *cp;
-int length;
+void alloc_db_lists(Chan *cp, int length)
{
/* allocate an array of pv names */
cp->db_name_list = (char **)calloc(sizeof(char **), length);
@@ -427,9 +428,10 @@
* monitor <var>; - monitor a single variable or all elements in an array.
* monitor <var>[<m>]; - monitor m-th element of an array.
*/
-void monitor_stmt(name, subscript)
-char *name; /* variable name (should be assigned) */
-char *subscript; /* element number or NULL */
+void monitor_stmt(
+ char *name, /* variable name (should be assigned) */
+ char *subscript /* element number or NULL */
+)
{
Var *vp;
Chan *cp;
@@ -497,10 +499,7 @@
}
/* Parsing "sync" statement */
-void sync_stmt(name, subscript, ef_name)
-char *name;
-char *subscript;
-char *ef_name;
+void sync_stmt(char *name, char *subscript, char *ef_name)
{
Chan *cp;
Var *vp;
@@ -568,11 +567,7 @@
}
/* Parsing "syncq" statement */
-void syncq_stmt(name, subscript, ef_name, maxQueueSize)
-char *name;
-char *subscript;
-char *ef_name;
-char *maxQueueSize;
+void syncq_stmt(char *name, char *subscript, char *ef_name, char *maxQueueSize)
{
Chan *cp;
Var *vp;
@@ -664,8 +659,9 @@
/* Definition C code */
-void defn_c_stmt(c_list)
-Expr *c_list; /* ptr to C code */
+void defn_c_stmt(
+ Expr *c_list /* ptr to C code */
+)
{
#ifdef DEBUG
fprintf(stderr, "defn_c_stmt\n");
@@ -679,8 +675,9 @@
}
/* Global C code (follows state program) */
-void global_c_stmt(c_list)
-Expr *c_list; /* ptr to C code */
+void global_c_stmt(
+ Expr *c_list /* ptr to C code */
+)
{
global_c_list = c_list;
@@ -689,8 +686,7 @@
/* Add a variable to the variable linked list */
-void addVar(vp)
-Var *vp;
+void addVar(Var *vp)
{
if (var_list == NULL)
var_list = vp;
@@ -702,8 +698,7 @@
/* Find a variable by name; returns a pointer to the Var struct;
returns 0 if the variable is not found. */
-Var *findVar(name)
-char *name;
+Var *findVar(char *name)
{
Var *vp;
@@ -718,8 +713,7 @@
}
/* Add a channel to the channel linked list */
-void addChan(cp)
-Chan *cp;
+void addChan(Chan *cp)
{
if (chan_list == NULL)
chan_list = cp;
@@ -730,15 +724,13 @@
}
/* Set debug print opt */
-void set_debug_print(opt)
-char *opt;
+void set_debug_print(char *opt)
{
debug_print_opt = atoi(opt);
}
/* Parsing "program" statement */
-void program(prog_list)
-Expr *prog_list;
+void program(Expr *prog_list)
{
ss_list = prog_list;
#ifdef DEBUG
@@ -750,16 +742,14 @@
}
/* Entry code */
-int entry_code(ep)
-Expr *ep;
+int entry_code(Expr *ep)
{
entry_code_list = ep;
return 0;
}
/* Exit code */
-int exit_code(ep)
-Expr *ep;
+int exit_code(Expr *ep)
{
exit_code_list = ep;
return 0;
@@ -768,11 +758,12 @@
/* Build an expression list (hierarchical):
Builds a node on a binary tree for each expression primitive.
*/
-Expr *expression(type, value, left, right)
-int type; /* E_BINOP, E_ASGNOP, etc */
-char *value; /* "==", "+=", var name, constant, etc. */
-Expr *left; /* LH side */
-Expr *right; /* RH side */
+Expr *expression(
+ int type, /* E_BINOP, E_ASGNOP, etc */
+ char *value, /* "==", "+=", var name, constant, etc. */
+ Expr *left, /* LH side */
+ Expr *right /* RH side */
+)
{
Expr *ep;
extern int line_num, c_line_num;
@@ -805,9 +796,10 @@
/* Link two expression structures and/or lists. Returns ptr to combined list.
Note: ->last ptrs are correct only for 1-st and last structures in the list */
-Expr *link_expr(ep1, ep2)
-Expr *ep1; /* beginning of 1-st structure or list */
-Expr *ep2; /* beginning 2-nd (append it to 1-st) */
+Expr *link_expr(
+ Expr *ep1, /* beginning of 1-st structure or list */
+ Expr *ep2 /* beginning 2-nd (append it to 1-st) */
+)
{
if (ep1 == 0 && ep2 == 0)
return NULL;
@@ -832,9 +824,7 @@
}
/* Interpret pre-processor code */
-void pp_code(line, fname)
-char *line;
-char *fname;
+void pp_code(char *line, char *fname)
{
extern int line_num;
extern char *src_file;
diff -rN -u old-branch-2-0/src/snc/parse.h new-branch-2-0/src/snc/parse.h
--- old-branch-2-0/src/snc/parse.h 2022-09-26 04:11:50.681832038 +0200
+++ new-branch-2-0/src/snc/parse.h 2022-09-26 04:11:50.685832134 +0200
@@ -83,10 +83,6 @@
typedef struct db_chan Chan;
/* Note: Only one of db_name or db_name_list can have a non-zero value */
-Expr *expression(), *link_expr();
-Var *findVar();
-Chan *findChan();
-
/* Linked list allocation definitions */
#define allocExpr() (Expr *)calloc(1, sizeof(Expr));
#define allocVar() (Var *)calloc(1, sizeof(Var));
@@ -145,5 +141,11 @@
#define E_ENTRY 26 /* entry statement */
#define E_EXIT 27 /* exit statement */
#define E_OPTION 28 /* state option statement */
-#endif /*INCLparseh*/
+Var *findVar(char *name);
+Expr *link_expr(
+ Expr *ep1, /* beginning of 1-st structure or list */
+ Expr *ep2 /* beginning 2-nd (append it to 1-st) */
+);
+
+#endif /*INCLparseh*/
diff -rN -u old-branch-2-0/src/snc/parsedefs.h new-branch-2-0/src/snc/parsedefs.h
--- old-branch-2-0/src/snc/parsedefs.h 1970-01-01 01:00:00.000000000 +0100
+++ new-branch-2-0/src/snc/parsedefs.h 2022-09-26 04:11:50.685832134 +0200
@@ -0,0 +1,59 @@
+#ifndef INCLparsedefsh
+#define INCLparsedefsh
+
+/* defined in snc_main.c */
+void yyerror(char *err);
+void snc_err(char *err_txt);
+
+/* defined in parse.c */
+void program(Expr *prog_list);
+void program_name(char *pname, char *pparam);
+void assign_single(
+ char *name, /* ptr to variable name */
+ char *db_name /* ptr to db name */
+);
+void assign_subscr(
+ char *name, /* ptr to variable name */
+ char *subscript, /* subscript value or NULL */
+ char *db_name /* ptr to db name */
+);
+void assign_list(
+ char *name, /* ptr to variable name */
+ Expr *db_name_list /* ptr to db name list */
+);
+Expr *expression(
+ int type, /* E_BINOP, E_ASGNOP, etc */
+ char *value, /* "==", "+=", var name, constant, etc. */
+ Expr *left, /* LH side */
+ Expr *right /* RH side */
+);
+void monitor_stmt(
+ char *name, /* variable name (should be assigned) */
+ char *subscript /* element number or NULL */
+);
+void set_debug_print(char *opt);
+void decl_stmt(
+ int type, /* variable type (e.g. V_FLOAT) */
+ int class, /* variable class (e.g. VC_ARRAY) */
+ char *name, /* ptr to variable name */
+ char *s_length1, /* array lth (1st dim, arrays only) */
+ char *s_length2, /* array lth (2nd dim, [n]x[m] arrays only) */
+ char *value /* initial value or NULL */
+);
+void sync_stmt(char *name, char *subscript, char *ef_name);
+void syncq_stmt(char *name, char *subscript, char *ef_name, char *maxQueueSize);
+void defn_c_stmt(
+ Expr *c_list /* ptr to C code */
+);
+void option_stmt(
+ char *option, /* "a", "r", ... */
+ int value /* TRUE means +, FALSE means - */
+);
+int entry_code(Expr *ep);
+int exit_code(Expr *ep);
+void pp_code(char *line, char *fname);
+void global_c_stmt(
+ Expr *c_list /* ptr to C code */
+);
+
+#endif /*INCLparsedefsh*/
diff -rN -u old-branch-2-0/src/snc/snc.y new-branch-2-0/src/snc/snc.y
--- old-branch-2-0/src/snc/snc.y 2022-09-26 04:11:50.681832038 +0200
+++ new-branch-2-0/src/snc/snc.y 2022-09-26 04:11:50.685832134 +0200
@@ -47,6 +47,7 @@
#include <stdio.h>
#include <ctype.h>
#include "parse.h"
+#include "parsedefs.h"
#ifndef TRUE
#define TRUE 1
@@ -199,9 +200,9 @@
in escaped C code */
/* ### this is not working yet; don't use it */
: type NAME SEMI_COLON
- { $$ = expression(E_TEXT, "", "int i;", 0); }
+ { $$ = expression(E_TEXT, "", (Expr *)"int i;", 0); }
| type NAME EQUAL NUMBER SEMI_COLON
- { $$ = expression(E_TEXT, "", "int i=0;", 0); }
+ { $$ = expression(E_TEXT, "", (Expr *)"int i=0;", 0); }
;
type /* types for variables defined in SNL */
@@ -282,9 +283,9 @@
state_option /* An option for a state */
: OPTION PLUS NAME SEMI_COLON
- { $$ = expression(E_OPTION,"stateoption",$3,"+"); }
+ { $$ = expression(E_OPTION,"stateoption",(Expr *)$3,(Expr *)"+"); }
| OPTION MINUS NAME SEMI_COLON
- { $$ = expression(E_OPTION,"stateoption",$3,"-"); }
+ { $$ = expression(E_OPTION,"stateoption",(Expr *)$3,(Expr *)"-"); }
| error { snc_err("state option specifier"); }
;
@@ -429,7 +430,7 @@
| else_stmt { $$ = $1; }
| while_stmt { $$ = $1; }
| for_stmt { $$ = $1; }
-| C_STMT { $$ = expression(E_TEXT, "", $1, 0); }
+| C_STMT { $$ = expression(E_TEXT, "", (Expr *)$1, 0); }
| pp_code { $$ = 0; }
/* | error { snc_err("action statement"); } */
;
@@ -453,10 +454,9 @@
;
pp_code /* pre-processor code (e.g. # 1 "test.st") */
-: PP_SYMBOL NUMBER STRING CR { pp_code($2, $3, ""); }
-| PP_SYMBOL NUMBER CR { pp_code($2, 0, ""); }
-| PP_SYMBOL NUMBER STRING NUMBER CR { pp_code($2, $3, $4); }
-| PP_SYMBOL STRING CR { /* Silently consume #pragma lines */ }
+: PP_SYMBOL NUMBER STRING CR { pp_code($2, $3); }
+| PP_SYMBOL NUMBER CR { pp_code($2, 0); }
+| PP_SYMBOL STRING CR { /* Silently consume #pragma lines */ }
;
pp_codes /* one or more pp_code */
@@ -469,8 +469,8 @@
;
escaped_c_list
-: C_STMT { $$ = expression(E_TEXT, "", $1, 0); }
-| escaped_c_list C_STMT { $$ = link_expr($1, expression(E_TEXT, "", $2, 0)); }
+: C_STMT { $$ = expression(E_TEXT, "", (Expr *)$1, 0); }
+| escaped_c_list C_STMT { $$ = link_expr($1, expression(E_TEXT, "", (Expr *)$2, 0)); }
;
%%
#include "snc_lex.c"
diff -rN -u old-branch-2-0/src/snc/snc_lex.l new-branch-2-0/src/snc/snc_lex.l
--- old-branch-2-0/src/snc/snc_lex.l 2022-09-26 04:11:50.685832134 +0200
+++ new-branch-2-0/src/snc/snc_lex.l 2022-09-26 04:11:50.685832134 +0200
@@ -39,6 +39,7 @@
*/
#include <string.h>
+#include <unistd.h>
#ifndef TRUE
#define TRUE 1
diff -rN -u old-branch-2-0/src/snc/snc_main.c new-branch-2-0/src/snc/snc_main.c
--- old-branch-2-0/src/snc/snc_main.c 2022-09-26 04:11:50.685832134 +0200
+++ new-branch-2-0/src/snc/snc_main.c 2022-09-26 04:11:50.685832134 +0200
@@ -333,8 +333,7 @@
*
* NOTES:
*-*************************************************************************/
-void yyerror(err)
-char *err;
+void yyerror(char *err)
{
fprintf(stderr, "%s: line no. %d (%s)\n", err, line_num, src_file);
return;
patch 7c9990256cc3d6cc2611a9363af2d96878882101
Author: ben.franksen <ben.franksen@online.de>
Date: Mon Mar 1 22:37:20 CET 2010
* ansificated compiler source