@@ -239,6 +239,13 @@ impl FilamentParser {
239239 . map_err ( |_| input. error ( "Expected valid bitwidth" ) )
240240 }
241241
242+ fn float ( input : Node ) -> ParseResult < f64 > {
243+ input
244+ . as_str ( )
245+ . parse :: < f64 > ( )
246+ . map_err ( |_| input. error ( "Expected valid float" ) )
247+ }
248+
242249 // ================ Intervals =====================
243250 fn time ( input : Node ) -> ParseResult < Loc < ast:: Time > > {
244251 let sp = Self :: get_span ( & input) ;
@@ -833,12 +840,13 @@ impl FilamentParser {
833840 Ok ( ( ) )
834841 }
835842
836- fn attributes < Bool , Num > (
843+ fn attributes < Bool , Num , Float > (
837844 input : Node ,
838- ) -> ParseResult < utils:: Attributes < Bool , Num > >
845+ ) -> ParseResult < utils:: Attributes < Bool , Num , Float > >
839846 where
840847 Bool : FromStr + Hash + Eq + Copy ,
841848 Num : FromStr + Hash + Eq + Copy ,
849+ Float : FromStr + Hash + Eq + Copy ,
842850 {
843851 let mut attrs = utils:: Attributes :: default ( ) ;
844852 for attr in input. into_children ( ) {
@@ -853,6 +861,9 @@ impl FilamentParser {
853861 [ identifier( name) , bitwidth( val) ] => Num :: from_str( name. as_ref( ) ) . map(
854862 |attr| attrs. set( attr, val, name. pos( ) ) ) . map_err(
855863 |_| attr. error( format!( "Found unknown numeric attribute \" {name}\" " ) ) ) ,
864+ [ identifier( name) , float( val) ] => Float :: from_str( name. as_ref( ) ) . map(
865+ |attr| attrs. set( attr, val, name. pos( ) ) ) . map_err(
866+ |_| attr. error( format!( "Found unknown float attribute \" {name}\" " ) ) ) ,
856867 ) ?;
857868 }
858869
0 commit comments