Mercurial > repos > tabletprog
diff modules/string.tp @ 154:6e579a75a0a9
Add JSON parser and sample
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sat, 10 Aug 2013 11:51:47 -0700 |
parents | a6739206a9e3 |
children | 55e0dca7d3d7 |
line wrap: on
line diff
--- a/modules/string.tp Fri Aug 09 21:01:11 2013 -0700 +++ b/modules/string.tp Sat Aug 10 11:51:47 2013 -0700 @@ -94,16 +94,17 @@ intret } - llMessage: find:else withVars: { + llMessage: find:startingAt:else withVars: { intret <- obj_int32 ptr oneedle <- object ptr + startpos <- obj_int32 ptr ifNotFound <- object ptr sneedle <- string ptr i <- uint32_t notFound <- uint32_t - } andCode: :oneedle :ifNotFound { + } andCode: :oneedle :startpos :ifNotFound { sneedle <- mcall: string 1 oneedle - i <- 0 + i <- startpos num notFound <- 1 while: { notFound && i + (sneedle bytes) <= bytes} do: { if: (memcmp: data + i (sneedle data) (sneedle bytes)) = 0 { @@ -121,6 +122,10 @@ } } + find:else <- :toFind :orElse { + find: toFind startingAt: 0 else: orElse + } + llMessage: from:withLength withVars: { from <- obj_int32 ptr tocopy <- obj_int32 ptr @@ -183,4 +188,5 @@ } isInteger? <- { false } + isString? <- { true } }