XLFJSOND ;SLC/KCM/TJB - Decode JSON ;26 Oct 2016
Source file <XLFJSOND.m>
| action | A | extended action | Ea | event driver | Ed | subscriber | Su | protocol | O | limited protocol | LP | run routine | RR | broker | B | edit | E | server | Se | P | screenman | SM | inquire | I |
| Name | Comments | DBIA/ICR reference |
|---|---|---|
| DECODE(XUJSON,XUROOT,XUERR) | ; Set JSON object into closed array ref XUROOT
|
|
| DIRECT | ; TAG for use by DECODE^XLFJSON
|
|
| NXTKN() | ; Move the pointers to the beginning of the next token
|
|
| ADDSTR | ; Add string value to current node, escaping text along the way
; Expects XULINE,XUIDX to reference that starting point of the index ; TODO: add a mechanism to specify names that should not be escaped ; just store as ":")= and ":",n)= |
|
| SETSTR | ; Set simple string value from within same line
; expects XUJSON, XULINE, XUINX, XUEND |
|
| UESEXT | ; unescape from XULINE,XUIDX to XUTLINE,XUEND & extend (\) if necessary
; expects XULINE,XUIDX,XUTLINE,XUEND |
|
| ADDBUF(XUX) | ; add buffer of characters to destination
; expects XUBUF,XUMAX,XUNODE,XUMORE to be defined ; used directly by ADDSTR |
|
| SAVEBUF | ; write out buffer to destination
; expects XUBUF,XUMAX,XUNODE,XUMORE to be defined ; used directly by ADDSTR,ADDBUF |
|
| ISCLOSEQ(XUBLINE) | ; return true if this is a closing, rather than escaped, quote
; expects ; XUJSON: lines of the JSON encoded string ; XUIDX: points to 1st character of the segment ; XULINE: points to the line in which the segment starts ; XUEND: points to 1st character after the " (may be past the end of the line) ; used directly by ADDSTR |
|
| NAMPARS() | ; Return parsed name, advancing index past the close quote
; -- This assumes no embedded quotes are in the name itself -- |
|
| SETNUM(XUDIGIT) | ; Set numeric along with any necessary modifier
|
|
| NUMPARS(XUDIGIT) | ; Return parsed number, advancing index past end of number
; XUIDX intially references the second digit |
|
| SETBOOL(XULTR) | ; Parse and set boolean value, advancing index past end of value
|
|
| OSETBOOL(XUX) | ; set a value and increment XUIDX
|
|
| CURNODE() | ; Return a global/local variable name based on XUSTACK
; Expects XUSTACK to be defined already |
|
| UES(X) | ; Unescape JSON string
; copy segments from START to POS-2 (right before \) ; translate target character (which is at $F position) |
|
| REALCHAR(C) | ; Return actual character from escaped
|
|
| ERRX(ID,VAL) | ; Set the appropriate error message
|
| Name | Line Occurrences |
|---|---|
| $$CURNODE | SETSTR+4, SETSTR+7, SETSTR+8, UESEXT+3, SETNUM+3, SETNUM+5, SETBOOL+11, OSETBOOL+1 |
| $$ISCLOSEQ | ADDSTR+9, ADDSTR+20 |
| $$NAMPARS | DIRECT+34 |
| $$NUMPARS | SETNUM+2 |
| $$NXTKN | DIRECT+21 |
| $$REALCHAR | UESEXT+19, UES+12 |
| $$UES | SETSTR+4 |
| ADDBUF | UESEXT+10, UESEXT+18, UESEXT+19 |
| ADDSTR | DIRECT+35 |
| ERRX | DIRECT+22, DIRECT+23, DIRECT+25, DIRECT+26, DIRECT+27, DIRECT+28, DIRECT+32, DIRECT+41, DIRECT+42, ADDSTR+16 , UESEXT+13, ISCLOSEQ+12, NAMPARS+8, NUMPARS+7, SETBOOL+7, SETBOOL+8, SETBOOL+9, SETBOOL+10, OSETBOOL+4, REALCHAR+11 |
| SAVEBUF | UESEXT+23, ADDBUF+3 |
| SETBOOL | DIRECT+37, DIRECT+38, DIRECT+39 |
| SETNUM | DIRECT+40 |
| SETSTR | ADDSTR+8, ADDSTR+9 |
| UESEXT | ADDSTR+23 |
| >> | Not killed explicitly |
| * | Changed |
| ! | Killed |
| ~ | Newed |
| Name | Field # of Occurrence |
|---|---|
| C | REALCHAR~, REALCHAR+1, REALCHAR+2, REALCHAR+3, REALCHAR+4, REALCHAR+5, REALCHAR+6, REALCHAR+7, REALCHAR+8, REALCHAR+9 , REALCHAR+11, REALCHAR+12 |
| ID | ERRX~, ERRX+1 |
| POS | UES+3~, UES+4*, UES+5, UES+6*, UES+7*, UES+10, UES+11* |
| START | UES+3~, UES+5*, UES+6, UES+7, UES+10 |
| TGT | UES+9~, UES+10*, UES+11, UES+12 |
| VAL | ERRX~, ERRX+1 |
| X | UES~, UES+5, UES+6, UES+7, UES+10, UES+11 |
| XUBDONE | ISCLOSEQ+7~, ISCLOSEQ+8*, ISCLOSEQ+10, ISCLOSEQ+14* |
| XUBIDX | ISCLOSEQ+7~, ISCLOSEQ+8*, ISCLOSEQ+11, ISCLOSEQ+13*, ISCLOSEQ+14, ISCLOSEQ+15* |
| XUBLINE | ISCLOSEQ~, ISCLOSEQ+12*, ISCLOSEQ+13, ISCLOSEQ+14 |
| XUBOOL | SETBOOL+1~, SETBOOL+2*, SETBOOL+6*, SETBOOL+8, SETBOOL+9, SETBOOL+10, SETBOOL+11 |
| XUBS | ISCLOSEQ+7~, ISCLOSEQ+8*, ISCLOSEQ+15*, ISCLOSEQ+16 |
| XUBUF | UESEXT+2~, UESEXT+3*, ADDBUF+3, ADDBUF+4*, SAVEBUF+3, SAVEBUF+4, SAVEBUF+5* |
| XUDIFF | OSETBOOL+3~*, OSETBOOL+4 |
| XUDIGIT | SETNUM~, SETNUM+2, NUMPARS~, NUMPARS+3 |
| XUDONE | NXTKN+1~, NXTKN+2*, NXTKN+4*, ADDSTR+12~, ADDSTR+13*, ADDSTR+14, ADDSTR+19*, ADDSTR+20*, UESEXT+2~, UESEXT+4* , UESEXT+5, UESEXT+11*, UESEXT+21*, NAMPARS+2~, NAMPARS+3*, NAMPARS+4, NAMPARS+6*, NUMPARS+2~, NUMPARS+3*, NUMPARS+4 , NUMPARS+5*, SETBOOL+1~, SETBOOL+2*, SETBOOL+3, SETBOOL+5* |
| XUEND | ADDSTR+6~, ADDSTR+7*, ADDSTR+8, ADDSTR+9, ADDSTR+16*, ADDSTR+17*, ADDSTR+18, ADDSTR+19, ADDSTR+25, SETSTR+3 , UESEXT+3, ISCLOSEQ+8, NAMPARS+2~, NAMPARS+5*, NAMPARS+6, NAMPARS+7, NAMPARS+8 |
| XUEOF | NXTKN+1~, NXTKN+2*, NXTKN+3*, NXTKN+6 |
| XUERR | DECODE~, DIRECT+14*, REALCHAR+11 |
| XUERRORS | DIRECT+19~, DIRECT+20*, DIRECT+21, ADDSTR+14, ADDSTR+21, UESEXT+5, UESEXT+22, ISCLOSEQ+10, NAMPARS+4, NUMPARS+4 , SETBOOL+3 |
| XUI | UESEXT+2~, UESEXT+4*, UESEXT+6*, UESEXT+8, UESEXT+9, UESEXT+11, UESEXT+12*, UESEXT+13*, UESEXT+14, UESEXT+16* , UESEXT+17*, UESEXT+20*, UESEXT+21, CURNODE+2~, CURNODE+4*, CURNODE+5, CURNODE+6 |
| XUIDX | DIRECT+19~, DIRECT+20*, NXTKN+3*, NXTKN+4, NXTKN+5*, NXTKN+7*, ADDSTR+7, ADDSTR+25*, SETSTR+3*, SETSTR+9* , UESEXT+4, NAMPARS+5, NAMPARS+6*, NAMPARS+7, NAMPARS+8*, NUMPARS+5, NUMPARS+6, NUMPARS+7*, SETBOOL+4, SETBOOL+7* , OSETBOOL+2*, OSETBOOL+3, OSETBOOL+4* |
| XUINPUT | DIRECT+17~ |
| XUINPUT(1 | DIRECT+17* |
| XUJSON | DECODE~, DIRECT+17*, DIRECT+20, NXTKN+3, NXTKN+4, NXTKN+7, ADDSTR+7, ADDSTR+8, ADDSTR+16, ADDSTR+17 , ADDSTR+19, SETSTR+3, SETSTR+9, UESEXT+6, UESEXT+10, UESEXT+13, UESEXT+14, UESEXT+16, UESEXT+17, ISCLOSEQ+13 , ISCLOSEQ+14, NAMPARS+5, NAMPARS+6, NAMPARS+7, NAMPARS+8, NUMPARS+5, NUMPARS+6, NUMPARS+7, SETBOOL+4, SETBOOL+7 , OSETBOOL+3, OSETBOOL+4 |
| XULINE | DIRECT+19~, DIRECT+20*, NXTKN+3*, NXTKN+4, NXTKN+7, ADDSTR+7, ADDSTR+8, ADDSTR+9, ADDSTR+13, ADDSTR+25* , SETSTR+3, SETSTR+9*, UESEXT+4, ISCLOSEQ+12, NAMPARS+5, NAMPARS+6, NAMPARS+7, NAMPARS+8*, NUMPARS+5, NUMPARS+6 , NUMPARS+7*, SETBOOL+4, SETBOOL+7*, OSETBOOL+3, OSETBOOL+4* |
| XULTR | SETBOOL~, SETBOOL+2, SETBOOL+8, SETBOOL+9, SETBOOL+10 |
| XUMAX | DIRECT+13~*, ADDBUF+3 |
| XUMORE | UESEXT+2~, UESEXT+3*, SAVEBUF+3, SAVEBUF+4, SAVEBUF+5* |
| XUNAME | NAMPARS+2~, NAMPARS+3*, NAMPARS+6*, NAMPARS+7*, NAMPARS+10*, NAMPARS+11 |
| XUNODE | UESEXT+2~, UESEXT+3*, SAVEBUF+3, SAVEBUF+4 |
| XUNUM | NUMPARS+2~, NUMPARS+3*, NUMPARS+6*, NUMPARS+8 |
| XUPROP | DIRECT+19~, DIRECT+20*, DIRECT+23*, DIRECT+31*, DIRECT+32*, DIRECT+34 |
| XUROOT | DECODE~, DIRECT+18*, CURNODE+7 |
| XUSTACK | DIRECT+19~, DIRECT+20*, DIRECT+23*, DIRECT+25, DIRECT+26*, DIRECT+27*, DIRECT+28*, DIRECT+30, DIRECT+32, DIRECT+34 , DIRECT+42, CURNODE+4 |
| XUSTACK( | DIRECT+23*, DIRECT+25, DIRECT+27*, DIRECT+28, DIRECT+30*, DIRECT+32, DIRECT+34*, CURNODE+5, CURNODE+6 |
| XUSTART | UESEXT+2~, UESEXT+6*, UESEXT+10 |
| XUSTOP | UESEXT+2~, UESEXT+3*, UESEXT+8, UESEXT+11, UESEXT+21 |
| XUSUBS | CURNODE+2~, CURNODE+3*, CURNODE+4*, CURNODE+5*, CURNODE+6*, CURNODE+7 |
| XUTGT | UESEXT+14~*, UESEXT+15, UESEXT+19 |
| XUTGTC | UESEXT+16~*, UESEXT+17*, UESEXT+18 |
| XUTLINE | ADDSTR+12~, ADDSTR+13*, ADDSTR+16*, ADDSTR+17, ADDSTR+19, ADDSTR+20, ADDSTR+25, UESEXT+8, UESEXT+11, UESEXT+21 |
| XUTO | UESEXT+2~, UESEXT+8*, UESEXT+9*, UESEXT+10 |
| XUTOKEN | NXTKN+1~, NXTKN+7*, NXTKN+8 |
| XUTYPE | DIRECT+19~, DIRECT+21*, DIRECT+22, DIRECT+23, DIRECT+24, DIRECT+27, DIRECT+28, DIRECT+29, DIRECT+32, DIRECT+33 , DIRECT+36*, DIRECT+37, DIRECT+38, DIRECT+39, DIRECT+40, DIRECT+41, SETBOOL+8, SETBOOL+9, SETBOOL+10 |
| XUVAL | DIRECT+19~, DIRECT+20*, DIRECT+22*, DIRECT+32* |
| XUX | ADDSTR+6~, SETSTR+2~, SETSTR+3*, SETSTR+4, SETSTR+7, SETSTR+8, ADDBUF~, ADDBUF+3, ADDBUF+4, SETNUM+1~ , SETNUM+2*, SETNUM+3, SETNUM+5, SETBOOL+1~, SETBOOL+4*, SETBOOL+5, SETBOOL+6, OSETBOOL~, OSETBOOL+1, OSETBOOL+2 |
| XUY | UESEXT+2~, UESEXT+4*, UESEXT+6, UESEXT+8, UESEXT+10, UESEXT+11, UESEXT+12*, UESEXT+13*, UESEXT+14, UESEXT+16 , UESEXT+17*, UESEXT+21 |
| Y | UES+3~, UES+4*, UES+7*, UES+10*, UES+11*, UES+12*, UES+13 |