]> gitweb.factorcode.org Git - factor.git/commitdiff
lexer/parser: rename (scan-token) to ?scan-token, (scan-datum) to ?scan-datum.
authorJohn Benediktsson <mrjbq7@gmail.com>
Tue, 20 May 2014 16:13:58 +0000 (09:13 -0700)
committerJohn Benediktsson <mrjbq7@gmail.com>
Tue, 20 May 2014 16:13:58 +0000 (09:13 -0700)
core/lexer/lexer-docs.factor
core/lexer/lexer.factor
core/parser/parser-docs.factor
core/parser/parser.factor

index 363295adb46fb357fcbab076555f7afc98a79583..01ed6828c23068e1a372964f0354c2454c76e72a 100644 (file)
@@ -57,14 +57,14 @@ HELP: parse-token
 { $values { "lexer" lexer } { "str/f" { $maybe string } } }
 { $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace." } ;
 
-HELP: (scan-token)
+HELP: ?scan-token
 { $values { "str/f" { $maybe string } } }
 { $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word outputs " { $link f } " on end of input. To throw an error on end of input, use " { $link scan-token } " instead." }
 $parsing-note ;
 
 HELP: scan-token
 { $values { "str" string } }
-{ $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word throws " { $link unexpected-eof } " on end of input. To output " { $link f } " on end of input, use " { $link (scan-token) } " instead." }
+{ $description "Reads the next token from the lexer. Tokens are delimited by whitespace, with the exception that " { $snippet "\"" } " is treated like a single token even when not followed by whitespace. This word throws " { $link unexpected-eof } " on end of input. To output " { $link f } " on end of input, use " { $link ?scan-token } " instead." }
 $parsing-note ;
 
 HELP: still-parsing?
index c143eceab6743b55ebd15246f5381f5de34aa2f2..ffccd7694c2dc4027cd7567c2513c8eb57478335 100644 (file)
@@ -117,14 +117,14 @@ M: lexer skip-word
         [ (parse-token) ] [ dup next-line parse-token ] if
     ] [ drop f ] if ;
 
-: (scan-token) ( -- str/f ) lexer get parse-token ;
+: ?scan-token ( -- str/f ) lexer get parse-token ;
 
 PREDICATE: unexpected-eof < unexpected got>> not ;
 
 : throw-unexpected-eof ( word -- * ) f unexpected ;
 
 : scan-token ( -- str )
-    (scan-token) [ "token" throw-unexpected-eof ] unless* ;
+    ?scan-token [ "token" throw-unexpected-eof ] unless* ;
 
 : expect ( token -- )
     scan-token 2dup = [ 2drop ] [ unexpected ] if ;
index 96a6ad642ca3baeb56a7d4e88fc7ba1058dcaec8..7df66997c928f713cc9ae310e428e2d0f19fe1fa 100644 (file)
@@ -18,8 +18,8 @@ ARTICLE: "reading-ahead" "Reading ahead"
 }
 "Parsing words that return " { $link f } " on end of file:"
 { $subsections
-    (scan-token)
-    (scan-datum)
+    ?scan-token
+    ?scan-datum
 }
 "A simple example is the " { $link POSTPONE: \ } " word:"
 { $see POSTPONE: \ } ;
@@ -160,7 +160,7 @@ HELP: parse-datum
 { $values { "string" string } { "word/number" "a word or number" } }
 { $description "If " { $snippet "string" } " is a valid number literal, it is converted to a number, otherwise the current vocabulary search path is searched for a word named by the string." }
 { $errors "Throws an error if the token does not name a word, and does not parse as a number." }
-{ $notes "This word is used to implement " { $link (scan-datum) } " and " { $link scan-datum } "." } ;
+{ $notes "This word is used to implement " { $link ?scan-datum } " and " { $link scan-datum } "." } ;
 
 HELP: scan-word
 { $values { "word" "a word" } }
@@ -176,25 +176,25 @@ HELP: scan-word-name
 { $errors "Throws an error if the scanned token is a number or upon finding end of file." }
 $parsing-note ;
 
-HELP: (scan-datum)
-{ $values { "word/number/f" "a word, a number, or " { $link f } } }
+HELP: ?scan-datum
+{ $values { "word/number/f" { $maybe word number } } }
 { $description "Reads the next token from parser input. If the token is found in the vocabulary search path, returns the word named by the token. If the token does not find a word, it is next converted to a number. If this conversion fails, too, this word returns " { $link f } "." }
 $parsing-note ;
 
 HELP: scan-datum
-{ $values { "word/number" "a word or a number" } }
+{ $values { "word/number" { $or word number } } }
 { $description "Reads the next token from parser input. If the token is found in the vocabulary search path, returns the word named be the token. If the token is not found in the vocabulary search path, it is converted to a number. If this conversion fails, an error is thrown." }
 { $errors "Throws an error if the token is not a number or end of file is reached." }
 $parsing-note ;
 
 HELP: scan-number
-{ $values { "number" "a number" } }
+{ $values { "number" number } }
 { $description "Reads the next token from parser input. If the token is a number literal, it is converted to a number. Otherwise, it throws an error." }
 { $errors "Throws an error if the token is not a number or end of file is reached." }
 $parsing-note ;
 
 HELP: parse-until-step
-{ $values { "accum" vector } { "end" word } { "?" "a boolean" } }
+{ $values { "accum" vector } { "end" word } { "?" boolean } }
 { $description "Parses a token. If the token is a number or an ordinary word, it is added to the accumulator. If it is a parsing word, calls the parsing word with the accumulator on the stack. Outputs " { $link f } " if " { $snippet "end" } " is encountered, " { $link t } " otherwise." }
 $parsing-note ;
 
index bba9bfe543d154e9170dab2c8ecef60203bba1f4..9060fa15573c0bb73425c4e35da84f1d80621747 100644 (file)
@@ -59,17 +59,17 @@ ERROR: number-expected ;
         dup string>number [ ] [ no-word ] ?if
     ] ?if ;
 
-: (scan-datum) ( -- word/number/f )
-    (scan-token) dup [ parse-datum ] when ;
+: ?scan-datum ( -- word/number/f )
+    ?scan-token dup [ parse-datum ] when ;
 
 : scan-datum ( -- word/number )
-    (scan-datum) [ \ word throw-unexpected-eof ] unless* ;
+    ?scan-datum [ \ word throw-unexpected-eof ] unless* ;
 
 : scan-word ( -- word )
-    (scan-token) parse-word ;
+    ?scan-token parse-word ;
 
 : scan-number ( -- number )
-    (scan-token) parse-number ;
+    ?scan-token parse-number ;
 
 ERROR: invalid-word-name string ;
 
@@ -105,7 +105,7 @@ ERROR: staging-violation word ;
     scan-object \ f or ;
 
 : parse-until-step ( accum end -- accum ? )
-    (scan-datum) {
+    ?scan-datum {
         { [ 2dup eq? ] [ 2drop f ] }
         { [ dup not ] [ drop throw-unexpected-eof t ] }
         { [ dup delimiter? ] [ unexpected t ] }