@@ -46,7 +46,7 @@ Matcher.parse = function(str) {
46
46
var result = reader . readMatch ( matcher ) ;
47
47
if ( result === null ) {
48
48
throw new SyntaxError (
49
- "Expected " + matcher , reader . getLine ( ) , reader . getCol ( ) ) ;
49
+ "Expected " + matcher , reader . getLine ( ) , reader . getCol ( ) ) ;
50
50
}
51
51
return result ;
52
52
} ;
@@ -98,7 +98,7 @@ Matcher.parse = function(str) {
98
98
eat ( / ^ \s * , \s * / ) ;
99
99
var max = eat ( / ^ \d + / ) ;
100
100
eat ( / ^ \s * \} / ) ;
101
- return m . braces ( + min , + max ) ;
101
+ return m . braces ( Number ( min ) , Number ( max ) ) ;
102
102
}
103
103
return m ;
104
104
} ;
@@ -241,7 +241,7 @@ Matcher.many = function(required) {
241
241
seen [ i ] = true ;
242
242
// Increase matchCount iff this was a required element
243
243
// (or if all the elements are optional)
244
- if ( tryMatch ( matchCount + ( ( required === false || required [ i ] ) ? 1 : 0 ) ) ) {
244
+ if ( tryMatch ( matchCount + ( required === false || required [ i ] ? 1 : 0 ) ) ) {
245
245
expression . drop ( ) ;
246
246
return true ;
247
247
}
@@ -314,19 +314,39 @@ Matcher.oror = function() {
314
314
Matcher . prototype = {
315
315
constructor : Matcher ,
316
316
// These are expected to be overridden in every instance.
317
- match : function ( ) { throw new Error ( "unimplemented" ) ; } ,
318
- toString : function ( ) { throw new Error ( "unimplemented" ) ; } ,
317
+ match : function ( ) {
318
+ throw new Error ( "unimplemented" ) ;
319
+ } ,
320
+ toString : function ( ) {
321
+ throw new Error ( "unimplemented" ) ;
322
+ } ,
319
323
// This returns a standalone function to do the matching.
320
- func : function ( ) { return this . match . bind ( this ) ; } ,
324
+ func : function ( ) {
325
+ return this . match . bind ( this ) ;
326
+ } ,
321
327
// Basic combinators
322
- then : function ( m ) { return Matcher . seq ( this , m ) ; } ,
323
- or : function ( m ) { return Matcher . alt ( this , m ) ; } ,
324
- andand : function ( m ) { return Matcher . many ( true , this , m ) ; } ,
325
- oror : function ( m ) { return Matcher . many ( false , this , m ) ; } ,
328
+ then : function ( m ) {
329
+ return Matcher . seq ( this , m ) ;
330
+ } ,
331
+ or : function ( m ) {
332
+ return Matcher . alt ( this , m ) ;
333
+ } ,
334
+ andand : function ( m ) {
335
+ return Matcher . many ( true , this , m ) ;
336
+ } ,
337
+ oror : function ( m ) {
338
+ return Matcher . many ( false , this , m ) ;
339
+ } ,
326
340
// Component value multipliers
327
- star : function ( ) { return this . braces ( 0 , Infinity , "*" ) ; } ,
328
- plus : function ( ) { return this . braces ( 1 , Infinity , "+" ) ; } ,
329
- question : function ( ) { return this . braces ( 0 , 1 , "?" ) ; } ,
341
+ star : function ( ) {
342
+ return this . braces ( 0 , Infinity , "*" ) ;
343
+ } ,
344
+ plus : function ( ) {
345
+ return this . braces ( 1 , Infinity , "+" ) ;
346
+ } ,
347
+ question : function ( ) {
348
+ return this . braces ( 0 , 1 , "?" ) ;
349
+ } ,
330
350
hash : function ( ) {
331
351
return this . braces ( 1 , Infinity , "#" , Matcher . cast ( "," ) ) ;
332
352
} ,
0 commit comments