forked from countingpine/tinybasic
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathparse_datatype.bas
More file actions
59 lines (46 loc) · 1.08 KB
/
parse_datatype.bas
File metadata and controls
59 lines (46 loc) · 1.08 KB
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
'::::::::
function new_datatype _
( _
byval dt as integer, _
byval ptr_cnt as integer, _
byval sym as sym_t ptr _
) as datatype_t ptr
dim as datatype_t ptr datatype = callocate( sizeof( datatype_t ) )
datatype->_dt = dt
datatype->_ptr_cnt = ptr_cnt
datatype->_sym = sym
function = datatype
end function
'::::::::
function parse_datatype _
( _
) as datatype_t ptr
dim as integer dt
dim as integer ptr_cnt
dim as sym_t ptr sym
sym = sym_find( lexer_stack.curr_lex->tk_str, 0 )
if sym then
dt = DT_TYPE
else
dim as integer typ = lexer_stack.curr_lex->tk_typ
if typ = TK_STRING then
dt = DT_STRING
elseif typ = TK_ANY then
dt = DT_ANY
elseif typ = TK_INTEGER then
dt = DT_INTEGER
elseif typ = TK_UINTEGER then
dt = DT_UINTEGER
elseif typ = TK_ZSTRING then
dt = DT_ZSTRING
else
expected( "datatype", "'" & lexer_stack.curr_lex->tk_str & "'" )
end if
end if
read_token( )
while lexer_stack.curr_lex->tk_typ = TK_PTR
ptr_cnt += 1
read_token( )
wend
function = new_datatype( dt, ptr_cnt, sym )
end function