Skip to content

Instantly share code, notes, and snippets.

@nedzadarek
Created May 2, 2018 14:33
Show Gist options
  • Save nedzadarek/7845ab73a7aa266e7d518f404a62b68d to your computer and use it in GitHub Desktop.
Save nedzadarek/7845ab73a7aa266e7d518f404a62b68d to your computer and use it in GitHub Desktop.
Parse lines (to new-line marker)
bl: [a b
c
]
parse bl [any [pos: if (not new-line? pos) skip] 'c]
; == true
bl: [ a b -> a + b
c d -> c * (c + d)
]
line-rule: [word! word! '-> [any [pos: if (not new-line? pos) skip] ] ]
parse bl [
any line-rule
]
bl: [ a b -> a + b
c d -> c * (c + d)
]
line-rule: [
set w1 word! set w2 word! (print mold reduce ["words: " w1 w2])
'->
start-pos: [any [pos: if (not new-line? pos) skip] ] end-pos: (print mold reduce ["code: " copy/part start-pos end-pos] )]
parse bl [
any line-rule
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment