Skip to content

Commit

Permalink
Merge pull request #12 from zeuk/master
Browse files Browse the repository at this point in the history
Lex fixed-form comments
  • Loading branch information
jleidel authored Sep 23, 2017
2 parents a772fc5 + dd5384a commit 54cf076
Showing 1 changed file with 15 additions and 4 deletions.
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

0 comments on commit 54cf076

Please sign in to comment.