Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
K
kicad-source-mirror
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Commits
Open sidebar
Elphel
kicad-source-mirror
Commits
aba543cb
Commit
aba543cb
authored
Mar 08, 2010
by
dickelbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
clipboard and DSNLEXER testing via target dsntest
parent
f1f11cf6
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
116 additions
and
11 deletions
+116
-11
TODO.txt
TODO.txt
+21
-0
dsnlexer.cpp
common/dsnlexer.cpp
+95
-11
No files found.
TODO.txt
View file @
aba543cb
...
...
@@ -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
------
...
...
common/dsnlexer.cpp
View file @
aba543cb
...
...
@@ -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
;
i
<
nestLevel
;
++
i
)
printf
(
"%*c"
,
NESTWIDTH
,
' '
);
}
public
:
DSNTEST
()
:
lexer
(
0
),
nestLevel
(
0
)
{}
~
DSNTEST
()
{
delete
lexer
;
}
virtual
bool
OnInit
();
};
...
...
@@ -1290,7 +1324,7 @@ bool DSNTEST::OnInit()
// this won't compile without a token table.
DSNLEXER lexer( fp, filename, keywords, DIM(keywords) );
#else
#else
// clipboard based line reader
if
(
!
wxTheClipboard
->
Open
()
)
{
...
...
@@ -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
();
fprintf
(
stderr
,
"formatCount:%d
\n
"
,
formatCount
);
wxDataFormat
*
formats
=
new
wxDataFormat
[
formatCount
];
DSNLEXER
lexer
(
std
::
string
(
CONV_TO_UTF8
(
dataObj
.
GetText
()
)
),
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
)
);
#endif
// read the stream via the lexer, and use recursion to establish a nesting
// level and some output.
try
{
int
tok
;
while
(
(
tok
=
lexer
.
NextTok
())
!=
DSN_EOF
)
int
tok
;
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
)
{
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
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment