Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lex fixed-form comments #12

Merged
merged 1 commit into from
Sep 23, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 15 additions & 4 deletions lib/Parse/Lexer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include "llvm/ADT/Twine.h"

// FIXME: Errors from diag:: for BOZ literals
// FIXME: Magic constants for line length, look for 72 and 132

namespace flang {

Expand Down Expand Up @@ -299,9 +300,6 @@ void Lexer::LineOfText::GetNextLine(bool AtLineStart) {

const char *AmpersandPos = 0;
if(LanguageOptions.FixedForm) {
if(AtLineStart)
SkipFixedFormBlankLinesAndComments(I, LineBegin);

// Fixed form
while (I != 72 && !isVerticalWhitespace(*BufPtr) && *BufPtr != '\0') {
++I, ++BufPtr;
Expand Down Expand Up @@ -1281,9 +1279,10 @@ void Lexer::LexTokenInternal(Token &Result, bool IsPeekAhead) {
}

// Check to see if we're at the start of a line.
if (getLineBegin() == getCurrentPtr())
if (getLineBegin() == getCurrentPtr()) {
// The returned token is at the start of the line.
Result.setFlag(Token::StartOfStatement);
}

// If we saw a semicolon, then we're at the start of a new statement.
if (LastTokenWasSemicolon) {
Expand All @@ -1299,6 +1298,18 @@ void Lexer::LexTokenInternal(Token &Result, bool IsPeekAhead) {
TokStart = getCurrentPtr();
tok::TokenKind Kind;

// Fixed-form comments
if (Features.FixedForm) {
// 'C' or '*' at the beginning of the line
if ((getLineBegin() == getCurrentPtr())
&& (Char == 'C' || Char == 'c' || Char == '*')) {
LexComment(Result);
if (Features.ReturnComments)
return;
return LexTokenInternal(Result, IsPeekAhead);
}
}

switch (Char) {
case 0: // Null.
// Found end of file?
Expand Down