@@ -622,13 +622,15 @@ static bool parseWithStrategy (tokenInfo *token,
622622 }
623623 else if (s -> type == '*' && isType (token , '*' ))
624624 next_token = true;
625- else if ((s -> type == '{' && isType (token , '{' )) || (s -> type == '\\' && isType (token , TOKEN_IDENTIFIER )))
625+ else if (((s -> type == '{' || s -> type == '\\' ) && isType (token , '{' )) ||
626+ (s -> type == '\\' && isType (token , TOKEN_IDENTIFIER )))
626627 {
627628 int depth = 1 ;
629+ bool missing_parens = isType (token , TOKEN_IDENTIFIER );
628630
629631 next_token = true;
630632
631- if (s -> type == '{' && !readToken (token ))
633+ if (! missing_parens && !readToken (token ))
632634 {
633635 eof = true;
634636 break ;
@@ -638,7 +640,7 @@ static bool parseWithStrategy (tokenInfo *token,
638640 copyToken (name , token );
639641 vStringClear (name -> string );
640642 }
641- if (s -> type == '\\' )
643+ if (missing_parens )
642644 {
643645 vStringCat (name -> string , token -> string );
644646 depth = 0 ;
@@ -831,10 +833,12 @@ static bool parseNewcommandFull (tokenInfo *const token, bool *tokenUnprocessed,
831833{
832834 bool eof = false;
833835
834- /* \newcommand {cmd}[args][opt]{def} */
836+ /* \newcommand{cmd}[args][opt]{def} */
837+ /* \newcommand\cmd[args][opt]{def} */
838+ /* \def\cmd{replacement} */
835839 struct TexParseStrategy strategy [] = {
836840 {
837- .type = '{ ' ,
841+ .type = '\\ ' ,
838842 .flags = 0 ,
839843 .kindIndex = kind ,
840844 .roleIndex = ROLE_DEFINITION_INDEX ,
@@ -875,37 +879,6 @@ static bool parseNewcommand (tokenInfo *const token, bool *tokenUnprocessed)
875879 return parseNewcommandFull (token , tokenUnprocessed , TEXTAG_COMMAND );
876880}
877881
878- static bool parseDef (tokenInfo * const token , bool * tokenUnprocessed )
879- {
880- bool eof = false;
881-
882- /* \def\cmd{replacement} */
883- struct TexParseStrategy strategy [] = {
884- {
885- .type = '\\' ,
886- .flags = 0 ,
887- .kindIndex = TEXTAG_COMMAND ,
888- .roleIndex = ROLE_DEFINITION_INDEX ,
889- .name = NULL ,
890- .unique = false,
891- },
892- {
893- .type = '{' ,
894- .flags = 0 ,
895- .kindIndex = KIND_GHOST_INDEX ,
896- .name = NULL ,
897- },
898- {
899- .type = 0
900- }
901- };
902-
903- if (parseWithStrategy (token , strategy , tokenUnprocessed ))
904- eof = true;
905-
906- return eof ;
907- }
908-
909882static bool parseNewEnvironment (tokenInfo * const token , bool * tokenUnprocessed )
910883{
911884 bool eof = false;
@@ -1088,10 +1061,8 @@ static void parseTexFile (tokenInfo *const token)
10881061 case KEYWORD_newcommand :
10891062 case KEYWORD_renewcommand :
10901063 case KEYWORD_providecommand :
1091- eof = parseNewcommand (token , & tokenUnprocessed );
1092- break ;
10931064 case KEYWORD_def :
1094- eof = parseDef (token , & tokenUnprocessed );
1065+ eof = parseNewcommand (token , & tokenUnprocessed );
10951066 break ;
10961067 case KEYWORD_declaremathoperator :
10971068 eof = parseNewcommandFull (token , & tokenUnprocessed , TEXTAG_OPERATOR );
0 commit comments