]> gitweb.factorcode.org Git - factor.git/blobdiff - core/syntax/syntax-docs.factor
use radix literals
[factor.git] / core / syntax / syntax-docs.factor
index 18434166b9933004b231dd34f948dc2923ee877b..5a3e237ab3cc797f05218882a46eb935b8d0d88a 100644 (file)
@@ -1,7 +1,7 @@
 USING: generic help.syntax help.markup kernel math parser words
 effects classes classes.tuple generic.math generic.single arrays
 io.pathnames vocabs.loader io sequences assocs words.symbol
-words.alias words.constant combinators vocabs.parser ;
+words.alias words.constant combinators vocabs.parser command-line ;
 IN: syntax
 
 ARTICLE: "parser-algorithm" "Parser algorithm"
@@ -105,15 +105,15 @@ ARTICLE: "syntax-floats" "Float syntax"
 { $subsections POSTPONE: NAN: }
 "Hexadecimal float literals are also supported. These consist of a hexadecimal literal with a decimal point and an optional base-two exponent expressed as a decimal number after " { $snippet "p" } " or " { $snippet "P" } ":"
 { $example
-    "8.0 HEX: 1.0p3 = ."
+    "8.0 0x1.0p3 = ."
     "t"
 }
 { $example
-    "1024.0 HEX: 1.0P10 = ."
+    "1024.0 0x1.0P10 = ."
     "t"
 }
 { $example
-    "10.125 HEX: 1.44p3 = ."
+    "10.125 0x1.44p3 = ."
     "t"
 }
 "The normalized hex form " { $snippet "HEX: ±1.MMMMMMMMMMMMMp±EEEE" } " allows any floating-point number to be specified precisely. The values of MMMMMMMMMMMMM and EEEE map directly to the mantissa and exponent fields of IEEE 754 representation."
@@ -214,7 +214,7 @@ ARTICLE: "syntax-pathnames" "Pathname syntax"
 
 ARTICLE: "syntax-effects" "Stack effect syntax"
 "Note that this is " { $emphasis "not" } " syntax to declare stack effects of words. This pushes an " { $link effect } " instance on the stack for reflection, for use with words such as " { $link define-declared } ", " { $link call-effect } " and " { $link execute-effect } "."
-{ $subsections POSTPONE: (( }
+{ $subsections POSTPONE: ( }
 { $see-also "effects" "inference" "tools.inference" } ;
 
 ARTICLE: "syntax-literals" "Literals"
@@ -478,7 +478,7 @@ HELP: CONSTANT:
 { $syntax "CONSTANT: word value" }
 { $values { "word" word } { "value" object } }
 { $description "Creates a word which pushes a value on the stack." }
-{ $examples { $code "CONSTANT: magic 1" "CONSTANT: science HEX: ff0f" } } ;
+{ $examples { $code "CONSTANT: magic 1" "CONSTANT: science 0xff0f" } } ;
 
 { define-constant POSTPONE: CONSTANT: } related-words
 
@@ -625,13 +625,7 @@ HELP: P"
 HELP: (
 { $syntax "( inputs -- outputs )" }
 { $values { "inputs" "a list of tokens" } { "outputs" "a list of tokens" } }
-{ $description "A stack effect declaration. This is treated as a comment unless it appears inside a word definition." }
-{ $see-also "effects" } ;
-
-HELP: ((
-{ $syntax "(( inputs -- outputs ))" }
-{ $values { "inputs" "a list of tokens" } { "outputs" "a list of tokens" } }
-{ $description "Literal stack effect syntax." }
+{ $description "Literal stack effect syntax.  Also used by syntax words (such as " { $link POSTPONE: : } "), typically declaring the stack effect of the word definition which follows." }
 { $notes "Useful for meta-programming with " { $link define-declared } "." }
 { $examples
     { $example
@@ -642,13 +636,15 @@ HELP: ((
         ""
         "["
         "    my-dynamic-word 2 { [ + ] [ * ] } random curry"
-        "    (( x -- y )) define-declared"
+        "    ( x -- y ) define-declared"
         "] with-compilation-unit"
         ""
         "2 my-dynamic-word ."
         "4"
     }
-} ;
+}
+{ $see-also "effects" }
+;
 
 HELP: !
 { $syntax "! comment..." }
@@ -667,21 +663,21 @@ HELP: HEX:
 { $values { "N" "hexadecimal digit (0-9, a-f, A-F)" } { "pEEE" "decimal exponent value" } }
 { $description "Adds an integer or floating-point value read from a hexadecimal literal to the parse tree." }
 { $examples
-    { $example "USE: prettyprint" "HEX: ff ." "255" }
-    { $example "USE: prettyprint" "HEX: 1.8p5 ." "48.0" }
+    { $example "USE: prettyprint" "0xff ." "255" }
+    { $example "USE: prettyprint" "0x1.8p5 ." "48.0" }
 } ;
 
 HELP: OCT:
 { $syntax "OCT: integer" }
 { $values { "integer" "octal digits (0-7)" } }
 { $description "Adds an integer read from an octal literal to the parse tree." }
-{ $examples { $example "USE: prettyprint" "OCT: 31337 ." "13023" } } ;
+{ $examples { $example "USE: prettyprint" "0o31337 ." "13023" } } ;
 
 HELP: BIN:
 { $syntax "BIN: integer" }
 { $values { "integer" "binary digits (0 and 1)" } }
 { $description "Adds an integer read from an binary literal to the parse tree." }
-{ $examples { $example "USE: prettyprint" "BIN: 100 ." "4" } } ;
+{ $examples { $example "USE: prettyprint" "0b100 ." "4" } } ;
 
 HELP: NAN:
 { $syntax "NAN: payload" }
@@ -716,7 +712,7 @@ HELP: MATH:
 { $description "Defines a new generic word which uses the " { $link math-combination } " method combination." } ;
 
 HELP: HOOK:
-{ $syntax "HOOK: word variable ( stack -- effect ) " }
+{ $syntax "HOOK: word variable ( stack -- effect )" }
 { $values { "word" "a new word to define" } { "variable" word } }
 { $description "Defines a new hook word in the current vocabulary. Hook words are generic words which dispatch on the value of a variable, so methods are defined with " { $link POSTPONE: M: } ". Hook words differ from other generic words in that the dispatch value is removed from the stack before the chosen method is called." }
 { $examples
@@ -850,7 +846,7 @@ HELP: C:
     "The following two lines are equivalent:"
     { $code
         "C: <color> color"
-        ": <color> color boa ;"
+        ": <color> ( red green blue -- color ) color boa ;"
     }
     "In both cases, a word " { $snippet "<color>" } " is defined, which reads three values from the stack and creates a " { $snippet "color" } " instance having these values in the " { $snippet "red" } ", " { $snippet "green" } " and " { $snippet "blue" } " slots, respectively."
 } ;
@@ -858,7 +854,7 @@ HELP: C:
 HELP: MAIN:
 { $syntax "MAIN: word" }
 { $values { "word" word } }
-{ $description "Defines the main entry point for the current vocabulary. This word will be executed when this vocabulary is passed to " { $link run } "." } ;
+{ $description "Defines the main entry point for the current vocabulary and source file. This word will be executed when this vocabulary is passed to " { $link run } " or the source file is passed to " { $link run-script } "." } ;
 
 HELP: <PRIVATE
 { $syntax "<PRIVATE ... PRIVATE>" }