Skip to content

Commit 859cc7c

Browse files
committed
fixed bugs in parse() method
1 parent 14bc713 commit 859cc7c

9 files changed

Lines changed: 18 additions & 24 deletions

File tree

JSONFox.PJT

0 Bytes
Binary file not shown.

JSONFox.pjx

0 Bytes
Binary file not shown.

jsonfox.app

-30 Bytes
Binary file not shown.

src/frmjsonviewer.SCT

0 Bytes
Binary file not shown.

src/frmjsonviewer.scx

0 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.4"
7+
version = "9.5"
88
hidden lInternal
99
hidden lTablePrompt
1010
Dimension aCustomArray[1]

src/jsontortf.prg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -159,10 +159,10 @@ define class JSONToRTF as custom
159159
If this.check(tnTokenType)
160160
Return this.advance()
161161
EndIf
162-
if empty(tcErrorMessage)
163-
tcErrorMessage = "Parser Error: expected token '" + _screen.jsonUtils.tokenTypeToStr(tnTokenType) + "' got = '" + _screen.jsonUtils.tokenTypeToStr(this.peek.type) + "'"
162+
if empty(tcMessage)
163+
tcMessage = "Parser Error: expected token '" + _screen.jsonUtils.tokenTypeToStr(tnTokenType) + "' got = '" + _screen.jsonUtils.tokenTypeToStr(this.peek.type) + "'"
164164
endif
165-
error tcErrorMessage
165+
error tcMessage
166166
endfunc
167167

168168
Hidden Function check(tnTokenType)

src/parser.prg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -163,10 +163,10 @@ define class Parser as custom
163163
If .check(tnTokenType)
164164
Return .advance()
165165
EndIf
166-
if empty(tcErrorMessage)
167-
tcErrorMessage = "Parser Error: expected token '" + _screen.jsonUtils.tokenTypeToStr(tnTokenType) + "' got = '" + _screen.jsonUtils.tokenTypeToStr(.peek.type) + "'"
166+
if empty(tcMessage)
167+
tcMessage = "Parser Error: expected token '" + _screen.jsonUtils.tokenTypeToStr(tnTokenType) + "' got = '" + _screen.jsonUtils.tokenTypeToStr(.peek.type) + "'"
168168
endif
169-
error tcErrorMessage
169+
error tcMessage
170170
EndWith
171171
endfunc
172172

src/tokenizer.prg

Lines changed: 11 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1+
* <<DEBUG>>
12
* =========================================
2-
*!* clear
3+
*!* Clear
34
*!* Cd f:\desarrollo\github\jsonfox\src\
4-
*!* If Type('_SCREEN.oRegEx') != 'U'
5-
*!* =Removeproperty(_Screen, 'oRegEx')
6-
*!* Endif
7-
*!* =AddProperty(_Screen, 'oRegEx', Createobject("VBScript.RegExp"))
8-
*!* _Screen.oRegEx.Global = .T.
9-
10-
*!* #include "JSONFox.h"
11-
12-
*!* If File('c:\a1\tokens.txt')
13-
*!* Delete File 'c:\a1\tokens.txt'
14-
*!* EndIf
15-
16-
*!* *Set Step On
17-
*!* sc = CreateObject("Tokenizer", FileToStr("c:\a1\test.json"))
5+
*!* sc = CreateObject("Tokenizer", '"string"')
186
*!* tokens = sc.scanTokens()
197
*!* For i = 1 to Alen(tokens)
20-
*!* StrToFile(sc.tokenStr(tokens[i]) + Chr(13) + Chr(10), 'c:\a1\tokens.txt', 1)
218
*!* ? sc.tokenStr(tokens[i])
229
*!* Endfor
2310
* =========================================
11+
* <<DEBUG>>
12+
2413
#include "JSONFox.h"
2514
* Tokenizer
2615
define class Tokenizer as custom
@@ -96,6 +85,11 @@ define class Tokenizer as custom
9685
.advance()
9786
EndDo
9887
lexeme = Substr(.source, .start, .current-.start)
88+
*!* If .current == Len(.source)
89+
*!* lexeme = Substr(.source, .start, (.current+1)-.start)
90+
*!* Else
91+
*!* lexeme = Substr(.source, .start, .current-.start)
92+
*!* endif
9993
if inlist(lexeme, "true", "false", "null")
10094
return .addToken(iif(lexeme == 'null', T_NULL, T_BOOLEAN), lexeme)
10195
else
@@ -268,7 +262,7 @@ define class Tokenizer as custom
268262

269263
function isAtEnd
270264
With this
271-
return .current >= .sourceLen
265+
return .current > .sourceLen
272266
EndWith
273267
endfunc
274268

0 commit comments

Comments
 (0)