1 /******************************************************************************
2 *
3 * Copyright (C) 2006, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: main 18.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 * Summary: Example of the using gentee analizer
15 *
16 ******************************************************************************/
17
18 include
19 {
20 $"..\..\lib\lex\lex.g"
21 "lexasm.g"
22 }
23
24 func main<main>
25 {
26 str in
27 uint i off lex
28 arrout out
29 uint igt // The current gtitem
30
31 out.isize = sizeof( lexitem )
32
33 in.read( "test.asm" )
34 lex = lex_init( 0, lexgasm.ptr())
35 gentee_lex( in->buf, lex, out )
36 // start = in.ptr()
37 off = out.data.ptr()
38 // igt as this
39
40 fornum i, *out
41 {
42 uint li
43
44 li as off->lexitem
45 if li.ltype != $ASM_LINE
46 {
47 print("type=\( hex2stru("", li.ltype )) pos = \(li.pos) len=\(li.len ) 0x\(hex2stru("", li.value )) \n")
48 }
49
50 off += sizeof( lexitem )
51 }
52 print("--------------------------\n")
53 off = out.data.ptr()
54 fornum i = 0, *out
55 {
56 uint li
57
58 li as off->lexitem
59
60 // if li.ltype != $ASM_UNKNOWN
61 {
62 str stemp
63
64 stemp.substr( in, li.pos, li.len )
65 print( " "+= stemp )
66 }
67 off += sizeof( lexitem )
68 }
69 lex_delete( lex )
70 print("--------------------------\n")
71 congetch("Press any key...")
72 }
73