mirror of
https://github.com/NikitaIvanovV/ctpv.git
synced 2025-06-21 10:27:48 +02:00
end -> newline
This commit is contained in:
parent
9227cea15d
commit
ecf560c2b8
4
config.c
4
config.c
@ -162,12 +162,12 @@ static int command(void)
|
|||||||
|
|
||||||
static int commands(void)
|
static int commands(void)
|
||||||
{
|
{
|
||||||
accept(TOK_END);
|
accept(TOK_NEW_LN);
|
||||||
|
|
||||||
while (1) {
|
while (1) {
|
||||||
CHECK_NULL(accept(TOK_EOF));
|
CHECK_NULL(accept(TOK_EOF));
|
||||||
CHECK_OK(command());
|
CHECK_OK(command());
|
||||||
CHECK_OK_NULL(accept(TOK_END));
|
CHECK_OK_NULL(accept(TOK_NEW_LN));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
lexer.c
10
lexer.c
@ -222,13 +222,13 @@ static inline Token get_tok(Lexer *ctx, enum TokenType type)
|
|||||||
.col = ctx->tok_pos.col };
|
.col = ctx->tok_pos.col };
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline Token read_end(Lexer *ctx)
|
static inline Token read_new_line(Lexer *ctx)
|
||||||
{
|
{
|
||||||
Token tok = get_tok(ctx, TOK_NULL);
|
Token tok = get_tok(ctx, TOK_NULL);
|
||||||
|
|
||||||
while (peek_char(ctx) == '\n') {
|
while (peek_char(ctx) == '\n') {
|
||||||
next_char(ctx);
|
next_char(ctx);
|
||||||
tok.type = TOK_END;
|
tok.type = TOK_NEW_LN;
|
||||||
}
|
}
|
||||||
|
|
||||||
return tok;
|
return tok;
|
||||||
@ -364,7 +364,7 @@ Token lexer_get_token(Lexer *ctx)
|
|||||||
ATTEMPT_READ_CHAR(ctx, tok, '*', TOK_STAR);
|
ATTEMPT_READ_CHAR(ctx, tok, '*', TOK_STAR);
|
||||||
ATTEMPT_READ_CHAR(ctx, tok, '.', TOK_DOT);
|
ATTEMPT_READ_CHAR(ctx, tok, '.', TOK_DOT);
|
||||||
|
|
||||||
ATTEMPT_READ(ctx, read_end);
|
ATTEMPT_READ(ctx, read_new_line);
|
||||||
ATTEMPT_READ(ctx, read_symbol);
|
ATTEMPT_READ(ctx, read_symbol);
|
||||||
ATTEMPT_READ(ctx, read_digit);
|
ATTEMPT_READ(ctx, read_digit);
|
||||||
ATTEMPT_READ(ctx, read_block);
|
ATTEMPT_READ(ctx, read_block);
|
||||||
@ -390,8 +390,8 @@ char *lexer_token_type_str(enum TokenType type)
|
|||||||
return "<end of file>";
|
return "<end of file>";
|
||||||
case TOK_ERR:
|
case TOK_ERR:
|
||||||
return "<TOKEN ERROR>";
|
return "<TOKEN ERROR>";
|
||||||
case TOK_END:
|
case TOK_NEW_LN:
|
||||||
return "<end>";
|
return "<newline>";
|
||||||
case TOK_BLK_OPEN:
|
case TOK_BLK_OPEN:
|
||||||
return block_open;
|
return block_open;
|
||||||
case TOK_BLK_CLS:
|
case TOK_BLK_CLS:
|
||||||
|
4
lexer.h
4
lexer.h
@ -11,12 +11,12 @@
|
|||||||
typedef struct Lexer Lexer;
|
typedef struct Lexer Lexer;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int line, col;
|
unsigned int line, col;
|
||||||
enum TokenType {
|
enum TokenType {
|
||||||
TOK_NULL,
|
TOK_NULL,
|
||||||
TOK_EOF,
|
TOK_EOF,
|
||||||
TOK_ERR,
|
TOK_ERR,
|
||||||
TOK_END,
|
TOK_NEW_LN,
|
||||||
TOK_BLK_OPEN,
|
TOK_BLK_OPEN,
|
||||||
TOK_BLK_CLS,
|
TOK_BLK_CLS,
|
||||||
TOK_SLASH,
|
TOK_SLASH,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user