Skip to content

Commit

Permalink
line continuation handling, not fully working
Browse files Browse the repository at this point in the history
  • Loading branch information
jpoirier committed Jun 20, 2015
1 parent 57190f3 commit 44ec8b0
Showing 1 changed file with 21 additions and 23 deletions.
44 changes: 21 additions & 23 deletions lex.c
Original file line number Diff line number Diff line change
Expand Up @@ -591,14 +591,14 @@ enum LexToken LexScanGetToken(Picoc *pc, struct LexState *Lexer,
case ':':
GotToken = TokenColon;
break;
// XXX: multiline support
// case '\\':
// if (NextChar == ' ' || NextChar == '\n') {
// LEXER_INC(Lexer);
// LexSkipLineCont(Lexer, NextChar);
// } else
// LexFail(pc, Lexer, "xx illegal character '%c'", ThisChar);
// break;
// XXX: line continuation feature
case '\\':
if (NextChar == ' ' || NextChar == '\n') {
LEXER_INC(Lexer);
LexSkipLineCont(Lexer, NextChar);
} else
LexFail(pc, Lexer, "illegal character '%c'", ThisChar);
break;
default:
LexFail(pc, Lexer, "illegal character '%c'", ThisChar);
break;
Expand Down Expand Up @@ -801,8 +801,8 @@ enum LexToken LexGetRawToken(struct ParseState *Parser, struct Value **Value,

Token = (enum LexToken)*(unsigned char*)Parser->Pos;
}
} while ((Parser->FileName == pc->StrEmpty &&
Token == TokenEOF) || Token == TokenEndOfLine);
} while ((Parser->FileName == pc->StrEmpty && Token == TokenEOF) ||
Token == TokenEndOfLine);

Parser->CharacterPos = *((unsigned char*)Parser->Pos + 1);
ValueSize = LexTokenSize(Token);
Expand Down Expand Up @@ -1104,22 +1104,20 @@ enum LexToken LexRawPeekToken(struct ParseState *Parser)
/* find the end of the line */
void LexToEndOfMacro(struct ParseState *Parser)
{
// bool isContinued = false;
// XXX: line continuation feature
bool isContinued = false;
while (true) {
enum LexToken Token = (enum LexToken)*(unsigned char*)Parser->Pos;
if (Token == TokenEndOfLine || Token == TokenEOF)
if (Token == TokenEOF)
return;
// XXX: multiline support
// else if (Token == TokenEndOfLine) {
// if (!isContinued)
// return;
// else
// isContinued = false;
else
// XXX: multiline support
// if (Token == TokenBackSlash)
// isContinued = true;
LexGetRawToken(Parser, NULL, true);
else if (Token == TokenEndOfLine) {
if (!isContinued)
return;
isContinued = false;
}
if (Token == TokenBackSlash)
isContinued = true;
LexGetRawToken(Parser, NULL, true);
}
}

Expand Down

0 comments on commit 44ec8b0

Please sign in to comment.