CREED builtins reference

Notation:

( input -- output )
t
text
g
group
n
number
s
symbol
a
any type
r
regex pattern (is just text)

edit

s

( t -- )

Substitutes the marked text with t. Marks the new text.

a

( t -- )

Appends t after the marked text and marks it.

p

( t -- )

mark

amp - absolute mark position

( n -- )

Set absolute mark position.

pmp - push mark position

( -- n )

Push mark position to the stack.

aml - absolute mark length

( n -- )

Set absolute mark length.

pml - push mark length

( -- n )

Pushes mark length to the stack.

mrm - mark regex match

( r -- )

Set the mark to the match of regex r.

emrm - extend mark regex match

( r -- )

Extend the mark to the end of match of r.

zme - zero mark end

( -- )

Move the start of the mark to the mark end.

pm - push mark

( -- t )

Push the marked text to the stack.

mall

( -- )

Mark the whole buffer.

mend

( -- )

Extend the mark to the end of the buffer.

mbegin

( -- )

Extend the mark to the start of the buffer.

mcl - mark current line

( -- )

Flow control

apply

( g -- )

Apply a group.

rec

( -- )

Apply the current group recursively.

ret

( -- )

Return from the current group.

branch

( ngg -- )

Apply g1 if n != 0, else apply g2.

while

( gg -- )
  1. Apply g1.
  2. If stack top is non zero apply g2 and repeat.

awmb - apply with mark buffer

( g -- )

Apply the group with the marked text as the buffer. Then substites it back.

awtb - apply with text buffer

( tg -- t )

Apply the group with t as the buffer. Then pushes it back.

hrm - has regex match

( t -- n )

Push 1 if the mark contains match of t.

stack operations

misc

parse

( t -- g )

Parses a string into a group.

repr

( a -- t )

read

( t -- t )

Read a file and push the content to the stack.

write

( tt -- )

Writes text from the stack to a file, opens with “r”.

writea

( tt -- )

Writes text from the stack to a file, opens with “a”.

shell

( t -- t )

Executes a shell command and pushes the stdout.

dump

( -- )

put

( -- )

bind

( gs -- )

Binds a groud to a symbol.

math

group

append

( gg -- g )

Appends two groups together.

pgnth - push group nth

( gn -- ga )

Push nth member of group g, starting from 0. The group is left on the stack.

gnth - group nth

( gna -- g )

Set nth group member. If n is outside of bounds of the group, runtime error is invoked.

glen

( g -- gn )

Pushes length of the group g to the stack.