@@ -7274,22 +7274,6 @@ impl<'a> Parser<'a> {
7274
7274
let placeholder = tok. to_string ( ) + & ident. value ;
7275
7275
Ok ( Value :: Placeholder ( placeholder) )
7276
7276
}
7277
- tok @ Token :: Minus | tok @ Token :: Plus => {
7278
- let next_token = self . next_token ( ) ;
7279
- match next_token. token {
7280
- Token :: Number ( n, l) => {
7281
- if tok == Token :: Minus {
7282
- Ok ( Value :: Number (
7283
- Self :: parse ( tok. to_string ( ) + & n, location) ?,
7284
- l,
7285
- ) )
7286
- } else {
7287
- Ok ( Value :: Number ( Self :: parse ( n, location) ?, l) )
7288
- }
7289
- }
7290
- _ => self . expected ( "number" , next_token) ,
7291
- }
7292
- }
7293
7277
unexpected => self . expected (
7294
7278
"a value" ,
7295
7279
TokenWithLocation {
@@ -7311,6 +7295,29 @@ impl<'a> Parser<'a> {
7311
7295
}
7312
7296
}
7313
7297
7298
+ pub fn parse_number_value_with_sign ( & mut self ) -> Result < Expr , ParserError > {
7299
+ let next_token = self . next_token ( ) ;
7300
+ match next_token. token {
7301
+ tok @ Token :: Minus | tok @ Token :: Plus => {
7302
+ if tok == Token :: Plus {
7303
+ Ok ( Expr :: UnaryOp {
7304
+ op : UnaryOperator :: Plus ,
7305
+ expr : Box :: new ( Expr :: Value ( self . parse_number_value ( ) ?) ) ,
7306
+ } )
7307
+ } else {
7308
+ Ok ( Expr :: UnaryOp {
7309
+ op : UnaryOperator :: Minus ,
7310
+ expr : Box :: new ( Expr :: Value ( self . parse_number_value ( ) ?) ) ,
7311
+ } )
7312
+ }
7313
+ }
7314
+ _ => {
7315
+ self . prev_token ( ) ;
7316
+ Ok ( Expr :: Value ( self . parse_number_value ( ) ?) )
7317
+ }
7318
+ }
7319
+ }
7320
+
7314
7321
fn parse_introduced_string_value ( & mut self ) -> Result < Value , ParserError > {
7315
7322
let next_token = self . next_token ( ) ;
7316
7323
let location = next_token. location ;
@@ -11625,29 +11632,29 @@ impl<'a> Parser<'a> {
11625
11632
if self . parse_keywords ( & [ Keyword :: INCREMENT ] ) {
11626
11633
if self . parse_keywords ( & [ Keyword :: BY ] ) {
11627
11634
sequence_options. push ( SequenceOptions :: IncrementBy (
11628
- Expr :: Value ( self . parse_number_value ( ) ?) ,
11635
+ self . parse_number_value_with_sign ( ) ?,
11629
11636
true ,
11630
11637
) ) ;
11631
11638
} else {
11632
11639
sequence_options. push ( SequenceOptions :: IncrementBy (
11633
- Expr :: Value ( self . parse_number_value ( ) ?) ,
11640
+ self . parse_number_value_with_sign ( ) ?,
11634
11641
false ,
11635
11642
) ) ;
11636
11643
}
11637
11644
}
11638
11645
//[ MINVALUE minvalue | NO MINVALUE ]
11639
11646
if self . parse_keyword ( Keyword :: MINVALUE ) {
11640
- sequence_options. push ( SequenceOptions :: MinValue ( Some ( Expr :: Value (
11641
- self . parse_number_value ( ) ?,
11642
- ) ) ) ) ;
11647
+ sequence_options. push ( SequenceOptions :: MinValue ( Some (
11648
+ self . parse_number_value_with_sign ( ) ?,
11649
+ ) ) ) ;
11643
11650
} else if self . parse_keywords ( & [ Keyword :: NO , Keyword :: MINVALUE ] ) {
11644
11651
sequence_options. push ( SequenceOptions :: MinValue ( None ) ) ;
11645
11652
}
11646
11653
//[ MAXVALUE maxvalue | NO MAXVALUE ]
11647
11654
if self . parse_keywords ( & [ Keyword :: MAXVALUE ] ) {
11648
- sequence_options. push ( SequenceOptions :: MaxValue ( Some ( Expr :: Value (
11649
- self . parse_number_value ( ) ?,
11650
- ) ) ) ) ;
11655
+ sequence_options. push ( SequenceOptions :: MaxValue ( Some (
11656
+ self . parse_number_value_with_sign ( ) ?,
11657
+ ) ) ) ;
11651
11658
} else if self . parse_keywords ( & [ Keyword :: NO , Keyword :: MAXVALUE ] ) {
11652
11659
sequence_options. push ( SequenceOptions :: MaxValue ( None ) ) ;
11653
11660
}
@@ -11656,21 +11663,19 @@ impl<'a> Parser<'a> {
11656
11663
if self . parse_keywords ( & [ Keyword :: START ] ) {
11657
11664
if self . parse_keywords ( & [ Keyword :: WITH ] ) {
11658
11665
sequence_options. push ( SequenceOptions :: StartWith (
11659
- Expr :: Value ( self . parse_number_value ( ) ?) ,
11666
+ self . parse_number_value_with_sign ( ) ?,
11660
11667
true ,
11661
11668
) ) ;
11662
11669
} else {
11663
11670
sequence_options. push ( SequenceOptions :: StartWith (
11664
- Expr :: Value ( self . parse_number_value ( ) ?) ,
11671
+ self . parse_number_value_with_sign ( ) ?,
11665
11672
false ,
11666
11673
) ) ;
11667
11674
}
11668
11675
}
11669
11676
//[ CACHE cache ]
11670
11677
if self . parse_keywords ( & [ Keyword :: CACHE ] ) {
11671
- sequence_options. push ( SequenceOptions :: Cache ( Expr :: Value (
11672
- self . parse_number_value ( ) ?,
11673
- ) ) ) ;
11678
+ sequence_options. push ( SequenceOptions :: Cache ( self . parse_number_value_with_sign ( ) ?) ) ;
11674
11679
}
11675
11680
// [ [ NO ] CYCLE ]
11676
11681
if self . parse_keywords ( & [ Keyword :: NO , Keyword :: CYCLE ] ) {
0 commit comments