"syntax" create-vocab drop
{
- "!"
"\""
"("
":"
{ $description "Skips to the first space character (if " { $snippet "boolean" } " is " { $link f } ") or the first non-space character (otherwise). Tabulations used as separators instead of spaces will be flagged as an error." } ;
HELP: change-lexer-column
-{ $values { "lexer" lexer } { "quot" { $quotation ( col line -- newcol ) } } }
+{ $values { "lexer" lexer } { "quot" { $quotation ( ..a col line -- ..b newcol ) } } }
{ $description "Applies a quotation to the current column and line text to produce a new column, and moves the lexer position." } ;
HELP: skip-blank
[ swap forbid-tab CHAR: \s eq? xor ] curry find-from drop
] dip or ; inline
-: change-lexer-column ( lexer quot -- )
+: change-lexer-column ( ..a lexer quot: ( ..a col line -- ..b newcol ) -- ..b )
[ check-lexer [ column>> ] [ line-text>> ] bi ] prepose
keep column<< ; inline
: still-parsing-line? ( lexer -- ? )
check-lexer [ column>> ] [ line-length>> ] bi < ;
+DEFER: parse-token
+
+<PRIVATE
+
+: skip-comments ( lexer str -- str' )
+ dup "!" = [
+ drop [ next-line ] keep parse-token
+ ] [
+ nip
+ ] if ;
+
+PRIVATE>
+
: (parse-token) ( lexer -- str )
- check-lexer {
+ dup check-lexer {
[ column>> ]
[ skip-word ]
[ column>> ]
[ line-text>> ]
- } cleave subseq ;
+ } cleave subseq skip-comments ;
: parse-token ( lexer -- str/f )
dup still-parsing? [
$nl
"While parsing words supporting arbitrary syntax can be defined, the default set is found in the " { $vocab-link "syntax" } " vocabulary and provides the basis for all further syntactic interaction with Factor." ;
-ARTICLE: "syntax-comments" "Comments"
-{ $subsections
- POSTPONE: !
-} ;
-
ARTICLE: "syntax-immediate" "Parse time evaluation"
"Code can be evaluated at parse time. This is a rarely-used feature; one use-case is " { $link "loading-libs" } ", where you want to execute some code before the words in a source file are compiled."
{ $subsections
{ $see-also "effects" }
;
-HELP: !
-{ $syntax "! comment..." }
-{ $values { "comment" "characters" } }
-{ $description "Discards all input until the end of the line." } ;
-
HELP: NAN:
{ $syntax "NAN: payload" }
{ $values { "payload" "64-bit hexadecimal integer" } }
"Call stack literals are not supported" throw
] define-core-syntax
- "!" [ lexer get next-line ] define-core-syntax
-
"IN:" [ scan-token set-current-vocab ] define-core-syntax
"<PRIVATE" [ begin-private ] define-core-syntax