diff --git a/TODO.txt b/TODO.txt index c590032f40..dde7516728 100644 --- a/TODO.txt +++ b/TODO.txt @@ -25,6 +25,24 @@ Common * Integer/long/double input boxes should handle comma and dot separated values, not only comma. +C2) Write a tool to generate DSNLEXER keyword tables (and enums) as *.cpp and + *.h. Language of tool should probably be C++. As input, the tool should take + a list of whitespace separated keywords from a text file that is manually + maintained. The *.cpp file should be named based on input file name and should + include the keyword table with a global array. The *.h file be named based on + the input file name and should hold the enums and an extern array to the keyword table. + The enum table should include the core syntactical enums from dsnlexer.h as + the first negative values. See enum DSN_T { from specctra.h as example. + + Tool should verify uniqueness of keywords, enforce all lowercase, and sort. + Spaces are not allowed in keywords, but if whitespace is the delimiter for + the tool, it will be impossible to specify a keyword with whitespaces in it. + + Use tool in CMake scripts for future grammars, but remember for cross compiling, + generating and using a tool to run natively on the build machine is a bit tricky with + CMake. + + Wayne: C1) Fix mouse wheel scrolling (ctrl + Mouse wheel) and (Shift + mouse wheel) to move more than a single scroll increment. @@ -55,6 +73,9 @@ GerbView * Switch to use ZONE instead of SEGZONE for polygons. + + + PCBNew ------ diff --git a/common/dsnlexer.cpp b/common/dsnlexer.cpp index b397f538fe..e00a8b6df0 100644 --- a/common/dsnlexer.cpp +++ b/common/dsnlexer.cpp @@ -1259,9 +1259,43 @@ static const KEYWORD keywords[] = { }; +/* To run this test code, simply copy some DSN text to the clipboard, then run + the program from the command line and it will beautify the input from the + clipboard to stdout. stderr gets errors, if any. + The wxApp is involved because the clipboard is not available to a raw + int main() type program on all platforms. +*/ + + class DSNTEST : public wxApp { + + DSNLEXER* lexer; + int nestLevel; + + void recursion() throw( IOError ); + + void indent() + { + const int NESTWIDTH = 2; + + printf("\n"); + for( int i=0; iOpen() ) { @@ -1298,36 +1332,86 @@ bool DSNTEST::OnInit() exit( 1 ); } -/* - if( wxTheClipboard->IsSupported( wxDF_TEXT ) ) + wxTextDataObject dataObj; + + if( !wxTheClipboard->GetData( dataObj ) ) { fprintf( stderr, "nothing of interest on clipboard\n" ); exit( 2 ); } -*/ - wxTextDataObject dataObj; - wxTheClipboard->GetData( dataObj ); + int formatCount = dataObj.GetFormatCount(); - DSNLEXER lexer( std::string( CONV_TO_UTF8( dataObj.GetText() ) ), + fprintf( stderr, "formatCount:%d\n", formatCount ); + + wxDataFormat* formats = new wxDataFormat[formatCount]; + + dataObj.GetAllFormats( formats ); + + for( int fmt=0; fmtNextTok()) != DSN_EOF ) { - printf( "%-3d %s\n", tok, lexer.CurText() ); + if( tok == DSN_LEFT ) + { + recursion(); + } + else + printf( " %s", lexer->CurText() ); } + printf("\n"); } catch( IOError ioe ) { - printf( "%s\n", (const char*) ioe.errorText.mb_str() ); + fprintf( stderr, "%s\n", CONV_TO_UTF8( ioe.errorText ) ); } return 0; } + +void DSNTEST::recursion() throw(IOError) +{ + int tok; + const char* space = ""; + + indent(); + printf("("); + + while( (tok = lexer->NextTok()) != DSN_EOF && tok != DSN_RIGHT ) + { + if( tok == DSN_LEFT ) + { + ++nestLevel; + + recursion(); + + --nestLevel; + } + else + printf( "%s%s", space, lexer->CurText() ); + + space = " "; // only the first tok gets no leading space. + } + + printf(")"); +} + #endif