|
Revision 1, 1.0 kB
(checked in by krobillard, 3 years ago)
|
|
Import orca & thune.
|
| Line | |
|---|
| 1 | REBOL [] |
|---|
| 2 | |
|---|
| 3 | |
|---|
| 4 | test-parser: context [ |
|---|
| 5 | a: b: blk: none |
|---|
| 6 | |
|---|
| 7 | append-blk: func [start end type] [ |
|---|
| 8 | probe start |
|---|
| 9 | probe type |
|---|
| 10 | append blk make type copy/part start end |
|---|
| 11 | ] |
|---|
| 12 | |
|---|
| 13 | digit: charset [#"0" - #"9"] |
|---|
| 14 | alpha: charset [#"A" - #"Z" #"a" - #"z"] |
|---|
| 15 | alpha-num: charset [#"A" - #"Z" #"a" - #"z" #"0" - #"9"] |
|---|
| 16 | white: charset " ^-^/" |
|---|
| 17 | sign: charset "+-" |
|---|
| 18 | |
|---|
| 19 | word: [ alpha any alpha-num ] |
|---|
| 20 | set-word: [ alpha any alpha-num #":" ] |
|---|
| 21 | get-word: [ #":" alpha any alpha-num ] |
|---|
| 22 | int: [ opt sign 1 12 digit ] |
|---|
| 23 | char: [ #"#" alpha ] |
|---|
| 24 | |
|---|
| 25 | token: [ |
|---|
| 26 | some white |
|---|
| 27 | | a: set-word b: (append-blk a back b set-word!) |
|---|
| 28 | | a: word b: (append-blk a b word!) |
|---|
| 29 | | a: get-word b: (append-blk next a b get-word!) |
|---|
| 30 | | a: int b: (append-blk a b integer!) |
|---|
| 31 | | a: char b: (append blk pick a 2) |
|---|
| 32 | ] |
|---|
| 33 | |
|---|
| 34 | set 'urparse func [code] [ |
|---|
| 35 | blk: make block! 8 |
|---|
| 36 | parse/all code [some token] |
|---|
| 37 | blk |
|---|
| 38 | ] |
|---|
| 39 | ] |
|---|
| 40 | |
|---|
| 41 | |
|---|
| 42 | probe urparse {a b: 1 #c 3} |
|---|