diff options
author | Brad King <brad.king@kitware.com> | 2022-08-09 13:07:24 (GMT) |
---|---|---|
committer | Brad King <brad.king@kitware.com> | 2022-08-09 13:09:51 (GMT) |
commit | a7211d6a2fd3097f88af94633b584d8ff76a8bce (patch) | |
tree | 40f62046de5ef271b6835ba48b76b35220acf47a /Source/LexerParser/cmFortranLexer.in.l | |
parent | 8ca7a53cdd0bf82f93447a581c95ca738df2d86c (diff) | |
download | CMake-a7211d6a2fd3097f88af94633b584d8ff76a8bce.zip CMake-a7211d6a2fd3097f88af94633b584d8ff76a8bce.tar.gz CMake-a7211d6a2fd3097f88af94633b584d8ff76a8bce.tar.bz2 |
Fortran: Teach lexer to handle CRLF newlines
We read sources in binary format, so we need to explicitly match CR
(`\r`) characters that occur as part of newlines in CRLF sources.
This is particularly important when line continuation (`&`) occurs
in the middle of module declaration or usage.
Diffstat (limited to 'Source/LexerParser/cmFortranLexer.in.l')
-rw-r--r-- | Source/LexerParser/cmFortranLexer.in.l | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Source/LexerParser/cmFortranLexer.in.l b/Source/LexerParser/cmFortranLexer.in.l index 05769a1..fac3181 100644 --- a/Source/LexerParser/cmFortranLexer.in.l +++ b/Source/LexerParser/cmFortranLexer.in.l @@ -75,10 +75,10 @@ Modify cmFortranLexer.cxx: return STRING; } -<str_dq,str_sq>&[ \t]*\n | -<str_dq,str_sq>&[ \t]*\n[ \t]*& /* Ignore (continued strings, free fmt) */ +<str_dq,str_sq>&[ \t]*\r?\n | +<str_dq,str_sq>&[ \t]*\r?\n[ \t]*& /* Ignore (continued strings, free fmt) */ -<fixed_fmt,str_dq,str_sq>\n[ ]{5}[^ \t\n] { +<fixed_fmt,str_dq,str_sq>\r?\n[ ]{5}[^ \t\r\n] { if (cmFortranParser_GetOldStartcond(yyextra) == fixed_fmt) ; /* Ignore (cont. strings, fixed fmt) */ else @@ -132,15 +132,15 @@ $[ \t]*else { return F90PPR_ELSE; } $[ \t]*endif { return F90PPR_ENDIF; } /* Line continuations, possible involving comments. */ -&([ \t\n]*|!.*)* -&([ \t\n]*|!.*)*& +&([ \t\r\n]*|!.*)* +&([ \t\r\n]*|!.*)*& , { return COMMA; } :: { return DCOLON; } : { return COLON; } -<fixed_fmt>\n[ ]{5}[^ ] { return GARBAGE; } +<fixed_fmt>\r?\n[ ]{5}[^ ] { return GARBAGE; } =|=> { return ASSIGNMENT_OP; } @@ -159,13 +159,13 @@ $[ \t]*endif { return F90PPR_ENDIF; } \( { return LPAREN; } \) { return RPAREN; } -[^ \t\n\r:;,!'"a-zA-Z=&()]+ { return GARBAGE; } +[^ \t\r\n:;,!'"a-zA-Z=&()]+ { return GARBAGE; } ;|\n { return EOSTMT; } [ \t\r,] /* Ignore */ -\\[ \t]*\n /* Ignore line-endings preceded by \ */ +\\[ \t]*\r?\n /* Ignore line-endings preceded by \ */ . { return *yytext; } |