From 52a3f6f3097f7760dfd72d234bf856b27bf6abac Mon Sep 17 00:00:00 2001 From: John Benediktsson Date: Wed, 30 Mar 2016 21:08:41 -0700 Subject: [PATCH] lexer: support universal comments. --- core/bootstrap/syntax.factor | 1 - core/lexer/lexer-docs.factor | 2 +- core/lexer/lexer.factor | 19 ++++++++++++++++--- core/syntax/syntax-docs.factor | 10 ---------- core/syntax/syntax.factor | 2 -- 5 files changed, 17 insertions(+), 17 deletions(-) diff --git a/core/bootstrap/syntax.factor b/core/bootstrap/syntax.factor index fea500de49..eccd30c4a1 100644 --- a/core/bootstrap/syntax.factor +++ b/core/bootstrap/syntax.factor @@ -8,7 +8,6 @@ IN: bootstrap.syntax "syntax" create-vocab drop { - "!" "\"" "(" ":" diff --git a/core/lexer/lexer-docs.factor b/core/lexer/lexer-docs.factor index 96adc0816a..951fb72335 100644 --- a/core/lexer/lexer-docs.factor +++ b/core/lexer/lexer-docs.factor @@ -32,7 +32,7 @@ HELP: skip { $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 diff --git a/core/lexer/lexer.factor b/core/lexer/lexer.factor index 7ded3662f6..36ea984b2f 100644 --- a/core/lexer/lexer.factor +++ b/core/lexer/lexer.factor @@ -57,7 +57,7 @@ ERROR: unexpected want got ; [ 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 @@ -94,13 +94,26 @@ M: lexer skip-word : still-parsing-line? ( lexer -- ? ) check-lexer [ column>> ] [ line-length>> ] bi < ; +DEFER: parse-token + + + : (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? [ diff --git a/core/syntax/syntax-docs.factor b/core/syntax/syntax-docs.factor index e3e285d11d..752f667d11 100644 --- a/core/syntax/syntax-docs.factor +++ b/core/syntax/syntax-docs.factor @@ -26,11 +26,6 @@ $nl $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 @@ -658,11 +653,6 @@ HELP: ( { $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" } } diff --git a/core/syntax/syntax.factor b/core/syntax/syntax.factor index 8641345c54..78b41e2116 100644 --- a/core/syntax/syntax.factor +++ b/core/syntax/syntax.factor @@ -48,8 +48,6 @@ IN: bootstrap.syntax "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 "