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
5dc3cf98
Commit
5dc3cf98
authored
Apr 03, 2011
by
Dick Hollenbeck
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
more free sweet work
parent
39194ef6
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
143 additions
and
129 deletions
+143
-129
eeschema_part_sexpr_format_EN.odt
new/eeschema_part_sexpr_format_EN.odt
+0
-0
make-dir-lib-source-test-data.sh
new/make-dir-lib-source-test-data.sh
+1
-1
sch_part.cpp
new/sch_part.cpp
+23
-36
sch_part.h
new/sch_part.h
+17
-4
sch_sweet_parser.cpp
new/sch_sweet_parser.cpp
+102
-88
No files found.
new/eeschema_part_sexpr_format_EN.odt
View file @
5dc3cf98
No preview for this file type
new/make-dir-lib-source-test-data.sh
View file @
5dc3cf98
...
@@ -40,7 +40,7 @@ BEZIER="
...
@@ -40,7 +40,7 @@ BEZIER="
)"
)"
TEXT
=
"
TEXT
=
"
(text
\"
This is some text
\"
(at 23 23 90.0)
(justify left bottom)(visible yes)(fill filled)
(text
(at 23 23 90.0)
\"
This is some text
\"
(justify left bottom)(visible yes)(fill filled)
(font arial (size .8 1.2))
(font arial (size .8 1.2))
)"
)"
...
...
new/sch_part.cpp
View file @
5dc3cf98
...
@@ -31,6 +31,20 @@
...
@@ -31,6 +31,20 @@
#include <macros.h>
#include <macros.h>
//#include <richio.h>
//#include <richio.h>
/**
* Function formatAt
* returns a formatted "(at X Y [ANGLE])" s-expression
*/
static
void
formatAt
(
OUTPUTFORMATTER
*
out
,
const
POINT
&
aPos
,
ANGLE
aAngle
,
int
indent
=
0
)
throw
(
IO_ERROR
)
{
out
->
Print
(
indent
,
aAngle
==
0.0
?
"(at %.6g %.6g %.6g)"
:
"(at %.6g %.6g)"
,
InternalToLogical
(
aPos
.
x
),
InternalToLogical
(
aPos
.
y
),
double
(
aAngle
)
);
}
using
namespace
SCH
;
using
namespace
SCH
;
...
@@ -40,13 +54,6 @@ PART::PART( LIB* aOwner, const STRING& aPartNameAndRev ) :
...
@@ -40,13 +54,6 @@ PART::PART( LIB* aOwner, const STRING& aPartNameAndRev ) :
partNameAndRev
(
aPartNameAndRev
),
partNameAndRev
(
aPartNameAndRev
),
extends
(
0
),
extends
(
0
),
base
(
0
)
base
(
0
)
/*
reference( this, wxT( "reference " ) ),
value( this, wxT( "value" ) ),
footprint( this, wxT( "footprint" ) ),
model( this, wxT( "model" ) ),
datasheet( this, wxT( "datasheet" ) )
*/
{
{
// Our goal is to have class LIB only instantiate what is needed, so print here
// Our goal is to have class LIB only instantiate what is needed, so print here
// what it is doing. It is the only class where PART can be instantiated.
// what it is doing. It is the only class where PART can be instantiated.
...
@@ -307,12 +314,7 @@ void TEXT_EFFECTS::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
...
@@ -307,12 +314,7 @@ void TEXT_EFFECTS::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
else
else
out
->
Print
(
indent
,
"(effects %s "
,
out
->
Quotew
(
propName
).
c_str
()
);
out
->
Print
(
indent
,
"(effects %s "
,
out
->
Quotew
(
propName
).
c_str
()
);
out
->
Print
(
0
,
"(at %.6g %.6g"
,
InternalToLogical
(
pos
.
x
),
InternalToLogical
(
pos
.
y
)
);
formatAt
(
out
,
pos
,
angle
);
if
(
angle
)
out
->
Print
(
0
,
" %.6g)"
,
double
(
angle
)
);
else
out
->
Print
(
0
,
")"
);
font
.
Format
(
out
,
0
,
ctl
|
CTL_OMIT_NL
);
font
.
Format
(
out
,
0
,
ctl
|
CTL_OMIT_NL
);
...
@@ -349,13 +351,8 @@ void PIN::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
...
@@ -349,13 +351,8 @@ void PIN::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
{
out
->
Print
(
indent
,
"(pin %s %s "
,
ShowType
(),
ShowShape
()
);
out
->
Print
(
indent
,
"(pin %s %s "
,
ShowType
(),
ShowShape
()
);
if
(
angle
)
formatAt
(
out
,
pos
,
angle
);
out
->
Print
(
0
,
"(at %.6g %.6g %.6g)"
,
InternalToLogical
(
pos
.
x
),
InternalToLogical
(
pos
.
y
),
double
(
angle
)
);
else
out
->
Print
(
0
,
"(at %.6g %.6g)"
,
InternalToLogical
(
pos
.
x
),
InternalToLogical
(
pos
.
y
)
);
out
->
Print
(
0
,
"(length %.6g)"
,
InternalToLogical
(
length
)
);
out
->
Print
(
0
,
"(length %.6g)"
,
InternalToLogical
(
length
)
);
out
->
Print
(
0
,
"(visible %s)
\n
"
,
isVisible
?
"yes"
:
"no"
);
out
->
Print
(
0
,
"(visible %s)
\n
"
,
isVisible
?
"yes"
:
"no"
);
signal
.
Format
(
out
,
"signal"
,
indent
+
1
,
0
);
signal
.
Format
(
out
,
"signal"
,
indent
+
1
,
0
);
...
@@ -386,7 +383,7 @@ void POLY_LINE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
...
@@ -386,7 +383,7 @@ void POLY_LINE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
void
POLY_LINE
::
formatContents
(
OUTPUTFORMATTER
*
out
,
int
indent
,
int
ctl
)
const
void
POLY_LINE
::
formatContents
(
OUTPUTFORMATTER
*
out
,
int
indent
,
int
ctl
)
const
throw
(
IO_ERROR
)
throw
(
IO_ERROR
)
{
{
out
->
Print
(
0
,
"(line_width %.6g)"
,
lineWidth
);
// @todo use logical units?
out
->
Print
(
0
,
"(line_width %.6g)"
,
InternalToWidth
(
lineWidth
)
);
if
(
fillType
!=
PR
::
T_none
)
if
(
fillType
!=
PR
::
T_none
)
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
...
@@ -437,7 +434,7 @@ void RECTANGLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
...
@@ -437,7 +434,7 @@ void RECTANGLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
out
->
Print
(
indent
,
"(rectangle (start %.6g %.6g)(end %.6g %.6g)(line_width %.6g)"
,
out
->
Print
(
indent
,
"(rectangle (start %.6g %.6g)(end %.6g %.6g)(line_width %.6g)"
,
InternalToLogical
(
start
.
x
),
InternalToLogical
(
start
.
y
),
InternalToLogical
(
start
.
x
),
InternalToLogical
(
start
.
y
),
InternalToLogical
(
end
.
x
),
InternalToLogical
(
end
.
y
),
InternalToLogical
(
end
.
x
),
InternalToLogical
(
end
.
y
),
lineWidth
);
InternalToWidth
(
lineWidth
)
);
if
(
fillType
!=
PR
::
T_none
)
if
(
fillType
!=
PR
::
T_none
)
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
...
@@ -456,7 +453,7 @@ void CIRCLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
...
@@ -456,7 +453,7 @@ void CIRCLE::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
out
->
Print
(
indent
,
"(circle (center %.6g %.6g)(radius %.6g)(line_width %.6g)"
,
out
->
Print
(
indent
,
"(circle (center %.6g %.6g)(radius %.6g)(line_width %.6g)"
,
InternalToLogical
(
center
.
x
),
InternalToLogical
(
center
.
y
),
InternalToLogical
(
center
.
x
),
InternalToLogical
(
center
.
y
),
InternalToLogical
(
radius
),
InternalToLogical
(
radius
),
lineWidth
);
InternalToWidth
(
lineWidth
)
);
if
(
fillType
!=
PR
::
T_none
)
if
(
fillType
!=
PR
::
T_none
)
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
...
@@ -477,7 +474,7 @@ void ARC::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
...
@@ -477,7 +474,7 @@ void ARC::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
InternalToLogical
(
radius
),
InternalToLogical
(
radius
),
InternalToLogical
(
start
.
x
),
InternalToLogical
(
start
.
y
),
InternalToLogical
(
start
.
x
),
InternalToLogical
(
start
.
y
),
InternalToLogical
(
end
.
x
),
InternalToLogical
(
end
.
y
),
InternalToLogical
(
end
.
x
),
InternalToLogical
(
end
.
y
),
lineWidth
);
InternalToWidth
(
lineWidth
)
);
if
(
fillType
!=
PR
::
T_none
)
if
(
fillType
!=
PR
::
T_none
)
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
...
@@ -491,23 +488,14 @@ void GR_TEXT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
...
@@ -491,23 +488,14 @@ void GR_TEXT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
{
{
/*
/*
(text "This is the text that gets drawn."
(text "This is the text that gets drawn."
(at X Y [ANGLE])
(at X Y [ANGLE])(justify HORIZONTAL_JUSTIFY VERTICAL_JUSTIFY)(visible YES)(fill FILL_TYPE)
# Valid horizontal justification values are center, right, and left. Valid
# vertical justification values are center, top, bottom.
(justify HORIZONTAL_JUSTIFY VERTICAL_JUSTIFY)
(font [FONT] (size HEIGHT WIDTH) [italic] [bold])
(font [FONT] (size HEIGHT WIDTH) [italic] [bold])
(visible YES)
(fill FILL_TYPE)
)
)
*/
*/
out
->
Print
(
indent
,
"(text %s
\n
"
,
out
->
Quotew
(
text
).
c_str
()
);
out
->
Print
(
indent
,
"(text %s
\n
"
,
out
->
Quotew
(
text
).
c_str
()
);
if
(
angle
)
formatAt
(
out
,
pos
,
angle
,
indent
+
1
);
out
->
Print
(
indent
+
1
,
"(at %.6g %.6g %.6g)"
,
InternalToLogical
(
pos
.
x
),
InternalToLogical
(
pos
.
y
),
double
(
angle
)
);
else
out
->
Print
(
indent
+
1
,
"(at %.6g %.6g)"
,
InternalToLogical
(
pos
.
x
),
InternalToLogical
(
pos
.
y
)
);
out
->
Print
(
0
,
"(justify %s %s)(visible %s)"
,
out
->
Print
(
0
,
"(justify %s %s)(visible %s)"
,
ShowJustify
(
hjustify
),
ShowJustify
(
vjustify
),
ShowJustify
(
hjustify
),
ShowJustify
(
vjustify
),
...
@@ -516,8 +504,7 @@ void GR_TEXT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
...
@@ -516,8 +504,7 @@ void GR_TEXT::Format( OUTPUTFORMATTER* out, int indent, int ctl ) const
if
(
fillType
!=
PR
::
T_none
)
if
(
fillType
!=
PR
::
T_none
)
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
out
->
Print
(
0
,
"(fill %s)"
,
ShowFill
(
fillType
)
);
out
->
Print
(
0
,
"
\n
"
);
font
.
Format
(
out
,
0
,
CTL_OMIT_NL
);
font
.
Format
(
out
,
indent
+
1
,
CTL_OMIT_NL
);
out
->
Print
(
0
,
")
\n
"
);
out
->
Print
(
0
,
")
\n
"
);
}
}
new/sch_part.h
View file @
5dc3cf98
...
@@ -55,6 +55,19 @@ static inline int LogicalToInternal( double aCoord )
...
@@ -55,6 +55,19 @@ static inline int LogicalToInternal( double aCoord )
return
int
(
aCoord
*
INTERNAL_PER_LOGICAL
);
return
int
(
aCoord
*
INTERNAL_PER_LOGICAL
);
}
}
static
inline
int
WidthToInternal
(
double
aWidth
)
{
// sweet line widths are a "percent of a logical unit"
return
LogicalToInternal
(
aWidth
)
/
100
;
}
static
inline
double
InternalToWidth
(
int
aWidth
)
{
// sweet line widths are a "percent of a logical unit"
return
InternalToLogical
(
aWidth
)
*
100
;
}
//-----<temporary home for PART sub objects, move after stable>------------------
//-----<temporary home for PART sub objects, move after stable>------------------
#include <wx/gdicmn.h>
#include <wx/gdicmn.h>
...
@@ -174,7 +187,7 @@ class POLY_LINE : public BASE_GRAPHIC
...
@@ -174,7 +187,7 @@ class POLY_LINE : public BASE_GRAPHIC
friend
class
SWEET_PARSER
;
friend
class
SWEET_PARSER
;
protected
:
protected
:
double
lineWidth
;
int
lineWidth
;
int
fillType
;
// T_none, T_filled, or T_transparent
int
fillType
;
// T_none, T_filled, or T_transparent
POINTS
pts
;
POINTS
pts
;
...
@@ -216,7 +229,7 @@ class RECTANGLE : public BASE_GRAPHIC
...
@@ -216,7 +229,7 @@ class RECTANGLE : public BASE_GRAPHIC
friend
class
SWEET_PARSER
;
friend
class
SWEET_PARSER
;
protected
:
protected
:
double
lineWidth
;
int
lineWidth
;
int
fillType
;
// T_none, T_filled, or T_transparent
int
fillType
;
// T_none, T_filled, or T_transparent
POINT
start
;
POINT
start
;
POINT
end
;
POINT
end
;
...
@@ -242,7 +255,7 @@ class CIRCLE : public BASE_GRAPHIC
...
@@ -242,7 +255,7 @@ class CIRCLE : public BASE_GRAPHIC
protected
:
protected
:
POINT
center
;
POINT
center
;
int
radius
;
int
radius
;
double
lineWidth
;
int
lineWidth
;
int
fillType
;
// T_none, T_filled, or T_transparent
int
fillType
;
// T_none, T_filled, or T_transparent
public
:
public
:
...
@@ -266,7 +279,7 @@ class ARC : public BASE_GRAPHIC
...
@@ -266,7 +279,7 @@ class ARC : public BASE_GRAPHIC
protected
:
protected
:
POINT
pos
;
POINT
pos
;
double
lineWidth
;
int
lineWidth
;
int
fillType
;
// T_none, T_filled, or T_transparent
int
fillType
;
// T_none, T_filled, or T_transparent
int
radius
;
int
radius
;
POINT
start
;
POINT
start
;
...
...
new/sch_sweet_parser.cpp
View file @
5dc3cf98
...
@@ -41,6 +41,11 @@ static inline int internal( const STRING& aCoord )
...
@@ -41,6 +41,11 @@ static inline int internal( const STRING& aCoord )
return
LogicalToInternal
(
strtod
(
aCoord
.
c_str
(),
NULL
)
);
return
LogicalToInternal
(
strtod
(
aCoord
.
c_str
(),
NULL
)
);
}
}
static
inline
int
fromWidth
(
const
STRING
&
aWidth
)
{
return
WidthToInternal
(
strtod
(
aWidth
.
c_str
(),
NULL
)
);
}
/**
/**
* Enum PartBit
* Enum PartBit
...
@@ -315,13 +320,14 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
...
@@ -315,13 +320,14 @@ void SWEET_PARSER::Parse( PART* me, LIB_TABLE* aTable ) throw( IO_ERROR, PARSE_E
parseKeywords
(
me
);
parseKeywords
(
me
);
break
;
break
;
/*
/*
@todo
@todo
// do we want to inherit alternates?
case T_alternates:
case T_alternates:
break;
break;
// do we want to inherit alternates?
case T_pin_merge:
case T_pin_merge:
break;
break;
...
@@ -735,8 +741,7 @@ void SWEET_PARSER::parsePolyLine( POLY_LINE* me )
...
@@ -735,8 +741,7 @@ void SWEET_PARSER::parsePolyLine( POLY_LINE* me )
if
(
sawWidth
)
if
(
sawWidth
)
Duplicate
(
tok
);
Duplicate
(
tok
);
NeedNUMBER
(
"line_width"
);
NeedNUMBER
(
"line_width"
);
// @todo Use logical units?
me
->
lineWidth
=
fromWidth
(
CurText
()
);
me
->
lineWidth
=
strtod
(
CurText
(),
NULL
);
NeedRIGHT
();
NeedRIGHT
();
sawWidth
=
true
;
sawWidth
=
true
;
break
;
break
;
...
@@ -822,15 +827,16 @@ void SWEET_PARSER::parseRectangle( RECTANGLE* me )
...
@@ -822,15 +827,16 @@ void SWEET_PARSER::parseRectangle( RECTANGLE* me )
case
T_line_width
:
case
T_line_width
:
if
(
sawWidth
)
if
(
sawWidth
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawWidth
=
true
;
NeedNUMBER
(
"line_width"
);
NeedNUMBER
(
"line_width"
);
me
->
lineWidth
=
strtod
(
CurText
(),
NULL
);
me
->
lineWidth
=
fromWidth
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawWidth
=
true
;
break
;
break
;
case
T_fill
:
case
T_fill
:
if
(
sawFill
)
if
(
sawFill
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawFill
=
true
;
tok
=
NeedSYMBOL
();
tok
=
NeedSYMBOL
();
switch
(
tok
)
switch
(
tok
)
{
{
...
@@ -843,29 +849,28 @@ void SWEET_PARSER::parseRectangle( RECTANGLE* me )
...
@@ -843,29 +849,28 @@ void SWEET_PARSER::parseRectangle( RECTANGLE* me )
Expecting
(
"none|filled|transparent"
);
Expecting
(
"none|filled|transparent"
);
}
}
NeedRIGHT
();
NeedRIGHT
();
sawFill
=
true
;
break
;
break
;
case
T_start
:
case
T_start
:
if
(
sawStart
)
if
(
sawStart
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawStart
=
true
;
NeedNUMBER
(
"x"
);
NeedNUMBER
(
"x"
);
me
->
start
.
x
=
internal
(
CurText
()
);
me
->
start
.
x
=
internal
(
CurText
()
);
NeedNUMBER
(
"y"
);
NeedNUMBER
(
"y"
);
me
->
start
.
y
=
internal
(
CurText
()
);
me
->
start
.
y
=
internal
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawStart
=
true
;
break
;
break
;
case
T_end
:
case
T_end
:
if
(
sawEnd
)
if
(
sawEnd
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawEnd
=
true
;
NeedNUMBER
(
"x"
);
NeedNUMBER
(
"x"
);
me
->
end
.
x
=
internal
(
CurText
()
);
me
->
end
.
x
=
internal
(
CurText
()
);
NeedNUMBER
(
"y"
);
NeedNUMBER
(
"y"
);
me
->
end
.
y
=
internal
(
CurText
()
);
me
->
end
.
y
=
internal
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawEnd
=
true
;
break
;
break
;
default
:
default
:
...
@@ -904,15 +909,16 @@ void SWEET_PARSER::parseCircle( CIRCLE* me )
...
@@ -904,15 +909,16 @@ void SWEET_PARSER::parseCircle( CIRCLE* me )
case
T_line_width
:
case
T_line_width
:
if
(
sawWidth
)
if
(
sawWidth
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawWidth
=
true
;
NeedNUMBER
(
"line_width"
);
NeedNUMBER
(
"line_width"
);
me
->
lineWidth
=
strtod
(
CurText
(),
NULL
);
me
->
lineWidth
=
fromWidth
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawWidth
=
true
;
break
;
break
;
case
T_fill
:
case
T_fill
:
if
(
sawFill
)
if
(
sawFill
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawFill
=
true
;
tok
=
NeedSYMBOL
();
tok
=
NeedSYMBOL
();
switch
(
tok
)
switch
(
tok
)
{
{
...
@@ -925,27 +931,26 @@ void SWEET_PARSER::parseCircle( CIRCLE* me )
...
@@ -925,27 +931,26 @@ void SWEET_PARSER::parseCircle( CIRCLE* me )
Expecting
(
"none|filled|transparent"
);
Expecting
(
"none|filled|transparent"
);
}
}
NeedRIGHT
();
NeedRIGHT
();
sawFill
=
true
;
break
;
break
;
case
T_center
:
case
T_center
:
if
(
sawCenter
)
if
(
sawCenter
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawCenter
=
true
;
NeedNUMBER
(
"center x"
);
NeedNUMBER
(
"center x"
);
me
->
center
.
x
=
internal
(
CurText
()
);
me
->
center
.
x
=
internal
(
CurText
()
);
NeedNUMBER
(
"center y"
);
NeedNUMBER
(
"center y"
);
me
->
center
.
y
=
internal
(
CurText
()
);
me
->
center
.
y
=
internal
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawCenter
=
true
;
break
;
break
;
case
T_radius
:
case
T_radius
:
if
(
sawRadius
)
if
(
sawRadius
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawRadius
=
true
;
NeedNUMBER
(
"radius"
);
NeedNUMBER
(
"radius"
);
me
->
radius
=
internal
(
CurText
()
);
me
->
radius
=
internal
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawRadius
=
true
;
break
;
break
;
default
:
default
:
...
@@ -984,15 +989,16 @@ void SWEET_PARSER::parseArc( ARC* me )
...
@@ -984,15 +989,16 @@ void SWEET_PARSER::parseArc( ARC* me )
case
T_line_width
:
case
T_line_width
:
if
(
sawWidth
)
if
(
sawWidth
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawWidth
=
true
;
NeedNUMBER
(
"line_width"
);
NeedNUMBER
(
"line_width"
);
me
->
lineWidth
=
strtod
(
CurText
(),
NULL
);
me
->
lineWidth
=
fromWidth
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawWidth
=
true
;
break
;
break
;
case
T_fill
:
case
T_fill
:
if
(
sawFill
)
if
(
sawFill
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawFill
=
true
;
tok
=
NeedSYMBOL
();
tok
=
NeedSYMBOL
();
switch
(
tok
)
switch
(
tok
)
{
{
...
@@ -1005,49 +1011,48 @@ void SWEET_PARSER::parseArc( ARC* me )
...
@@ -1005,49 +1011,48 @@ void SWEET_PARSER::parseArc( ARC* me )
Expecting
(
"none|filled|transparent"
);
Expecting
(
"none|filled|transparent"
);
}
}
NeedRIGHT
();
NeedRIGHT
();
sawFill
=
true
;
break
;
break
;
case
T_pos
:
case
T_pos
:
if
(
sawPos
)
if
(
sawPos
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawPos
=
true
;
NeedNUMBER
(
"pos x"
);
NeedNUMBER
(
"pos x"
);
me
->
pos
.
x
=
internal
(
CurText
()
);
me
->
pos
.
x
=
internal
(
CurText
()
);
NeedNUMBER
(
"pos y"
);
NeedNUMBER
(
"pos y"
);
me
->
pos
.
y
=
internal
(
CurText
()
);
me
->
pos
.
y
=
internal
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawPos
=
true
;
break
;
break
;
case
T_radius
:
case
T_radius
:
if
(
sawRadius
)
if
(
sawRadius
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawRadius
=
true
;
NeedNUMBER
(
"radius"
);
NeedNUMBER
(
"radius"
);
me
->
radius
=
internal
(
CurText
()
);
me
->
radius
=
internal
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawRadius
=
true
;
break
;
break
;
case
T_start
:
case
T_start
:
if
(
sawStart
)
if
(
sawStart
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawStart
=
true
;
NeedNUMBER
(
"start x"
);
NeedNUMBER
(
"start x"
);
me
->
start
.
x
=
internal
(
CurText
()
);
me
->
start
.
x
=
internal
(
CurText
()
);
NeedNUMBER
(
"start y"
);
NeedNUMBER
(
"start y"
);
me
->
start
.
y
=
internal
(
CurText
()
);
me
->
start
.
y
=
internal
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawStart
=
true
;
break
;
break
;
case
T_end
:
case
T_end
:
if
(
sawEnd
)
if
(
sawEnd
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawEnd
=
true
;
NeedNUMBER
(
"end x"
);
NeedNUMBER
(
"end x"
);
me
->
end
.
x
=
internal
(
CurText
()
);
me
->
end
.
x
=
internal
(
CurText
()
);
NeedNUMBER
(
"end y"
);
NeedNUMBER
(
"end y"
);
me
->
end
.
y
=
internal
(
CurText
()
);
me
->
end
.
y
=
internal
(
CurText
()
);
NeedRIGHT
();
NeedRIGHT
();
sawEnd
=
true
;
break
;
break
;
default
:
default
:
...
@@ -1099,91 +1104,100 @@ void SWEET_PARSER::parseText( GR_TEXT* me )
...
@@ -1099,91 +1104,100 @@ void SWEET_PARSER::parseText( GR_TEXT* me )
bool
sawFont
=
false
;
bool
sawFont
=
false
;
bool
sawVis
=
false
;
bool
sawVis
=
false
;
bool
sawJust
=
false
;
bool
sawJust
=
false
;
bool
sawText
=
false
;
NeedSYMBOLorNUMBER
();
me
->
text
=
FROM_UTF8
(
CurText
()
);
while
(
(
tok
=
NextTok
()
)
!=
T_RIGHT
)
while
(
(
tok
=
NextTok
()
)
!=
T_RIGHT
)
{
{
if
(
tok
!=
T_LEFT
)
if
(
tok
==
T_LEFT
)
Expecting
(
T_LEFT
);
tok
=
NextTok
();
switch
(
tok
)
{
{
case
T_at
:
tok
=
NextTok
();
if
(
sawAt
)
Duplicate
(
tok
);
parseAt
(
&
me
->
pos
,
&
me
->
angle
);
sawAt
=
true
;
break
;
case
T_fill
:
if
(
sawFill
)
Duplicate
(
tok
);
tok
=
NeedSYMBOL
();
switch
(
tok
)
switch
(
tok
)
{
{
case
T_none
:
case
T_at
:
case
T_filled
:
if
(
sawAt
)
case
T_transparent
:
Duplicate
(
tok
);
me
->
fillType
=
tok
;
parseAt
(
&
me
->
pos
,
&
me
->
angle
);
sawAt
=
true
;
break
;
break
;
default
:
Expecting
(
"none|filled|transparent"
);
}
NeedRIGHT
();
sawFill
=
true
;
break
;
case
T_justify
:
case
T_fill
:
if
(
sawJust
)
if
(
sawFill
)
Duplicate
(
tok
);
Duplicate
(
tok
);
tok
=
NeedSYMBOL
();
tok
=
NeedSYMBOL
();
switch
(
tok
)
switch
(
tok
)
{
{
case
T_center
:
case
T_none
:
case
T_right
:
case
T_filled
:
case
T_left
:
case
T_transparent
:
me
->
hjustify
=
tok
;
me
->
fillType
=
tok
;
break
;
default
:
Expecting
(
"none|filled|transparent"
);
}
NeedRIGHT
();
sawFill
=
true
;
break
;
break
;
default
:
Expecting
(
"center|right|left"
);
}
tok
=
NeedSYMBOL
();
case
T_justify
:
switch
(
tok
)
if
(
sawJust
)
{
Duplicate
(
tok
);
case
T_center
:
tok
=
NeedSYMBOL
();
case
T_top
:
switch
(
tok
)
case
T_bottom
:
{
me
->
vjustify
=
tok
;
case
T_center
:
case
T_right
:
case
T_left
:
me
->
hjustify
=
tok
;
break
;
default
:
Expecting
(
"center|right|left"
);
}
tok
=
NeedSYMBOL
();
switch
(
tok
)
{
case
T_center
:
case
T_top
:
case
T_bottom
:
me
->
vjustify
=
tok
;
break
;
default
:
Expecting
(
"center|top|bottom"
);
}
NeedRIGHT
();
sawJust
=
true
;
break
;
break
;
case
T_visible
:
if
(
sawVis
)
Duplicate
(
tok
);
parseBool
(
&
me
->
isVisible
);
NeedRIGHT
();
sawVis
=
true
;
break
;
case
T_font
:
if
(
sawFont
)
Duplicate
(
tok
);
sawFont
=
true
;
parseFont
(
&
me
->
font
);
break
;
default
:
default
:
Expecting
(
"
center|top|bottom
"
);
Expecting
(
"
at|justify|font|visible|fill
"
);
}
}
NeedRIGHT
();
}
sawJust
=
true
;
else
break
;
{
if
(
!
IsSymbol
(
tok
)
&&
tok
!=
T_NUMBER
)
case
T_visible
:
Expecting
(
T_STRING
);
if
(
sawVis
)
Duplicate
(
tok
);
parseBool
(
&
me
->
isVisible
);
NeedRIGHT
();
sawVis
=
true
;
break
;
case
T_font
:
if
(
sawText
)
if
(
sawFont
)
Duplicate
(
tok
);
Duplicate
(
tok
);
sawFont
=
true
;
sawText
=
true
;
parseFont
(
&
me
->
font
);
break
;
default
:
me
->
text
=
FROM_UTF8
(
CurText
()
);
Expecting
(
"at|justify|font|visible|fill"
);
}
}
}
}
}
}
...
...
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