fix STRUCT: functor when a slot name is the same as a non-lexical word name

db4
Joe Groff 2009-08-29 20:19:47 -05:00
parent 309b11213c
commit 2e3f75fd87
2 changed files with 14 additions and 12 deletions

View File

@ -161,10 +161,10 @@ WHERE
STRUCT: T-class
{ NAME int }
{ "x" { TYPE 4 } }
{ "y" { "short" N } }
{ "z" TYPE initial: 5 }
{ "w" { "int" 2 } } ;
{ x { TYPE 4 } }
{ y { "short" N } }
{ z TYPE initial: 5 }
{ float { "float" 2 } } ;
;FUNCTOR
@ -203,11 +203,11 @@ STRUCT: T-class
{ c-type "char" }
}
T{ struct-slot-spec
{ name "w" }
{ name "float" }
{ offset 16 }
{ class object }
{ initial f }
{ c-type { "int" 2 } }
{ c-type { "float" 2 } }
}
}
] [ a-struct struct-slots ] unit-test

View File

@ -58,15 +58,17 @@ M: object (fake-quotations>) , ;
[ parse-definition* ] dip
parsed ;
: >string-param ( string -- string/param )
dup search dup lexical? [ nip ] [ drop ] if ;
: scan-c-type* ( -- c-type/param )
scan {
{ [ dup "{" = ] [ drop \ } parse-until >array ] }
{ [ dup search ] [ search ] }
[ ]
} cond ;
scan dup "{" = [ drop \ } parse-until >array ] [ >string-param ] if ;
: scan-string-param ( -- name/param )
scan >string-param ;
:: parse-struct-slot* ( accum -- accum )
scan-param :> name
scan-string-param :> name
scan-c-type* :> c-type
\ } parse-until :> attributes
accum {