;;; forth-syntax.el -- syntax-propertize function -*-lexical-binding:t-*-
;; This code mimics the Forth text interpreter and adds text
;; properties as side effect.
;;; Helpers
;; Skip forward over whitespace and the following word. Return the
;; start position of the word.
;; Return the whitespace-delimited word at position POS.
;; Return nil if POS is at end-of-buffer.
;; Set the syntax in the region START/END to "word" or "symbol". Do
;; nothing for characters that already have the correct syntax so that
;; word movement commands work "naturally".
;;; State functions
;; The parser is a loop that calls "state-functions".
;; A state function parses forward from point, adds text-properties as needed,
;; and returns the next state-function.
;;
;; The naming convention for state-functions is forth-syntax--state-FOO.
;; One line strings
)
)
;; The position where the current word started. It is setup by
;; `forth-syntax--state-normal'. It avoids the need to scan backward
;; so often.
;; For the word before point, set the font-lock-face property.
;; State for words that parse the following word, e.g. POSTPONE S"
;; where POSTPONE parses S".
;;
;; FIXME: It would nice be to know if we are in compilation state for
;; things like this: : FOO CREATE , ;
;; Because in this case CREATE doesn't parse immediately.
;; This is like `forth-syntax--state-parsing-word' but additionally
;; sets the font-lock-keyword-face.
;; This is also like `forth-syntax--state-parsing-word' but
;; additionally set font-lock-keyword-face for the current word and
;; font-lock-function-name-face for the following word.
;; It's intended for thigs like: DEFER S"
;; Define a state-function for comments. The comment starts with
;; the string BEGIN and ends with the string END.
;; For now, treat locals like comments
;; Hashtable that maps strings (word names) to parser functions.
;; Find the parsing function for WORD.