IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 10147


Ignore:
Timestamp:
Nov 22, 2006, 1:54:50 PM (20 years ago)
Author:
jhoblitt
Message:

merge the 'time' production into the 'scalar' production for a ~20% speed
boost
remove support for "epoch format" times

Location:
trunk/PS-IPP-Metadata-Config
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/PS-IPP-Metadata-Config/Changes

    r9849 r10147  
    330.10
    44    - fix handling of NULL strings
     5    - merge the 'time' production into the 'scalar' production for a ~20% speed boost
     6    - remove support for "epoch format" times
    57
    680.09 Thu Oct 26 16:16:28 HST 2006
  • trunk/PS-IPP-Metadata-Config/config_grammar.txt

    r9849 r10147  
    11# Copyright (c) 2005  Joshua Hoblitt
    22#
    3 # $Id: config_grammar.txt,v 1.8 2006-11-04 01:25:32 jhoblitt Exp $
     3# $Id: config_grammar.txt,v 1.9 2006-11-22 23:54:50 jhoblitt Exp $
    44
    55{
     
    77
    88    use Carp qw( carp );
     9    use DateTime::Format::ISO8601;
    910
    1011    our @scope_stack;
     
    2930    | typedef_declare
    3031    | multi_declare
    31     | time
    3232    | <error:unmatched statement: $text>
    3333
     
    131131    <skip:'[ \t\r]*'> comment(?) "\n"
    132132        {{ class   => 'comment_line' }}
    133 
    134 time:
    135     <skip:'[ \t\r]*'> name ttype <matchrule:$item{ttype}> comment(?) "\n"
    136         {
    137             use DateTime::Format::ISO8601;
    138 
    139             $return = {
    140                 class   => 'time',
    141                 name    => $item{name},
    142                 type    => $item{ttype},
    143                 value   => $item[4],
    144             };
    145 
    146             $return->{comment} = $item{'comment(?)'}[0]
    147                 if $item{'comment(?)'}[0];
    148 
    149             if ( defined $thisparser->{local}{name}{ $item{name} } ) {
    150                 $return->{multi}++
    151                     if $thisparser->{local}{name}{ $item{name} } =~ /MULTI/;
    152             } else {
    153                 $thisparser->{local}{name}{ $item{name} }++;
    154             }
    155         }
    156133
    157134typedef_declare:
     
    261238    | 'STRING'
    262239    | vtype
     240    | 'UTC'
     241    | 'UT1'
     242    | 'TAI'
     243    | 'TT'
    263244
    264245vtype:
     
    276257    | 'C64'
    277258    | 'BOOL'
    278 
    279 ttype:
    280     'UTC'
    281     | 'UT1'
    282     | 'TAI'
    283     | 'TT'
    284259
    285260S8: int
     
    303278        { [ map { @$_ } @{$item[1]} ] }
    304279
    305 tvalue:
    306     iso8601
    307     | epoch
    308 
    309280# backtracking optimization
    310281_vvalue:
     
    369340UTC:
    370341    iso8601
    371     | utc_epoch
    372342    | NULL
    373343
    374344UT1:
    375345    iso8601
    376     | epoch
    377346    | NULL
    378347
    379348TAI:
    380349    iso8601
    381     | epoch
    382350    | NULL
    383351
    384352TT:
    385353    iso8601
    386     | epoch
    387354    | NULL
    388355
     
    392359        { DateTime::Format::ISO8601->parse_datetime( $item[1] ) }
    393360
    394 utc_epoch:
    395     / (-?\d{1,19}) \s*,\s* (\d{1,9}) (?:\s*,\s* (\d))? /x
    396         {{
    397             sec         => $1,
    398             nsec        => $2,
    399             leapsecond  => $3,
    400         }}
    401 
    402 epoch:
    403     / (-?\d{1,19}) \s*,\s* (\d{1,9}) /x
    404         {{
    405             sec     => $1,
    406             nsec    => $2,
    407         }}
    408361NULL:
    409362    /NULL/
  • trunk/PS-IPP-Metadata-Config/t/05_time.t

    r9758 r10147  
    33# Copyright (C) 2005  Joshua Hoblitt
    44#
    5 # $Id: 05_time.t,v 1.4 2006-10-27 02:15:45 jhoblitt Exp $
     5# $Id: 05_time.t,v 1.5 2006-11-22 23:54:50 jhoblitt Exp $
    66
    77use strict;
     
    1212#$::RD_TRACE = 1;
    1313
    14 use Test::More tests => 17;
     14use Test::More tests => 15;
    1515use PS::IPP::Metadata::Config;
    1616
     
    3232        {
    3333            name    => 'mytime',
    34             class   => 'time',
    35             type    => 'UTC',
    36             value   => undef,
    37         },
    38         {
    39             name    => 'mytime',
    40             class   => 'time',
    41             type    => 'UT1',
    42             value   => undef,
    43         },
    44         {
    45             name    => 'mytime',
    46             class   => 'time',
    47             type    => 'TAI',
    48             value   => undef,
    49         },
    50         {
    51             name    => 'mytime',
    52             class   => 'time',
     34            class   => 'scalar',
     35            type    => 'UTC',
     36            value   => undef,
     37        },
     38        {
     39            name    => 'mytime',
     40            class   => 'scalar',
     41            type    => 'UT1',
     42            value   => undef,
     43        },
     44        {
     45            name    => 'mytime',
     46            class   => 'scalar',
     47            type    => 'TAI',
     48            value   => undef,
     49        },
     50        {
     51            name    => 'mytime',
     52            class   => 'scalar',
    5353            type    => 'TT',
    5454            value   => undef,
     
    7474        {
    7575            name    => 'mytime',
    76             class   => 'time',
    77             type    => 'UTC',
    78             value   => undef,
    79             comment => 'comment',
    80         },
    81         {
    82             name    => 'mytime',
    83             class   => 'time',
    84             type    => 'UT1',
    85             value   => undef,
    86             comment => 'comment',
    87         },
    88         {
    89             name    => 'mytime',
    90             class   => 'time',
    91             type    => 'TAI',
    92             value   => undef,
    93             comment => 'comment',
    94         },
    95         {
    96             name    => 'mytime',
    97             class   => 'time',
     76            class   => 'scalar',
     77            type    => 'UTC',
     78            value   => undef,
     79            comment => 'comment',
     80        },
     81        {
     82            name    => 'mytime',
     83            class   => 'scalar',
     84            type    => 'UT1',
     85            value   => undef,
     86            comment => 'comment',
     87        },
     88        {
     89            name    => 'mytime',
     90            class   => 'scalar',
     91            type    => 'TAI',
     92            value   => undef,
     93            comment => 'comment',
     94        },
     95        {
     96            name    => 'mytime',
     97            class   => 'scalar',
    9898            type    => 'TT',
    9999            value   => undef,
     
    120120        {
    121121            name    => 'recently',
    122             class   => 'time',
    123             type    => 'UTC',
    124             value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
    125         },
    126         {
    127             name    => 'recently',
    128             class   => 'time',
    129             type    => 'UT1',
    130             value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
    131         },
    132         {
    133             name    => 'recently',
    134             class   => 'time',
    135             type    => 'TAI',
    136             value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
    137         },
    138         {
    139             name    => 'recently',
    140             class   => 'time',
     122            class   => 'scalar',
     123            type    => 'UTC',
     124            value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
     125        },
     126        {
     127            name    => 'recently',
     128            class   => 'scalar',
     129            type    => 'UT1',
     130            value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
     131        },
     132        {
     133            name    => 'recently',
     134            class   => 'scalar',
     135            type    => 'TAI',
     136            value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
     137        },
     138        {
     139            name    => 'recently',
     140            class   => 'scalar',
    141141            type    => 'TT',
    142142            value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
     
    162162        {
    163163            name    => 'recently',
    164             class   => 'time',
    165             type    => 'UTC',
    166             value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
    167         },
    168         {
    169             name    => 'recently',
    170             class   => 'time',
    171             type    => 'UT1',
    172             value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
    173         },
    174         {
    175             name    => 'recently',
    176             class   => 'time',
    177             type    => 'TAI',
    178             value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
    179         },
    180         {
    181             name    => 'recently',
    182             class   => 'time',
     164            class   => 'scalar',
     165            type    => 'UTC',
     166            value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
     167        },
     168        {
     169            name    => 'recently',
     170            class   => 'scalar',
     171            type    => 'UT1',
     172            value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
     173        },
     174        {
     175            name    => 'recently',
     176            class   => 'scalar',
     177            type    => 'TAI',
     178            value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
     179        },
     180        {
     181            name    => 'recently',
     182            class   => 'scalar',
    183183            type    => 'TT',
    184184            value   => DateTime::Format::ISO8601->parse_datetime("2005-03-18T16:05:00Z"),
     
    225225}
    226226
    227 diag("epoch time format maybe deprecated");
    228 
    229 {
    230 my $example =<<END;
    231 recently    MULTI
    232 recently    UTC     123456, 5000, 1
    233 recently    UT1     123456, 5000
    234 recently    TAI     123456, 5000
    235 recently    TT      123456, 5000
    236 END
    237     my $config = $config_parser->parse( $example );
    238     ok( defined( $config ), "basic epoch time parsed");
    239 }
    240 
    241 {
    242 my $example =<<END;
    243 recently    MULTI
    244 recently    UTC     123456, 5000, 1         # foo
    245 recently    UT1     123456, 5000            # bar
    246 recently    TAI     123456, 5000            # baz
    247 recently    TT      123456, 5000            #
    248 END
    249     my $config = $config_parser->parse( $example );
    250     ok( defined( $config ), "epoch time with comments parsed");
    251 }
     227#diag("epoch time format maybe deprecated");
     228#
     229#{
     230#my $example =<<END;
     231#recently    MULTI
     232#recently    UTC     123456, 5000, 1
     233#recently    UT1     123456, 5000
     234#recently    TAI     123456, 5000
     235#recently    TT      123456, 5000
     236#END
     237#    my $config = $config_parser->parse( $example );
     238#    ok( defined( $config ), "basic epoch time parsed");
     239#}
     240#
     241#{
     242#my $example =<<END;
     243#recently    MULTI
     244#recently    UTC     123456, 5000, 1         # foo
     245#recently    UT1     123456, 5000            # bar
     246#recently    TAI     123456, 5000            # baz
     247#recently    TT      123456, 5000            #
     248#END
     249#    my $config = $config_parser->parse( $example );
     250#    ok( defined( $config ), "epoch time with comments parsed");
     251#}
    252252
    253253{
Note: See TracChangeset for help on using the changeset viewer.