Skip to content

Commit 3aec61b

Browse files
authored
Merge pull request #38 from Irwin1985/version_9
revision 9.6
2 parents 13f006d + 7e7ac22 commit 3aec61b

5 files changed

Lines changed: 62 additions & 58 deletions

File tree

JSONFox.PJT

-33 Bytes
Binary file not shown.

JSONFox.pjx

0 Bytes
Binary file not shown.

jsonfox.app

-28 Bytes
Binary file not shown.

src/jsonclass.prg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ define class JSONClass as session
44
LastErrorText = ""
55
lError = .f.
66
lShowErrors = .t.
7-
version = "9.5"
7+
version = "9.6"
88
hidden lInternal
99
hidden lTablePrompt
1010
Dimension aCustomArray[1]

src/netscanner.prg

Lines changed: 61 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,61 +1,65 @@
11
#include "JSONFox.h"
2-
define class NETScanner as custom
2+
Define Class NETScanner As Custom
33
Hidden capacity
4-
Hidden length
4+
Hidden Length
5+
Hidden Scanner
56
Dimension tokens[1]
6-
7-
function init(strInput)
8-
public ns
9-
ns = createobject("JSONFoxHelper.Lexer")
10-
ns.ReadString(strInput)
11-
this.length = 1
12-
this.capacity = 0
13-
EndFunc
14-
15-
function scanTokens
16-
return ns.NextToken()
17-
endfunc
18-
7+
8+
Function Init(strInput)
9+
With This
10+
.Scanner = Createobject("JSONFoxHelper.Lexer")
11+
.Scanner.ReadString(strInput)
12+
.Length = 1
13+
.capacity = 0
14+
Endwith
15+
Endfunc
16+
1917
Function scanTokens
20-
Local loToken
21-
Dimension this.tokens[1]
22-
loToken = ns.NextToken()
23-
this.addToken(loToken.type, loToken.value, 1)
24-
25-
Do while loToken.type != T_EOF
26-
loToken = ns.NextToken()
27-
this.addToken(loToken.type, loToken.value, 1)
28-
EndDo
29-
this.addToken(T_EOF, "", 1)
30-
this.capacity = this.length-1
31-
32-
* Shrink array
33-
Dimension this.tokens[this.capacity]
34-
35-
Return @this.tokens
36-
EndFunc
37-
38-
hidden function addToken(tnTokenType, tcTokenValue, tnLine)
39-
this.checkCapacity()
40-
local loToken
41-
loToken = createobject("Empty")
42-
=addproperty(loToken, "type", tnTokenType)
43-
=addproperty(loToken, "value", tcTokenValue)
44-
=AddProperty(loToken, "line", tnLine)
45-
46-
this.tokens[this.length] = loToken
47-
this.length = this.length + 1
48-
EndFunc
49-
50-
Hidden function checkCapacity
51-
If this.capacity < this.length + 1
52-
If Empty(this.capacity)
53-
this.capacity = 8
54-
Else
55-
this.capacity = this.capacity * 2
56-
EndIf
57-
Dimension this.tokens[this.capacity]
58-
EndIf
59-
endfunc
60-
61-
enddefine
18+
With This
19+
Local loToken
20+
Dimension .tokens[1]
21+
loToken = .Scanner.NextToken()
22+
.addToken(loToken.Type, loToken.Value, 1)
23+
24+
Do While loToken.Type != 0 && 0 T_NONE
25+
loToken = .Scanner.NextToken()
26+
.addToken(loToken.Type, loToken.Value, 1)
27+
Enddo
28+
.addToken(T_EOF, "", 1)
29+
.capacity = .Length-1
30+
31+
* Shrink array
32+
Dimension .tokens[.capacity]
33+
34+
Return @.tokens
35+
Endwith
36+
Endfunc
37+
38+
Hidden Function addToken(tnTokenType, tcTokenValue, tnLine)
39+
With This
40+
.checkCapacity()
41+
Local loToken
42+
loToken = Createobject("Empty")
43+
=AddProperty(loToken, "type", tnTokenType)
44+
=AddProperty(loToken, "value", tcTokenValue)
45+
=AddProperty(loToken, "line", tnLine)
46+
47+
.tokens[.length] = loToken
48+
.Length = .Length + 1
49+
Endwith
50+
Endfunc
51+
52+
Hidden Function checkCapacity
53+
With This
54+
If .capacity < .Length + 1
55+
If Empty(.capacity)
56+
.capacity = 8
57+
Else
58+
.capacity = .capacity * 2
59+
Endif
60+
Dimension .tokens[.capacity]
61+
Endif
62+
Endwith
63+
Endfunc
64+
65+
Enddefine

0 commit comments

Comments
 (0)