upgrade INPgetTree()

This commit is contained in:
rlar 2012-02-11 08:17:12 +00:00
parent 37940c9133
commit 6ea91d2834
3 changed files with 45 additions and 7 deletions

View File

@ -1,3 +1,10 @@
2012-02-11 Robert Larice
* src/spicelib/parser/inpptree-parser.y ,
* src/spicelib/parser/inpptree.c :
upgrade INPgetTree()
this parser did parse the *whole* line,
now it parses as much as it can, and passes the rest back in arg `line'
2012-02-10 Holger Vogt / (Robert Larice)
* src/frontend/cpitf.c :
search for tclspinit in `cwd' as well

View File

@ -1,12 +1,34 @@
%{
/*
* (compile (concat "bison " buffer-file-name))
*/
#include <stdio.h>
#include <stdlib.h>
struct PTltype {
char *start, *stop;
};
# define YYLTYPE struct PTltype
# define YYLLOC_DEFAULT(Current, Rhs, N) \
do \
if (N) { \
(Current).start = YYRHSLOC(Rhs, 1).start; \
(Current).stop = YYRHSLOC(Rhs, N).stop; \
} else { \
(Current).start = (Current).stop = YYRHSLOC(Rhs, 0).stop; \
} \
while (0)
#include "inpptree-parser.h"
extern int PTlex (YYSTYPE *lvalp, char **line);
extern int PTlex (YYSTYPE *lvalp, struct PTltype *llocp, char **line);
extern int PTdebug;
static void PTerror (char **line, struct INPparseNode **retval, void *ckt, char const *);
static void PTerror (YYLTYPE *locp, char **line, struct INPparseNode **retval, void *ckt, char const *);
#if defined (_MSC_VER)
# define __func__ __FUNCTION__ /* __func__ is C99, but MSC can't */
@ -57,13 +79,18 @@
%initial-action /* initialize yylval */
{
$$.num = 0.0;
yylloc.start = yylloc.stop = NULL;
};
%%
expression:
exp { *retval = $1; }
;
expression: exp
{
*retval = $1;
*line = @1.stop;
YYACCEPT;
}
exp:
TOK_NUM { $$ = mknnode($1); }
@ -116,8 +143,9 @@ nonempty_arglist:
/* Called by yyparse on error. */
static void
PTerror (char **line, struct INPparseNode **retval, void *ckt, char const *s)
PTerror (YYLTYPE *locp, char **line, struct INPparseNode **retval, void *ckt, char const *s)
{
NG_IGNORE(locp);
NG_IGNORE(line);
NG_IGNORE(retval);
NG_IGNORE(ckt);

View File

@ -1028,7 +1028,7 @@ static INPparseNode *mksnode(const char *string, void *ckt)
/* The lexical analysis routine. */
int PTlex (YYSTYPE *lvalp, char **line)
int PTlex (YYSTYPE *lvalp, struct PTltype *llocp, char **line)
{
double td;
int err;
@ -1044,6 +1044,8 @@ int PTlex (YYSTYPE *lvalp, char **line)
while ((*sbuf == ' ') || (*sbuf == '\t'))
sbuf++;
llocp->start = sbuf;
switch (*sbuf) {
case '\0':
token = 0;
@ -1210,6 +1212,7 @@ int PTlex (YYSTYPE *lvalp, char **line)
// printf("PTlexer: token = %d, type = %d, left = '%s'\n",
// el.token, el.type, sbuf); */
#endif
llocp->stop = sbuf;
return (token);
}