From 8af36ef451a93715881db5692056503bceeb61c8 Mon Sep 17 00:00:00 2001 From: rliebscher Date: Sun, 4 Nov 2012 17:18:59 +0000 Subject: [PATCH] * lexer.l,config_gram.y,config.[hc]: changed reading of numbers to integers except of default_bitclock which is the only real number. No signs are allowed as negative values do not make sense for current config values. * buspirate.c: include own header file buspirate.h * doc/.cvsignore: add programmers.texi to ignore list git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@1105 81a1dc3b-b13d-400b-aceb-764788c761c2 --- ChangeLog | 9 +++++++++ avrdude.conf.in | 2 +- buspirate.c | 1 + config.c | 36 +++++++++++++++++++++++++++--------- config.h | 11 ++++++++--- config_gram.y | 16 ++++++++++++++-- doc/.cvsignore | 1 + lexer.l | 9 ++++++--- 8 files changed, 67 insertions(+), 18 deletions(-) diff --git a/ChangeLog b/ChangeLog index 48696e6d..75e24259 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2012-11-04 Rene Liebscher + + * lexer.l,config_gram.y,config.[hc]: changed reading of numbers to integers + except of default_bitclock which is the only real number. + No signs are allowed as negative values do not make sense for current + config values. + * buspirate.c: include own header file buspirate.h + * doc/.cvsignore: add programmers.texi to ignore list + 2012-09-06 Joerg Wunsch * doc/Makefile.am: add EXTRA_DIST, replace $(srcdir) by diff --git a/avrdude.conf.in b/avrdude.conf.in index 910d5899..4335b63e 100644 --- a/avrdude.conf.in +++ b/avrdude.conf.in @@ -326,7 +326,7 @@ # default_parallel = "@DEFAULT_PAR_PORT@"; default_serial = "@DEFAULT_SER_PORT@"; -# default_bitclock = 2.5 +# default_bitclock = 2.5; # diff --git a/buspirate.c b/buspirate.c index cf12d76c..2c50b15b 100644 --- a/buspirate.c +++ b/buspirate.c @@ -50,6 +50,7 @@ #include "avr.h" #include "pgm.h" #include "serial.h" +#include "buspirate.h" /* ====== Private data structure ====== */ /* CS and AUX pin bitmasks in diff --git a/config.c b/config.c index 7da6531c..3472dfc8 100644 --- a/config.c +++ b/config.c @@ -122,7 +122,7 @@ void free_token(TOKEN * tkn) tkn->value.string = NULL; break; } - + free(tkn); } } @@ -149,15 +149,29 @@ TOKEN * number(char * text) tkn = new_token(TKN_NUMBER); tkn->value.type = V_NUM; - tkn->value.number = atof(text); + tkn->value.number = atoi(text); #if DEBUG - fprintf(stderr, "NUMBER(%g)\n", tkn->value.number); + fprintf(stderr, "NUMBER(%d)\n", tkn->value.number); #endif return tkn; } +TOKEN * number_real(char * text) +{ + struct token_t * tkn; + + tkn = new_token(TKN_NUMBER); + tkn->value.type = V_NUM_REAL; + tkn->value.number_real = atof(text); + +#if DEBUG + fprintf(stderr, "NUMBER(%g)\n", tkn->value.number_real); +#endif + + return tkn; +} TOKEN * hexnumber(char * text) { @@ -223,16 +237,20 @@ void print_token(TOKEN * tkn) fprintf(stderr, "token = %d = ", tkn->primary); switch (tkn->value.type) { - case V_NUM: - fprintf(stderr, "NUMBER, value=%g", tkn->value.number); + case V_NUM: + fprintf(stderr, "NUMBER, value=%d", tkn->value.number); break; - case V_STR: - fprintf(stderr, "STRING, value=%s", tkn->value.string); + case V_NUM_REAL: + fprintf(stderr, "NUMBER, value=%g", tkn->value.number_real); break; - default: - fprintf(stderr, ""); + case V_STR: + fprintf(stderr, "STRING, value=%s", tkn->value.string); + break; + + default: + fprintf(stderr, ""); break; } diff --git a/config.h b/config.h index 13566413..09d73cbb 100644 --- a/config.h +++ b/config.h @@ -29,11 +29,14 @@ #define MAX_STR_CONST 1024 -enum { V_NONE, V_NUM, V_STR }; +enum { V_NONE, V_NUM, V_NUM_REAL, V_STR }; typedef struct value_t { int type; - double number; - char * string; + /*union { TODO: use an anonymous union here ? */ + int number; + double number_real; + char * string; + /*};*/ } VALUE; @@ -91,6 +94,8 @@ void free_tokens(int n, ...); TOKEN * number(char * text); +TOKEN * number_real(char * text); + TOKEN * hexnumber(char * text); TOKEN * string(char * text); diff --git a/config_gram.y b/config_gram.y index d4fa3511..8145ff83 100644 --- a/config_gram.y +++ b/config_gram.y @@ -200,12 +200,24 @@ static int pin_name; %token TKN_SEMI %token TKN_TILDE %token TKN_NUMBER +%token TKN_NUMBER_REAL %token TKN_STRING %start configuration %% +number_real : + TKN_NUMBER { + $$ = $1; + /* convert value to real */ + $$->value.number_real = $$->value.number; + $$->value.type = V_NUM_REAL; + } | + TKN_NUMBER_REAL { + $$ = $1; + } + configuration : /* empty */ | config ; @@ -239,8 +251,8 @@ def : free_token($3); } | - K_DEFAULT_BITCLOCK TKN_EQUAL TKN_NUMBER TKN_SEMI { - default_bitclock = $3->value.number; + K_DEFAULT_BITCLOCK TKN_EQUAL number_real TKN_SEMI { + default_bitclock = $3->value.number_real; free_token($3); } ; diff --git a/doc/.cvsignore b/doc/.cvsignore index 99f4eabd..afe95fe9 100644 --- a/doc/.cvsignore +++ b/doc/.cvsignore @@ -22,3 +22,4 @@ texinfo.tex version.texi programmer_types.texi parts.texi +programmers.texi diff --git a/lexer.l b/lexer.l index 255ae941..06440969 100644 --- a/lexer.l +++ b/lexer.l @@ -57,9 +57,12 @@ SIGN [+-] %% -{SIGN}*{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; } -{SIGN}*{DIGIT}+"."{DIGIT}* { yylval = number(yytext); return TKN_NUMBER; } -{SIGN}*"."{DIGIT}* { yylval = number(yytext); return TKN_NUMBER; } +#{SIGN}*{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; } +#{SIGN}*{DIGIT}+"."{DIGIT}* { yylval = number_real(yytext); return TKN_NUMBER_REAL; } +#{SIGN}*"."{DIGIT}* { yylval = number_real(yytext); return TKN_NUMBER_REAL; } +{DIGIT}+ { yylval = number(yytext); return TKN_NUMBER; } +{DIGIT}+"."{DIGIT}* { yylval = number_real(yytext); return TKN_NUMBER_REAL; } +"."{DIGIT}+ { yylval = number_real(yytext); return TKN_NUMBER_REAL; } "\"" { string_buf_ptr = string_buf; BEGIN(strng); }