let's pretend BIN: HEX: OCT: never happened

db4
Joe Groff 2011-11-23 19:22:37 -08:00
parent 943596575a
commit 72de75b881
8 changed files with 23 additions and 71 deletions

View File

@ -100,8 +100,8 @@ HELP: set-file-ids
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"
}

View File

@ -36,15 +36,6 @@
<SEQ_REGEXP TYPE="LITERAL2"
HASH_CHAR="CHAR:"
AT_WORD_START="TRUE">CHAR:\s+(\S+)</SEQ_REGEXP>
<SEQ_REGEXP TYPE="LITERAL2"
HASH_CHAR="BIN:"
AT_WORD_START="TRUE">BIN:\s+(\S+)</SEQ_REGEXP>
<SEQ_REGEXP TYPE="LITERAL2"
HASH_CHAR="OCT:"
AT_WORD_START="TRUE">OCT:\s+(\S+)</SEQ_REGEXP>
<SEQ_REGEXP TYPE="LITERAL2"
HASH_CHAR="HEX:"
AT_WORD_START="TRUE">HEX:\s+(\S+)</SEQ_REGEXP>
<SPAN TYPE="COMMENT3" DELEGATE="STACK_EFFECT" NO_LINE_BREAK="TRUE">
<BEGIN>( </BEGIN>

View File

@ -21,11 +21,9 @@ ARTICLE: "reading-ahead" "Reading ahead"
(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"

View File

@ -81,11 +81,6 @@ unit-test
! 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( -- )

View File

@ -45,11 +45,14 @@ ARTICLE: "syntax-integers" "Integer syntax"
"-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" } "." ;
@ -109,14 +112,14 @@ ARTICLE: "syntax-floats" "Float syntax"
"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" } "." ;
@ -658,27 +661,6 @@ HELP: #!
{ $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" } }

View File

@ -201,18 +201,6 @@
<key>name</key>
<string>constant.character.factor</string>
</dict>
<dict>
<key>match</key>
<string>(^|(?&lt;=\s))((BIN:|OCT:)\s+)?-?\d+(\s|$)</string>
<key>name</key>
<string>constant.numeric.integer.factor</string>
</dict>
<dict>
<key>match</key>
<string>(^|(?&lt;=\s))HEX:\s+-?[\dA-Fa-f]+(\s|$)</string>
<key>name</key>
<string>constant.numeric.hexadecimal.integer.factor</string>
</dict>
<dict>
<key>match</key>
<string>(^|(?&lt;=\s))-?+\d+\.\d+(E(\+|-)\d+)?(\s|$)</string>

View File

@ -46,20 +46,19 @@
(defconst fuel-syntax--parsing-words
'(":" "::" ";" "&:" "<<" "<PRIVATE" ">>"
"ABOUT:" "AFTER:" "ALIAS:" "ALIEN:" "ARTICLE:"
"B" "BEFORE:" "BIN:"
"B" "BEFORE:"
"C:" "CALLBACK:" "C-GLOBAL:" "C-TYPE:" "CHAR:" "COM-INTERFACE:" "CONSTANT:" "CONSULT:" "call-next-method"
"DEFER:" "DESTRUCTOR:"
"EBNF:" ";EBNF" "ENUM:" "ERROR:" "EXCLUDE:"
"f" "FORGET:" "FROM:" "FUNCTION:" "FUNCTION-ALIAS:"
"GAME:" "GENERIC#" "GENERIC:"
"GLSL-SHADER:" "GLSL-PROGRAM:"
"HELP:" "HEX:" "HOOK:"
"HELP:" "HOOK:"
"IN:" "initial:" "INSTANCE:" "INTERSECTION:"
"LIBRARY:"
"M:" "M::" "MACRO:" "MACRO::" "MAIN:" "MATH:"
"MEMO:" "MEMO:" "METHOD:" "MIXIN:"
"NAN:"
"OCT:"
"POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROTOCOL:" "PROVIDE:"
"QUALIFIED-WITH:" "QUALIFIED:"
"read-only" "RENAME:" "REQUIRE:" "REQUIRES:"
@ -129,7 +128,7 @@
'("IN:" "USE:" "FROM:" "EXCLUDE:" "QUALIFIED:" "QUALIFIED-WITH:")))
(defconst fuel-syntax--int-constant-def-regex
(fuel-syntax--second-word-regex '("ALIEN:" "CHAR:" "BIN:" "HEX:" "NAN:" "OCT:")))
(fuel-syntax--second-word-regex '("ALIEN:" "CHAR:" "NAN:")))
(defconst fuel-syntax--type-definition-regex
(fuel-syntax--second-word-regex
@ -208,12 +207,11 @@
"DEFER:" "DESTRUCTOR:"
"FORGET:"
"GAME:" "GENERIC:" "GENERIC#" "GLSL-PROGRAM:"
"HEX:" "HOOK:"
"HOOK:"
"IN:" "INSTANCE:"
"LIBRARY:"
"MAIN:" "MATH:" "MIXIN:"
"NAN:"
"OCT:"
"POSTPONE:" "PRIVATE>" "<PRIVATE"
"QUALIFIED-WITH:" "QUALIFIED:"
"RENAME:"

View File

@ -73,12 +73,12 @@ syn match factorFloat /\<-\=[0-9]\([0-9,]*[0-9]\)\?\.[0-9,]*[0-9]\+\([
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\+\>/