clipboard and DSNLEXER testing via target dsntest
This commit is contained in:
parent
f1f11cf66d
commit
aba543cb54
21
TODO.txt
21
TODO.txt
|
@ -25,6 +25,24 @@ Common
|
||||||
* Integer/long/double input boxes should handle comma and dot separated values,
|
* Integer/long/double input boxes should handle comma and dot separated values,
|
||||||
not only comma.
|
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:
|
Wayne:
|
||||||
C1) Fix mouse wheel scrolling (ctrl + Mouse wheel) and (Shift + mouse wheel)
|
C1) Fix mouse wheel scrolling (ctrl + Mouse wheel) and (Shift + mouse wheel)
|
||||||
to move more than a single scroll increment.
|
to move more than a single scroll increment.
|
||||||
|
@ -55,6 +73,9 @@ GerbView
|
||||||
* Switch to use ZONE instead of SEGZONE for polygons.
|
* Switch to use ZONE instead of SEGZONE for polygons.
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
PCBNew
|
PCBNew
|
||||||
------
|
------
|
||||||
|
|
||||||
|
|
|
@ -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
|
class DSNTEST : public wxApp
|
||||||
{
|
{
|
||||||
|
|
||||||
|
DSNLEXER* lexer;
|
||||||
|
int nestLevel;
|
||||||
|
|
||||||
|
void recursion() throw( IOError );
|
||||||
|
|
||||||
|
void indent()
|
||||||
|
{
|
||||||
|
const int NESTWIDTH = 2;
|
||||||
|
|
||||||
|
printf("\n");
|
||||||
|
for( int i=0; i<nestLevel; ++i )
|
||||||
|
printf( "%*c", NESTWIDTH, ' ' );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
|
DSNTEST() :
|
||||||
|
lexer(0),
|
||||||
|
nestLevel(0)
|
||||||
|
{}
|
||||||
|
|
||||||
|
~DSNTEST()
|
||||||
|
{
|
||||||
|
delete lexer;
|
||||||
|
}
|
||||||
|
|
||||||
virtual bool OnInit();
|
virtual bool OnInit();
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1290,7 +1324,7 @@ bool DSNTEST::OnInit()
|
||||||
// this won't compile without a token table.
|
// this won't compile without a token table.
|
||||||
DSNLEXER lexer( fp, filename, keywords, DIM(keywords) );
|
DSNLEXER lexer( fp, filename, keywords, DIM(keywords) );
|
||||||
|
|
||||||
#else
|
#else // clipboard based line reader
|
||||||
|
|
||||||
if( !wxTheClipboard->Open() )
|
if( !wxTheClipboard->Open() )
|
||||||
{
|
{
|
||||||
|
@ -1298,36 +1332,86 @@ bool DSNTEST::OnInit()
|
||||||
exit( 1 );
|
exit( 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
wxTextDataObject dataObj;
|
||||||
if( wxTheClipboard->IsSupported( wxDF_TEXT ) )
|
|
||||||
|
if( !wxTheClipboard->GetData( dataObj ) )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "nothing of interest on clipboard\n" );
|
fprintf( stderr, "nothing of interest on clipboard\n" );
|
||||||
exit( 2 );
|
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; fmt<formatCount; ++fmt )
|
||||||
|
{
|
||||||
|
fprintf( stderr, "format:%d\n", formats[fmt].GetType() );
|
||||||
|
// @todo: what are these formats in terms of enum strings, and how
|
||||||
|
// do they vary across platforms. I am seeing
|
||||||
|
// on linux: 2 formats, 13 and 1
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
lexer = new DSNLEXER( std::string( CONV_TO_UTF8( dataObj.GetText() ) ),
|
||||||
keywords, DIM(keywords) );
|
keywords, DIM(keywords) );
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
// read the stream via the lexer, and use recursion to establish a nesting
|
||||||
|
// level and some output.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
int tok;
|
int tok;
|
||||||
while( (tok = lexer.NextTok()) != DSN_EOF )
|
while( (tok = lexer->NextTok()) != DSN_EOF )
|
||||||
{
|
{
|
||||||
printf( "%-3d %s\n", tok, lexer.CurText() );
|
if( tok == DSN_LEFT )
|
||||||
|
{
|
||||||
|
recursion();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
printf( " %s", lexer->CurText() );
|
||||||
}
|
}
|
||||||
|
printf("\n");
|
||||||
}
|
}
|
||||||
catch( IOError ioe )
|
catch( IOError ioe )
|
||||||
{
|
{
|
||||||
printf( "%s\n", (const char*) ioe.errorText.mb_str() );
|
fprintf( stderr, "%s\n", CONV_TO_UTF8( ioe.errorText ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
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
|
#endif
|
||||||
|
|
Loading…
Reference in New Issue