Commit 945c14d4 authored by dickelbeck's avatar dickelbeck

more specctra dsn work

parent 36f6103b
...@@ -588,7 +588,7 @@ DSN_T LEXER::NextTok() throw (IOError) ...@@ -588,7 +588,7 @@ DSN_T LEXER::NextTok() throw (IOError)
char* cur = next; char* cur = next;
char* head = cur; char* head = cur;
lastTok = curTok; prevTok = curTok;
if( curTok != T_EOF ) if( curTok != T_EOF )
{ {
...@@ -613,7 +613,7 @@ L_read: ...@@ -613,7 +613,7 @@ L_read:
goto L_read; goto L_read;
// switching the string_quote character // switching the string_quote character
if( lastTok == T_string_quote ) if( prevTok == T_string_quote )
{ {
static const wxString errtxt( _("String delimiter must be a single character of ', \", or $")); static const wxString errtxt( _("String delimiter must be a single character of ', \", or $"));
......
...@@ -527,7 +527,7 @@ class LEXER ...@@ -527,7 +527,7 @@ class LEXER
bool space_in_quoted_tokens; ///< blank spaces within quoted strings bool space_in_quoted_tokens; ///< blank spaces within quoted strings
wxString filename; wxString filename;
int lastTok; ///< curTok from previous NextTok() call. DSN_T prevTok; ///< curTok from previous NextTok() call.
int curOffset; ///< offset within current line of the current token int curOffset; ///< offset within current line of the current token
DSN_T curTok; ///< the current token obtained on last NextTok() DSN_T curTok; ///< the current token obtained on last NextTok()
...@@ -640,7 +640,6 @@ public: ...@@ -640,7 +640,6 @@ public:
return curText.c_str(); return curText.c_str();
} }
/** /**
* Function CurTok * Function CurTok
* returns whatever NextTok() returned the last time it was called. * returns whatever NextTok() returned the last time it was called.
...@@ -650,6 +649,15 @@ public: ...@@ -650,6 +649,15 @@ public:
return curTok; return curTok;
} }
/**
* Function PrevTok
* returns whatever NextTok() returned the 2nd to last time it was called.
*/
DSN_T PrevTok()
{
return prevTok;
}
/** /**
* Function CurOffset * Function CurOffset
* returns the char offset within the current line, using a 1 based index. * returns the char offset within the current line, using a 1 based index.
......
...@@ -538,23 +538,36 @@ public: ...@@ -538,23 +538,36 @@ public:
}; };
/**
* Class RULE
* holds a single rule and corresponds to <rule_descriptors>
*/
class RULE : public ELEM
{
};
/** /**
* Class RULES * Class RULES
* corresponds to the <rule_descriptor> in the specctra dsn spec. * corresponds to the <rule_descriptor> in the specctra dsn spec.
*/ */
class RULES : public ELEM class RULES : public ELEM
{ {
; friend class SPECCTRA_DB;
STRINGS rules; ///< rules are saved in std::string form.
public:
RULES( ELEM* aParent ) :
ELEM( T_rule, aParent )
{
}
~RULES()
{
}
void Save( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
{
out->Print( nestLevel, "(%s\n", LEXER::GetTokenText( Type() ) );
for( STRINGS::const_iterator i = rules.begin(); i!=rules.end(); ++i )
out->Print( nestLevel+1, "%s\n", i->c_str() );
out->Print( nestLevel, ")\n" );
}
}; };
...@@ -670,6 +683,7 @@ class STRUCTURE : public ELEM ...@@ -670,6 +683,7 @@ class STRUCTURE : public ELEM
BOUNDARY* place_boundary; BOUNDARY* place_boundary;
VIA* via; VIA* via;
CONTROL* control; CONTROL* control;
RULES* rules;
typedef boost::ptr_vector<LAYER> LAYERS; typedef boost::ptr_vector<LAYER> LAYERS;
LAYERS layers; LAYERS layers;
...@@ -684,6 +698,7 @@ public: ...@@ -684,6 +698,7 @@ public:
place_boundary = 0; place_boundary = 0;
via = 0; via = 0;
control = 0; control = 0;
rules = 0;
} }
~STRUCTURE() ~STRUCTURE()
...@@ -693,6 +708,7 @@ public: ...@@ -693,6 +708,7 @@ public:
delete place_boundary; delete place_boundary;
delete via; delete via;
delete control; delete control;
delete rules;
} }
void Save( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError ) void Save( OUTPUTFORMATTER* out, int nestLevel ) throw( IOError )
...@@ -722,6 +738,9 @@ public: ...@@ -722,6 +738,9 @@ public:
At(i)->Save( out, nestLevel+1 ); At(i)->Save( out, nestLevel+1 );
} }
if( rules )
rules->Save( out, nestLevel+1 );
out->Print( nestLevel, ")\n" ); out->Print( nestLevel, ")\n" );
} }
...@@ -910,6 +929,7 @@ class SPECCTRA_DB : public OUTPUTFORMATTER ...@@ -910,6 +929,7 @@ class SPECCTRA_DB : public OUTPUTFORMATTER
void doVIA( VIA* growth ) throw( IOError ); void doVIA( VIA* growth ) throw( IOError );
void doCONTROL( CONTROL* growth ) throw( IOError ); void doCONTROL( CONTROL* growth ) throw( IOError );
void doLAYER( LAYER* growth ) throw( IOError ); void doLAYER( LAYER* growth ) throw( IOError );
void doRULES( RULES* growth ) throw( IOError );
public: public:
...@@ -1338,6 +1358,11 @@ L_place: ...@@ -1338,6 +1358,11 @@ L_place:
growth->layers.push_back( layer ); growth->layers.push_back( layer );
doLAYER( layer ); doLAYER( layer );
break; break;
case T_rule:
growth->rules = new RULES( growth );
doRULES( growth->rules );
break;
default: default:
unexpected( lexer->CurText() ); unexpected( lexer->CurText() );
...@@ -1608,7 +1633,8 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError ) ...@@ -1608,7 +1633,8 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError )
break; break;
case T_rule: case T_rule:
// @todo growth->rules = new RULES( growth );
doRULES( growth->rules );
break; break;
case T_property: case T_property:
...@@ -1714,6 +1740,39 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError ) ...@@ -1714,6 +1740,39 @@ void SPECCTRA_DB::doLAYER( LAYER* growth ) throw( IOError )
} }
void SPECCTRA_DB::doRULES( RULES* growth ) throw( IOError )
{
std::string builder;
int bracketNesting = 1; // we already saw the opening T_LEFT
while( bracketNesting != 0 )
{
DSN_T tok = nextTok();
switch( tok )
{
case T_LEFT: ++bracketNesting; break;
case T_RIGHT: --bracketNesting; break;
default:
;
}
if( bracketNesting >= 1 )
{
if( lexer->PrevTok() != T_LEFT && tok!=T_RIGHT )
builder += ' ';
builder += lexer->CurText();
}
if( bracketNesting == 1 )
{
growth->rules.push_back( builder );
builder.clear();
}
}
}
void SPECCTRA_DB::Print( int nestLevel, const char* fmt, ... ) throw( IOError ) void SPECCTRA_DB::Print( int nestLevel, const char* fmt, ... ) throw( IOError )
{ {
va_list args; va_list args;
......
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