Slightly improve the C and C++ support. Allow for function return

types being on the same line as the function name, this finally closes
PR # bin/1785.  Also allow :: and ~ as part of the function name, for
C++.

Still, C++ operator overloading will not be recognized as a valid
function name.  Fixing this would require a major overhaul of the \p
recognition parser.
This commit is contained in:
Joerg Wunsch 1996-10-18 17:23:33 +00:00
parent 43658eac64
commit 0d4abe6259
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=19019
2 changed files with 10 additions and 3 deletions

View File

@ -458,7 +458,12 @@ expmatch (s, re, mstring)
/* not optional and we still matched */
return (NIL);
}
if (!isalnum(*s1) && *s1 != '_')
if (!(isalnum(*s1) || *s1 == '_' ||
/* C++ destructor */
*s1 == '~' ||
/* C++ scope operator */
(strlen(s1) > 1 && *s1 == ':' && s1[1] == ':' &&
(s1++, TRUE))))
return (NIL);
if (*s1 == '\\')
_escaped = _escaped ? FALSE : TRUE;

View File

@ -33,7 +33,8 @@
#
C|c:\
:pb=^\d?*?\d?\p\d?\(\a?\)(\d|{):bb={:be=}:cb=/*:ce=*/:sb=":se=\e":lb=':\
:pb=^\a?\d?*?\d?\p\d?\(\a?\)(\d|{):\
:bb={:be=}:cb=/*:ce=*/:sb=":se=\e":lb=':\
:le=\e':tl:\
:kw=asm auto break case char continue default do double else enum\
extern float for fortran goto if int long register return short\
@ -134,7 +135,8 @@ yacc|Yacc|y:\
#else #endif #if #ifdef #ifndef #include #undef # define else endif\
if ifdef ifndef include undef:
C++|c++:\
:pb=^\d?*?\d?\p\d?\(\a?\)(\d|{):bb={:be=}:cb=/*:ce=*/:ab=//:\
:pb=^\a?\d?*?\d?\p\d?\(\a?\)(\d|{):\
:bb={:be=}:cb=/*:ce=*/:ab=//:\
:ae=$:sb=":se=\e":lb=':\
:le=\e':tl:\
:kw=asm auto break case char continue default do double else enum\