Commit 998de50e authored by dickelbeck's avatar dickelbeck

lexer tweaks, more token definitions

parent babc73e7
...@@ -242,6 +242,7 @@ const static KEYWORD tokens[] = { ...@@ -242,6 +242,7 @@ const static KEYWORD tokens[] = {
TOKDEF(negative_diagonal), TOKDEF(negative_diagonal),
TOKDEF(net), TOKDEF(net),
TOKDEF(net_number), TOKDEF(net_number),
TOKDEF(net_out),
TOKDEF(net_pin_changes), TOKDEF(net_pin_changes),
TOKDEF(nets), TOKDEF(nets),
TOKDEF(network), TOKDEF(network),
...@@ -673,52 +674,62 @@ L_read: ...@@ -673,52 +674,62 @@ L_read:
} }
curTok = T_QUOTE_DEF; curTok = T_QUOTE_DEF;
goto exit;
} }
else if( *cur == '(' ) if( *cur == '(' )
{ {
curText.clear(); curText.clear();
curText += *cur; curText += *cur;
curTok = T_LEFT; curTok = T_LEFT;
head = cur+1; head = cur+1;
goto exit;
} }
else if( *cur == ')' ) if( *cur == ')' )
{ {
curText.clear(); curText.clear();
curText += *cur; curText += *cur;
curTok = T_RIGHT; curTok = T_RIGHT;
head = cur+1; head = cur+1;
goto exit;
} }
/* get the dash out of a <pin_reference> which is embedded for example /* get the dash out of a <pin_reference> which is embedded for example
like: U2-14 or "U2"-"14" like: U2-14 or "U2"-"14"
This is detectable by a non-space immediately preceeding the dash. This is detectable by a non-space immediately preceeding the dash.
*/ */
else if( *cur == '-' && cur>start && !isspace( cur[-1] ) ) if( *cur == '-' && cur>start && !isspace( cur[-1] ) )
{ {
head = cur+1; head = cur+1;
curText.clear(); curText.clear();
curText += '-'; curText += '-';
curTok = T_DASH; curTok = T_DASH;
goto exit;
} }
// handle T_NUMBER // handle T_NUMBER
else if( strchr( "+-.0123456789", *cur ) ) if( strchr( "+-.0123456789", *cur ) )
{ {
head = cur+1; head = cur+1;
while( head<limit && strchr( ".0123456789", *head ) ) while( head<limit && strchr( ".0123456789", *head ) )
++head; ++head;
if( (head<limit && isspace(*head)) || *head==')' || *head=='(' || head==limit )
{
curText.clear(); curText.clear();
curText.append( cur, head ); curText.append( cur, head );
curTok = T_NUMBER; curTok = T_NUMBER;
goto exit;
}
// else it was something like +5V, reset head back
} }
// a quoted string // a quoted string
else if( *cur == stringDelimiter ) if( *cur == stringDelimiter )
{ {
++cur; // skip over the leading delimiter: ",', or $ ++cur; // skip over the leading delimiter: ",', or $
...@@ -739,11 +750,11 @@ L_read: ...@@ -739,11 +750,11 @@ L_read:
++head; // skip over the trailing delimiter ++head; // skip over the trailing delimiter
curTok = T_STRING; curTok = T_STRING;
goto exit;
} }
// a token we hope to find in the tokens[] array. If not, then // a token we hope to find in the tokens[] array. If not, then
// call it a T_SYMBOL. // call it a T_SYMBOL.
else
{ {
head = cur+1; head = cur+1;
while( head<limit && !isspace( *head ) && *head!=')' && *head!='(' ) while( head<limit && !isspace( *head ) && *head!=')' && *head!='(' )
...@@ -757,16 +768,8 @@ L_read: ...@@ -757,16 +768,8 @@ L_read:
if( found != -1 ) if( found != -1 )
curTok = (DSN_T) found; curTok = (DSN_T) found;
else // unrecogized token else // unrecogized token, call it a symbol
{
curTok = T_SYMBOL; curTok = T_SYMBOL;
/*
wxString errTxt( CONV_FROM_UTF8( curText.c_str() ) );
errTxt << wxT(" ") << _("is an unrecognized token");
ThrowIOError( errTxt, cur-start+1 );
*/
}
} }
} }
...@@ -776,6 +779,8 @@ exit: // single point of exit ...@@ -776,6 +779,8 @@ exit: // single point of exit
next = head; next = head;
// printf("tok:\"%s\"\n", curText.c_str() );
return curTok; return curTok;
} }
......
...@@ -242,6 +242,7 @@ enum DSN_T { ...@@ -242,6 +242,7 @@ enum DSN_T {
T_negative_diagonal, T_negative_diagonal,
T_net, T_net,
T_net_number, T_net_number,
T_net_out,
T_net_pin_changes, T_net_pin_changes,
T_nets, T_nets,
T_network, T_network,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment