Mon 16 Mar 11:09:06 CET 2026
This commit is contained in:
parent
0904e0af50
commit
2f8328ecf6
51
src/lexer.h
Normal file
51
src/lexer.h
Normal file
|
|
@ -0,0 +1,51 @@
|
|||
#ifndef _LEXER_H
|
||||
#define _LEXER_H
|
||||
|
||||
#include "types.h"
|
||||
|
||||
/*
|
||||
Code parser state
|
||||
*/
|
||||
typedef enum {
|
||||
PSTART,
|
||||
PEXPR,
|
||||
PARGS,
|
||||
PINSTR
|
||||
} ps_t;
|
||||
|
||||
/*
|
||||
Lexer (and parser) structure
|
||||
*/
|
||||
typedef struct {
|
||||
char * input;
|
||||
char * last; // input before NextToken
|
||||
char * next;
|
||||
index_t line; // line number
|
||||
token_t token;
|
||||
number_t x;
|
||||
index_t ix;
|
||||
token_t type;
|
||||
char name[MAXNAMELEN+1];
|
||||
char *arg;
|
||||
index_t arglen;
|
||||
ps_t ps;
|
||||
int argN;
|
||||
token_t lasttoken;
|
||||
token_t uptoken; // which token, e.g. CCALL, calls compileexpr
|
||||
#if HAS_FUNC > 0
|
||||
char fun[MAXNAMELEN+1]; // function name
|
||||
index_t fp[2]; // for local variables stored on the stack
|
||||
index_t level; // scope nesting level, basically we have only 0 (top-level) and 1 (function)
|
||||
#endif
|
||||
#if PROFILE>0
|
||||
index_t ntoken;
|
||||
#endif
|
||||
} lexer_t;
|
||||
|
||||
void LookAheadToken(lexer_t *lex);
|
||||
void SkipToken (lexer_t *lex);
|
||||
void NextToken (lexer_t *lex);
|
||||
void LexerInit(lexer_t *L);
|
||||
void LexerSetup(lexer_t *lex, char * input);
|
||||
|
||||
#endif
|
||||
Loading…
Reference in New Issue
Block a user