-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathbsparser.h
93 lines (78 loc) · 3 KB
/
bsparser.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#ifndef BSPARSER_H
#define BSPARSER_H
/*
* Copyright 2022 Rochus Keller <mailto:[email protected]>
*
* This file is part of the BUSY build system.
*
* The following is the license that applies to this copy of the
* application. For a license to use the application under conditions
* other than those described here, please email to [email protected].
*
* GNU General Public License Usage
* This file may be used under the terms of the GNU General Public
* License (GPL) versions 2.0 or 3.0 as published by the Free Software
* Foundation and appearing in the file LICENSE.GPL included in
* the packaging of this file. Please review the following information
* to ensure GNU General Public Licensing requirements will be met:
* http://www.fsf.org/licensing/licenses/info/GPLv2.html and
* http://www.gnu.org/copyleft/gpl.html.
*/
#include "lua.h"
#include "bscallbacks.h"
typedef enum BSNodeType { // #kind
BS_Invalid,
BS_BaseType, // see BSBaseType
BS_ListType,
BS_ModuleDef,
BS_ClassDecl,
BS_EnumDecl,
BS_VarDecl,
BS_FieldDecl,
BS_BlockDef,
BS_ProcDef,
BS_MacroDef,
BS_CondStat,
} BSNodeType;
typedef enum BSBaseType { // #type
BS_nil,
BS_boolean,
BS_integer,
BS_real,
BS_string,
BS_path,
BS_symbol
} BSBaseType;
typedef enum BSVisibility { // #visi
BS_Private, BS_Protected, BS_Public, BS_PublicDefault
} BSVisibility;
typedef enum BSReadability { // #rw
BS_var, BS_let, BS_param
} BSReadability;
extern void bs_preset_logger(lua_State *L, BSLogger, void*);
/* Expects
* 1. an absolute, normalized path to the directory in which BUSY is present,
* 2. the new module def table which is filled by bs_parser, kind and outer already set,
* 3. and the parameter table.
* Returns a module definition as a Lua table on the Lua stack.
* The actual module instance carrying the data is in another table which is referenced in the definition by #inst.
*
* The AST (but expressions and statements) is mapped to Lua tables in general.
* There is a table for vardecl, enumtype, basictype, classtype, fielddecl; expressions and statements are
* immediately executed.
* Class and list instances are tables as well; basic types are directly mapped to Lua values.
*/
extern int bs_parse(lua_State *L);
// supporting features
extern int bs_add_path(lua_State* L, int lhs, int rhs); // return 0..ok, >0..error
extern int bs_isa( lua_State *L, int lhs, int rhs ); // returns 1 if rhs is same or subclass of lhs, 0 otherwise
extern unsigned int bs_torowcol(int row, int col);
extern unsigned int bs_torow(int rowcol);
extern unsigned int bs_tocol(int rowcol);
extern int bs_isInEnum(lua_State* L, int type, int sym );
extern int bs_sameType(lua_State* L, int left, int right );
extern int bs_getAndCheckParam( lua_State* L, int builtins, int params, int paramName, int accessible, int refType );
// debugging feature; expects zero or more Lua values
extern int bs_dump(lua_State *L);
extern void bs_dump2(lua_State *L, const char* title, int index );
#endif // BSPARSER_H