@@ -571,6 +571,7 @@ public static object InterpretToken(string rawToken, string token, string mask,
571571 //static Regex symbolPat = new Regex("[:]?([\\D&&[^/]].*/)?(/|[\\D&&[^/]][^/]*)");
572572 static readonly Regex symbolPat = new Regex ( "^[:]?([^\\ p{Nd}/].*/)?(/|[^\\ p{Nd}/][^/]*)$" ) ;
573573 static readonly Regex keywordPat = new Regex ( "^[:]?([^/].*/)?(/|[^/][^/]*)$" ) ;
574+ static readonly Regex argPat = new Regex ( "^%(?:(&)|([1-9][0-9]*))?$" ) ;
574575
575576 [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Style" , "IDE0060:Remove unused parameter" , Justification = "Standard API" ) ]
576577 private static void ExtractNamesUsingMask ( string token , string maskNS , string maskName , out string ns , out string name )
@@ -1778,27 +1779,21 @@ sealed class ArgReader : ReaderBase
17781779 {
17791780 protected override object Read ( PushbackTextReader r , char pct , object opts , object pendingForms )
17801781 {
1781- //if (ARG_ENV.deref() == null)
1782- // return interpretToken(readToken(r, '%'));
1782+ var token = readSimpleToken ( r , '%' ) ;
1783+
17831784 if ( ARG_ENV . deref ( ) == null )
17841785 {
1785- return InterpretToken ( readSimpleToken ( r , '%' ) , null ) ;
1786+ return InterpretToken ( token , null ) ;
17861787 }
17871788
1788- int ch = r . Read ( ) ;
1789- Unread ( r , ch ) ;
1790- //% alone is first arg
1791- if ( ch == - 1 || isWhitespace ( ch ) || isTerminatingMacro ( ch ) )
1792- {
1793- return registerArg ( 1 ) ;
1794- }
1795- //object n = ReadAux(r, true, null, true, opts, pendingForms);
1796- object n = ReadAux ( r , opts , EnsurePending ( pendingForms ) ) ;
1797- if ( n . Equals ( Compiler . AmpersandSym ) )
1798- return registerArg ( - 1 ) ;
1799- if ( ! Util . IsNumeric ( n ) )
1789+ Match m = argPat . Match ( token ) ;
1790+ if ( ! m . Success )
18001791 throw new ArgumentException ( "arg literal must be %, %& or %integer" ) ;
1801- return registerArg ( Util . ConvertToInt ( n ) ) ;
1792+
1793+ if ( m . Groups [ 1 ] . Success ) // %&
1794+ return registerArg ( - 1 ) ;
1795+
1796+ return registerArg ( m . Groups [ 2 ] . Success ? int . Parse ( m . Groups [ 2 ] . Value ) : 1 ) ;
18021797 }
18031798
18041799 [ System . Diagnostics . CodeAnalysis . SuppressMessage ( "Style" , "IDE1006:Naming Styles" , Justification = "ClojureJVM name match" ) ]
0 commit comments