@@ -846,7 +846,7 @@ less.Parser = function Parser(env) {
846
846
c = $ ( '>' ) ;
847
847
}
848
848
if ( $ ( '(' ) ) {
849
- args = this . mixin . args . call ( this , true ) ;
849
+ args = this . mixin . args . call ( this , true ) . args ;
850
850
expect ( ')' ) ;
851
851
}
852
852
@@ -863,30 +863,73 @@ less.Parser = function Parser(env) {
863
863
restore ( ) ;
864
864
} ,
865
865
args : function ( isCall ) {
866
- var expressions = [ ] , argsSemiColon = [ ] , isSemiColonSeperated , argsComma = [ ] , expressionContainsNamed , name , nameLoop , value , arg , args ;
867
- while ( arg = $ ( this . expression ) ) {
866
+ var expressions = [ ] , argsSemiColon = [ ] , isSemiColonSeperated , argsComma = [ ] , expressionContainsNamed , name , nameLoop , value , arg ,
867
+ returner = { args :null , variadic : false } ;
868
+ while ( true ) {
869
+ if ( isCall ) {
870
+ arg = $ ( this . expression ) ;
871
+ } else {
872
+ $ ( this . comment ) ;
873
+ if ( input . charAt ( i ) === '.' && $ ( / ^ \. { 3 } / ) ) {
874
+ returner . variadic = true ;
875
+ if ( $ ( ";" ) && ! isSemiColonSeperated ) {
876
+ isSemiColonSeperated = true ;
877
+ }
878
+ ( isSemiColonSeperated ? argsSemiColon : argsComma )
879
+ . push ( { variadic : true } ) ;
880
+ break ;
881
+ }
882
+ arg = $ ( this . entities . variable ) || $ ( this . entities . literal )
883
+ || $ ( this . entities . keyword ) ;
884
+ }
885
+
886
+ if ( ! arg ) {
887
+ break ;
888
+ }
889
+
868
890
nameLoop = null ;
869
- arg . throwAwayComments ( ) ;
891
+ if ( arg . throwAwayComments ) {
892
+ arg . throwAwayComments ( ) ;
893
+ }
870
894
value = arg ;
895
+ var val = null ;
896
+
897
+ if ( isCall ) {
898
+ // Variable
899
+ if ( arg . value . length == 1 ) {
900
+ var val = arg . value [ 0 ] ;
901
+ }
902
+ } else {
903
+ val = arg ;
904
+ }
871
905
872
- // Variable
873
- if ( arg . value . length == 1 ) {
874
- var val = arg . value [ 0 ] ;
875
- if ( val instanceof tree . Variable ) {
876
- if ( $ ( ':' ) ) {
877
- if ( expressions . length > 0 ) {
878
- if ( isSemiColonSeperated ) {
879
- error ( "Cannot mix ; and , as delimiter types" ) ;
880
- }
881
- expressionContainsNamed = true ;
906
+ if ( val && val instanceof tree . Variable ) {
907
+ if ( $ ( ':' ) ) {
908
+ if ( expressions . length > 0 ) {
909
+ if ( isSemiColonSeperated ) {
910
+ error ( "Cannot mix ; and , as delimiter types" ) ;
882
911
}
883
- value = expect ( this . expression ) ;
884
- nameLoop = ( name = val . name ) ;
912
+ expressionContainsNamed = true ;
885
913
}
914
+ value = expect ( this . expression ) ;
915
+ nameLoop = ( name = val . name ) ;
916
+ } else if ( ! isCall && $ ( / ^ \. { 3 } / ) ) {
917
+ returner . variadic = true ;
918
+ if ( $ ( ";" ) && ! isSemiColonSeperated ) {
919
+ isSemiColonSeperated = true ;
920
+ }
921
+ ( isSemiColonSeperated ? argsSemiColon : argsComma )
922
+ . push ( { name : arg . name , variadic : true } ) ;
923
+ break ;
924
+ } else if ( ! isCall ) {
925
+ name = nameLoop = val . name ;
926
+ value = null ;
886
927
}
887
928
}
888
929
889
- expressions . push ( value ) ;
930
+ if ( value ) {
931
+ expressions . push ( value ) ;
932
+ }
890
933
891
934
argsComma . push ( { name :nameLoop , value :value } ) ;
892
935
@@ -913,8 +956,8 @@ less.Parser = function Parser(env) {
913
956
}
914
957
}
915
958
916
- args = isSemiColonSeperated ? argsSemiColon : argsComma ;
917
- return args ;
959
+ returner . args = isSemiColonSeperated ? argsSemiColon : argsComma ;
960
+ return returner ;
918
961
} ,
919
962
//
920
963
// A Mixin definition, with a list of parameters
@@ -945,33 +988,9 @@ less.Parser = function Parser(env) {
945
988
if ( match = $ ( / ^ ( [ # . ] (?: [ \w - ] | \\ (?: [ A - F a - f 0 - 9 ] { 1 , 6 } ? | [ ^ A - F a - f 0 - 9 ] ) ) + ) \s * \( / ) ) {
946
989
name = match [ 1 ] ;
947
990
948
- do {
949
- $ ( this . comment ) ;
950
- if ( input . charAt ( i ) === '.' && $ ( / ^ \. { 3 } / ) ) {
951
- variadic = true ;
952
- params . push ( { variadic : true } ) ;
953
- break ;
954
- } else if ( param = $ ( this . entities . variable ) || $ ( this . entities . literal )
955
- || $ ( this . entities . keyword ) ) {
956
- // Variable
957
- if ( param instanceof tree . Variable ) {
958
- if ( $ ( ':' ) ) {
959
- value = expect ( this . expression , 'expected expression' ) ;
960
- params . push ( { name : param . name , value : value } ) ;
961
- } else if ( $ ( / ^ \. { 3 } / ) ) {
962
- params . push ( { name : param . name , variadic : true } ) ;
963
- variadic = true ;
964
- break ;
965
- } else {
966
- params . push ( { name : param . name } ) ;
967
- }
968
- } else {
969
- params . push ( { value : param } ) ;
970
- }
971
- } else {
972
- break ;
973
- }
974
- } while ( $ ( ',' ) || $ ( ';' ) )
991
+ var argInfo = this . mixin . args . call ( this , false ) ;
992
+ params = argInfo . args ;
993
+ variadic = argInfo . variadic ;
975
994
976
995
// .mixincall("@{a}");
977
996
// looks a bit like a mixin definition.. so we have to be nice and restore
0 commit comments