This repository has been archived by the owner on Nov 14, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 31
Internals
Craig Andera edited this page Nov 21, 2013
·
2 revisions
gherkin doesn't compile anything, but it does read strings into Lisp types.
Lisp types are represented by pointers which are bash strings of the following format: "${tag_marker}nnnddd..."
-
$tag_marker
is itself a string, the unprintable character"\036"
. It allows one to distinguish between native bash strings and Lisp pointers. Any string of which the first character is$tag_marker
is considered a pointer to a non-string type. -
nnn
is a 3-character string of an integer with leading zeros that represents the "type tag". gherkin currently supports 3 non-string types, each of which has a corresponding tag. -
ddd...
is the "data" portion of the pointer, and can be arbitrarily long. Integer objects store their printed representation here. conses store their pointer here, an integer into thecar
andcdr
arrays. symbols store a pointer here into thesymbols
array.
For instance, the +
primitive function accepts two arguments, each of which is understood to be a pointer to a Lisp object. It expects each object to be an integer - as of this writing no type checking is done. $tag_marker
and type tag are stripped from each pointer, and the remaining substrings - strings representing integers - are added together via bash's $((x + y))
.
Note: gherkin strings are native. Another way, gherkin string pointers represent themselves and are discerned by not having $tag_marker
at the front.