Corrected the verilog parser's behavior with respect to string
definitions: Now correctly parses everything from the definition name to the end of line as the definition value. Also: The search for definitions in the body of the text does not reject non-alphanumerics "_" and "$" in the definition name, without which definition names containing those characters will go unrecongized. Have not yet extended this to multi-line definition values.
This commit is contained in:
parent
cca0e4b3f3
commit
07c493c796
|
|
@ -329,7 +329,7 @@ int GetNextLineNoNewline(char *delimiter)
|
||||||
for (s = line; *s != '\0'; s++) {
|
for (s = line; *s != '\0'; s++) {
|
||||||
if (*s == '`') {
|
if (*s == '`') {
|
||||||
w = s + 1;
|
w = s + 1;
|
||||||
while (isalnum(*w)) w++;
|
while (isalnum(*w) || (*w == '_') || (*w == '$')) w++;
|
||||||
e = *w;
|
e = *w;
|
||||||
*w = '\0';
|
*w = '\0';
|
||||||
kl = (struct property *)HashLookup(s + 1, definitions);
|
kl = (struct property *)HashLookup(s + 1, definitions);
|
||||||
|
|
@ -365,7 +365,7 @@ int GetNextLineNoNewline(char *delimiter)
|
||||||
for (s = line; *s != '\0'; s++) {
|
for (s = line; *s != '\0'; s++) {
|
||||||
if (*s == '`') {
|
if (*s == '`') {
|
||||||
w = s + 1;
|
w = s + 1;
|
||||||
while (isalnum(*w)) w++;
|
while (isalnum(*w) || (*w == '_') || (*w == '$')) w++;
|
||||||
e = *w;
|
e = *w;
|
||||||
*w = '\0';
|
*w = '\0';
|
||||||
kl = (struct property *)HashLookup(s + 1, definitions);
|
kl = (struct property *)HashLookup(s + 1, definitions);
|
||||||
|
|
@ -496,6 +496,21 @@ void GetNextLine(char *delimiter)
|
||||||
} while (nexttok == NULL);
|
} while (nexttok == NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*----------------------------------------------------------------------*/
|
||||||
|
/* Return a pointer to the line at the position of nexttok */
|
||||||
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
||||||
|
char *GetLineAtTok()
|
||||||
|
{
|
||||||
|
char *lpos;
|
||||||
|
|
||||||
|
if (nexttok == NULL) return NULL;
|
||||||
|
if (line == NULL) return NULL;
|
||||||
|
|
||||||
|
lpos = strstr(line, nexttok);
|
||||||
|
return lpos;
|
||||||
|
}
|
||||||
|
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
/* if nexttok is already NULL, force scanner to read new line */
|
/* if nexttok is already NULL, force scanner to read new line */
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
|
|
||||||
|
|
@ -31,6 +31,7 @@ extern struct hashdict *definitions;
|
||||||
extern char *nexttok;
|
extern char *nexttok;
|
||||||
#define SKIPTO(a) do {SkipTok(NULL);} while (!match(nexttok,a))
|
#define SKIPTO(a) do {SkipTok(NULL);} while (!match(nexttok,a))
|
||||||
extern char *strdtok(char *pstring, char *delim1, char *delim2);
|
extern char *strdtok(char *pstring, char *delim1, char *delim2);
|
||||||
|
extern char *GetLineAtTok();
|
||||||
extern void SkipTok(char *delimiter);
|
extern void SkipTok(char *delimiter);
|
||||||
extern void SkipTokNoNewline(char *delimiter);
|
extern void SkipTokNoNewline(char *delimiter);
|
||||||
extern void SkipTokComments(char *delimiter);
|
extern void SkipTokComments(char *delimiter);
|
||||||
|
|
|
||||||
|
|
@ -1115,10 +1115,17 @@ skip_endmodule:
|
||||||
kl->slop.dval = 0.01; // One percent default
|
kl->slop.dval = 0.01; // One percent default
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
/* Treat the parameter as a string */
|
char *toks;
|
||||||
|
|
||||||
|
/* Treat the parameter as a string; BUT pull everything to */
|
||||||
|
/* EOL, not just the current token. */
|
||||||
|
toks = GetLineAtTok();
|
||||||
|
|
||||||
kl->type = PROP_STRING;
|
kl->type = PROP_STRING;
|
||||||
kl->pdefault.string = strsave(nexttok);
|
kl->pdefault.string = strsave(toks);
|
||||||
kl->slop.dval = 0.0;
|
kl->slop.dval = 0.0;
|
||||||
|
|
||||||
|
SkipNewLine(VLOG_DELIMITERS);
|
||||||
}
|
}
|
||||||
if (kl) HashPtrInstall(kl->key, kl, &verilogdefs);
|
if (kl) HashPtrInstall(kl->key, kl, &verilogdefs);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue