Path: blob/main/sys/contrib/openzfs/module/lua/llex.h
48383 views
// SPDX-License-Identifier: MIT1/*2** $Id: llex.h,v 1.72.1.1 2013/04/12 18:48:47 roberto Exp $3** Lexical Analyzer4** See Copyright Notice in lua.h5*/67#ifndef llex_h8#define llex_h910#include "lobject.h"11#include "lzio.h"121314#define FIRST_RESERVED 25715161718/*19* WARNING: if you change the order of this enumeration,20* grep "ORDER RESERVED"21*/22enum RESERVED {23/* terminal symbols denoted by reserved words */24TK_AND = FIRST_RESERVED, TK_BREAK,25TK_DO, TK_ELSE, TK_ELSEIF, TK_END, TK_FALSE, TK_FOR, TK_FUNCTION,26TK_GOTO, TK_IF, TK_IN, TK_LOCAL, TK_NIL, TK_NOT, TK_OR, TK_REPEAT,27TK_RETURN, TK_THEN, TK_TRUE, TK_UNTIL, TK_WHILE,28/* other terminal symbols */29TK_CONCAT, TK_DOTS, TK_EQ, TK_GE, TK_LE, TK_NE, TK_DBCOLON, TK_EOS,30TK_NUMBER, TK_NAME, TK_STRING31};3233/* number of reserved words */34#define NUM_RESERVED (cast(int, TK_WHILE-FIRST_RESERVED+1))353637typedef union {38lua_Number r;39TString *ts;40} SemInfo; /* semantics information */414243typedef struct Token {44int token;45SemInfo seminfo;46} Token;4748#ifdef current49#undef current50#endif5152/* state of the lexer plus state of the parser when shared by all53functions */54typedef struct LexState {55int current; /* current character (charint) */56int linenumber; /* input line counter */57int lastline; /* line of last token `consumed' */58Token t; /* current token */59Token lookahead; /* look ahead token */60struct FuncState *fs; /* current function (parser) */61struct lua_State *L;62ZIO *z; /* input stream */63Mbuffer *buff; /* buffer for tokens */64struct Dyndata *dyd; /* dynamic structures used by the parser */65TString *source; /* current source name */66TString *envn; /* environment variable name */67char decpoint; /* locale decimal point */68} LexState;697071LUAI_FUNC void luaX_init (lua_State *L);72LUAI_FUNC void luaX_setinput (lua_State *L, LexState *ls, ZIO *z,73TString *source, int firstchar);74LUAI_FUNC TString *luaX_newstring (LexState *ls, const char *str, size_t l);75LUAI_FUNC void luaX_next (LexState *ls);76LUAI_FUNC int luaX_lookahead (LexState *ls);77LUAI_FUNC l_noret luaX_syntaxerror (LexState *ls, const char *s);78LUAI_FUNC const char *luaX_token2str (LexState *ls, int token);798081#endif828384