HELP: set-file-permissions
{ $values
{ "path" "a pathname string" } { "n" "an integer, interepreted as a string of bits" } }
-{ $description "Sets the file permissions for a given file with the supplied Unix permissions integer. Supplying an octal number with " { $link POSTPONE: OCT: } " is recommended." }
-{ $examples "Using the tradidional octal value:"
+{ $description "Sets the file permissions for a given file with the supplied Unix permissions integer." }
+{ $examples "Using the traditional octal value:"
{ $code "USING: io.files.info.unix kernel ;"
"\"resource:license.txt\" 0o755 set-file-permissions"
}
<SEQ_REGEXP TYPE="LITERAL2"\r
HASH_CHAR="CHAR:"\r
AT_WORD_START="TRUE">CHAR:\s+(\S+)</SEQ_REGEXP>\r
- <SEQ_REGEXP TYPE="LITERAL2"\r
- HASH_CHAR="BIN:"\r
- AT_WORD_START="TRUE">BIN:\s+(\S+)</SEQ_REGEXP>\r
- <SEQ_REGEXP TYPE="LITERAL2"\r
- HASH_CHAR="OCT:"\r
- AT_WORD_START="TRUE">OCT:\s+(\S+)</SEQ_REGEXP>\r
- <SEQ_REGEXP TYPE="LITERAL2"\r
- HASH_CHAR="HEX:"\r
- AT_WORD_START="TRUE">HEX:\s+(\S+)</SEQ_REGEXP>\r
\r
<SPAN TYPE="COMMENT3" DELEGATE="STACK_EFFECT" NO_LINE_BREAK="TRUE">\r
<BEGIN>( </BEGIN>\r
(scan-token)
(scan-datum)
}
-"For example, the " { $link POSTPONE: HEX: } " word uses this feature to read hexadecimal literals:"
-{ $see POSTPONE: HEX: }
"It is defined in terms of a lower-level word that takes the numerical base on the data stack, but reads the number from the parser and then adds it to the parse tree:"
{ $see parse-base }
-"Another simple example is the " { $link POSTPONE: \ } " word:"
+"A simple example is the " { $link POSTPONE: \ } " word:"
{ $see POSTPONE: \ } ;
ARTICLE: "parsing-word-nest" "Nested structure"
! Funny bug
[ 2 ] [ "IN: parser.tests : \0. ( -- x ) 2 ; \0." eval( -- n ) ] unit-test
-! These should throw errors
-[ "HEX: zzz" eval( -- obj ) ] must-fail
-[ "OCT: 999" eval( -- obj ) ] must-fail
-[ "BIN: --0" eval( -- obj ) ] must-fail
-
DEFER: foo
"IN: parser.tests USING: math prettyprint ; SYNTAX: foo 2 2 + . ;" eval( -- )
"-10"
"2432902008176640000"
}
-"Integers are entered in base 10 unless prefixed with a base change parsing word."
-{ $subsections
- POSTPONE: BIN:
- POSTPONE: OCT:
- POSTPONE: HEX:
+"Integers are entered in base 10 unless prefixed with a base-changing prefix. " { $snippet "0x" } " begins a hexadecimal literal, " { $snippet "0o" } " an octal literal, and " { $snippet "0b" } " a binary literal. A sign, if any, goes before the base prefix."
+{ $example
+ "USE: prettyprint"
+ "10 ."
+ "0b10 ."
+ "-0o10 ."
+ "0x10 ."
+ "10\n2\n-8\n16"
}
"More information on integers can be found in " { $link "integers" } "." ;
"t"
}
{ $example
- "1024.0 0x1.0P10 = ."
+ "-1024.0 -0x1.0P10 = ."
"t"
}
{ $example
"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."
+"The normalized hex form " { $snippet "±0x1.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 the binary IEEE 754 representation."
$nl
"More information on floats can be found in " { $link "floats" } "." ;
{ $values { "comment" "characters" } }
{ $description "Discards all input until the end of the line." } ;
-HELP: HEX:
-{ $syntax "HEX: NNN" "HEX: NNN.NNNpEEE" }
-{ $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" "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" "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" "0b100 ." "4" } } ;
-
HELP: NAN:
{ $syntax "NAN: payload" }
{ $values { "payload" "64-bit hexadecimal integer" } }
<key>name</key>
<string>constant.character.factor</string>
</dict>
- <dict>
- <key>match</key>
- <string>(^|(?<=\s))((BIN:|OCT:)\s+)?-?\d+(\s|$)</string>
- <key>name</key>
- <string>constant.numeric.integer.factor</string>
- </dict>
- <dict>
- <key>match</key>
- <string>(^|(?<=\s))HEX:\s+-?[\dA-Fa-f]+(\s|$)</string>
- <key>name</key>
- <string>constant.numeric.hexadecimal.integer.factor</string>
- </dict>
<dict>
<key>match</key>
<string>(^|(?<=\s))-?+\d+\.\d+(E(\+|-)\d+)?(\s|$)</string>
(defconst fuel-syntax--parsing-words\r
'(":" "::" ";" "&:" "<<" "<PRIVATE" ">>"\r
"ABOUT:" "AFTER:" "ALIAS:" "ALIEN:" "ARTICLE:"\r
- "B" "BEFORE:" "BIN:"\r
+ "B" "BEFORE:"\r
"C:" "CALLBACK:" "C-GLOBAL:" "C-TYPE:" "CHAR:" "COM-INTERFACE:" "CONSTANT:" "CONSULT:" "call-next-method"\r
"DEFER:" "DESTRUCTOR:"\r
"EBNF:" ";EBNF" "ENUM:" "ERROR:" "EXCLUDE:"\r
"f" "FORGET:" "FROM:" "FUNCTION:" "FUNCTION-ALIAS:"\r
"GAME:" "GENERIC#" "GENERIC:"\r
"GLSL-SHADER:" "GLSL-PROGRAM:"\r
- "HELP:" "HEX:" "HOOK:"\r
+ "HELP:" "HOOK:"\r
"IN:" "initial:" "INSTANCE:" "INTERSECTION:"\r
"LIBRARY:"\r
"M:" "M::" "MACRO:" "MACRO::" "MAIN:" "MATH:"\r
"MEMO:" "MEMO:" "METHOD:" "MIXIN:"\r
"NAN:"\r
- "OCT:"\r
"POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROTOCOL:" "PROVIDE:"\r
"QUALIFIED-WITH:" "QUALIFIED:"\r
"read-only" "RENAME:" "REQUIRE:" "REQUIRES:"\r
'("IN:" "USE:" "FROM:" "EXCLUDE:" "QUALIFIED:" "QUALIFIED-WITH:")))\r
\r
(defconst fuel-syntax--int-constant-def-regex\r
- (fuel-syntax--second-word-regex '("ALIEN:" "CHAR:" "BIN:" "HEX:" "NAN:" "OCT:")))\r
+ (fuel-syntax--second-word-regex '("ALIEN:" "CHAR:" "NAN:")))\r
\r
(defconst fuel-syntax--type-definition-regex\r
(fuel-syntax--second-word-regex\r
"DEFER:" "DESTRUCTOR:"\r
"FORGET:"\r
"GAME:" "GENERIC:" "GENERIC#" "GLSL-PROGRAM:"\r
- "HEX:" "HOOK:"\r
+ "HOOK:"\r
"IN:" "INSTANCE:"\r
"LIBRARY:"\r
"MAIN:" "MATH:" "MIXIN:"\r
"NAN:"\r
- "OCT:"\r
"POSTPONE:" "PRIVATE>" "<PRIVATE"\r
"QUALIFIED-WITH:" "QUALIFIED:"\r
"RENAME:"\r
syn match factorPosRatio /\<+\=[0-9]\([0-9,]*[0-9]\)\?\(+[0-9]\([0-9,]*[0-9]\+\)\?\)\?\/-\=[0-9]\([0-9,]*[0-9]\+\)\?\.\?\>/
syn match factorNegRatio /\<\-[0-9]\([0-9,]*[0-9]\)\?\(\-[0-9]\([0-9,]*[0-9]\+\)\?\)\?\/-\=[0-9]\([0-9,]*[0-9]\+\)\?\.\?\>/
syn region factorComplex start=/\<C{\>/ end=/\<}\>/ contains=@factorReal
-syn match factorBinErr /\<BIN:\s\+-\=[01,]*[^01 ]\S*\>/
-syn match factorBinary /\<BIN:\s\+-\=[01,]\+\>/
-syn match factorHexErr /\<HEX:\s\+-\=\(,\S*\|\S*,\|[-0-9a-fA-Fp,]*[^-0-9a-fA-Fp, ]\S*\)\>/
-syn match factorHex /\<HEX:\s\+-\=[0-9a-fA-F]\([0-9a-fA-F,]*[0-9a-fA-F]\)\?\(\.[0-9a-fA-F]\([0-9a-fA-F,]*[0-9a-fA-F]\)\?\)\?\(p-\=[0-9]\([0-9,]*[0-9]\)\?\)\?\>/
-syn match factorOctErr /\<OCT:\s\+-\=\(,\S*\|\S*,\|[0-7,]*[^0-7, ]\S*\)\>/
-syn match factorOctal /\<OCT:\s\+-\=[0-7,]\+\>/
+syn match factorBinErr /\<-\=0b[01,]*[^01 ]\S*\>/
+syn match factorBinary /\<-\=0b[01,]\+\>/
+syn match factorHexErr /\<-\=0x\(,\S*\|\S*,\|[-0-9a-fA-Fp,]*[^-0-9a-fA-Fp, ]\S*\)\>/
+syn match factorHex /\<-\=0x[0-9a-fA-F]\([0-9a-fA-F,]*[0-9a-fA-F]\)\?\(\.[0-9a-fA-F]\([0-9a-fA-F,]*[0-9a-fA-F]\)\?\)\?\(p-\=[0-9]\([0-9,]*[0-9]\)\?\)\?\>/
+syn match factorOctErr /\<-\=0o\(,\S*\|\S*,\|[0-7,]*[^0-7, ]\S*\)\>/
+syn match factorOctal /\<\+-\=0o[0-7,]\+\>/
syn match factorNan /\<NAN:\s\+[0-9a-fA-F]\([0-9a-fA-F,]*[0-9a-fA-F]\)\?\>/
syn match factorIn /\<IN:\s\+\S\+\>/