From 1154e7bb834da75b81e1b4cea0f42850c34b7c58 Mon Sep 17 00:00:00 2001 From: Koen De Vleeschauwer Date: Wed, 26 Jul 2017 04:30:46 -0400 Subject: [PATCH] device VAL= more lenient --- configure.ac | 2 +- lib/scan.ll | 48 ++++++++++++++++++++++++++++-------------------- 2 files changed, 29 insertions(+), 21 deletions(-) diff --git a/configure.ac b/configure.ac index e3eeb05..c441dbc 100644 --- a/configure.ac +++ b/configure.ac @@ -1,5 +1,5 @@ # Process this file with autoconf to produce a configure script. -AC_INIT([hyp2mat], [0.0.16]) +AC_INIT([hyp2mat], [0.0.17]) AC_CONFIG_AUX_DIR([config]) AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_SRCDIR([src/hyp2mat.cc]) diff --git a/lib/scan.ll b/lib/scan.ll index eb6981c..edef049 100644 --- a/lib/scan.ll +++ b/lib/scan.ll @@ -117,7 +117,7 @@ STRING [^ \t\v\f\r\n\{\}\(\)=\"]+|"("[[:alnum:]]+")" QUOTED_STRING \"([^\"\n]|\"\")*\" /* an unquoted string with spaces */ -CHARS_AND_SPACES [^\t\v\f\r\n\{\}\(\)=\"\,]+ +CHARS_AND_SPACES [^\t\v\f\r\n\{\}\(\)=\"]+ /* all variables used in assignments */ VARIABLE ("A"|"A1"|"A2"|"BR"|"C"|"C\?"|"CO\?"|"D"|"ER"|"F"|"ID"|"L"|"L1"|"L2"|"LPS"|"LT"|"M"|"N"|"NAME"|"P"|"PKG"|"PR\?"|"PS"|"R"|"REF"|"S"|"SX"|"SY"|"S1"|"S1X"|"S1Y"|"S2"|"S2X"|"S2Y"|"T"|"TC"|"USE_DIE_FOR_METAL"|"V"|"V\?"|"VAL"|"W"|"X"|"X1"|"X2"|"XC"|"Y"|"Y1"|"Y2"|"YC"|"Z"|"ZL"|"ZLEN"|"ZW") @@ -251,7 +251,7 @@ EMPTY_STRING ({WS}{VARIABLE}"="|")"|"}") "USE_DIE_FOR_METAL"/{LHS} {return USE_DIE_FOR_METAL;} "V"/{LHS} {BEGIN STATE_STRING; return V;} "V?"/{LHS} {return V_QM;} -"VAL"/{LHS} {return VAL;} +"VAL"/{LHS} {BEGIN STATE_STRING; return VAL;} "W"/{LHS} {return W;} "X"/{LHS} {return X;} "X1"/{LHS} {return X1;} @@ -319,22 +319,31 @@ EMPTY_STRING ({WS}{VARIABLE}"="|")"|"}") {EMPTY_STRING} { yyless(0); BEGIN INITIAL; yylval.strval = strdup(""); return STRING; } /* emit empty string and reprocess */ {STRING_W_SPACES} { - char *s = strdup(yytext); - - BEGIN INITIAL; - - /* strip final ' VAR=' */ - if ((strlen(s) != 0) && (s[strlen(s)-1] == '=')) { - char* space = strrchr(s, ' '); - /* strip trailing spaces */ - if (space != NULL) - while ((space >= s) && (*space == ' ')) *space-- = '\0'; - yyless(strlen(s)); - } - - yylval.strval = s; - - return STRING; + /* + * Commas are not allowed in strings in the padstack section unless the string is enclosed in double quotes ("). + */ + + if ((section == PADSTACK) && strchr(yytext, ',')) + REJECT + else + { + char *s = strdup(yytext); + + BEGIN INITIAL; + + /* strip final ' VAR=' */ + if ((strlen(s) != 0) && (s[strlen(s)-1] == '=')) { + char* space = strrchr(s, ' '); + /* strip trailing spaces */ + if (space != NULL) + while ((space >= s) && (*space == ' ')) *space-- = '\0'; + yyless(strlen(s)); + } + + yylval.strval = s; + + return STRING; + } } } @@ -356,8 +365,7 @@ EMPTY_STRING ({WS}{VARIABLE}"="|")"|"}") /* string */ {STRING} { /* - * Commas are not allowed in strings in the padstack section - * unless the string is enclosed in double quotes ("). + * Commas are not allowed in strings in the padstack section unless the string is enclosed in double quotes ("). */ if ((section == PADSTACK) && strchr(yytext, ','))