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 HELP: set-file-permissions
{ $values { $values
{ "path" "a pathname string" } { "n" "an integer, interepreted as a string of bits" } } { "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." } { $description "Sets the file permissions for a given file with the supplied Unix permissions integer." }
{ $examples "Using the tradidional octal value:" { $examples "Using the traditional octal value:"
{ $code "USING: io.files.info.unix kernel ;" { $code "USING: io.files.info.unix kernel ;"
"\"resource:license.txt\" 0o755 set-file-permissions" "\"resource:license.txt\" 0o755 set-file-permissions"
} }

View File

@ -36,15 +36,6 @@
<SEQ_REGEXP TYPE="LITERAL2" <SEQ_REGEXP TYPE="LITERAL2"
HASH_CHAR="CHAR:" HASH_CHAR="CHAR:"
AT_WORD_START="TRUE">CHAR:\s+(\S+)</SEQ_REGEXP> 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"> <SPAN TYPE="COMMENT3" DELEGATE="STACK_EFFECT" NO_LINE_BREAK="TRUE">
<BEGIN>( </BEGIN> <BEGIN>( </BEGIN>

View File

@ -21,11 +21,9 @@ ARTICLE: "reading-ahead" "Reading ahead"
(scan-token) (scan-token)
(scan-datum) (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:" "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 } { $see parse-base }
"Another simple example is the " { $link POSTPONE: \ } " word:" "A simple example is the " { $link POSTPONE: \ } " word:"
{ $see POSTPONE: \ } ; { $see POSTPONE: \ } ;
ARTICLE: "parsing-word-nest" "Nested structure" ARTICLE: "parsing-word-nest" "Nested structure"

View File

@ -81,11 +81,6 @@ unit-test
! Funny bug ! Funny bug
[ 2 ] [ "IN: parser.tests : \0. ( -- x ) 2 ; \0." eval( -- n ) ] unit-test [ 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 DEFER: foo
"IN: parser.tests USING: math prettyprint ; SYNTAX: foo 2 2 + . ;" eval( -- ) "IN: parser.tests USING: math prettyprint ; SYNTAX: foo 2 2 + . ;" eval( -- )

View File

@ -45,11 +45,14 @@ ARTICLE: "syntax-integers" "Integer syntax"
"-10" "-10"
"2432902008176640000" "2432902008176640000"
} }
"Integers are entered in base 10 unless prefixed with a base change parsing word." "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."
{ $subsections { $example
POSTPONE: BIN: "USE: prettyprint"
POSTPONE: OCT: "10 ."
POSTPONE: HEX: "0b10 ."
"-0o10 ."
"0x10 ."
"10\n2\n-8\n16"
} }
"More information on integers can be found in " { $link "integers" } "." ; "More information on integers can be found in " { $link "integers" } "." ;
@ -109,14 +112,14 @@ ARTICLE: "syntax-floats" "Float syntax"
"t" "t"
} }
{ $example { $example
"1024.0 0x1.0P10 = ." "-1024.0 -0x1.0P10 = ."
"t" "t"
} }
{ $example { $example
"10.125 0x1.44p3 = ." "10.125 0x1.44p3 = ."
"t" "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 $nl
"More information on floats can be found in " { $link "floats" } "." ; "More information on floats can be found in " { $link "floats" } "." ;
@ -658,27 +661,6 @@ HELP: #!
{ $values { "comment" "characters" } } { $values { "comment" "characters" } }
{ $description "Discards all input until the end of the line." } ; { $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: HELP: NAN:
{ $syntax "NAN: payload" } { $syntax "NAN: payload" }
{ $values { "payload" "64-bit hexadecimal integer" } } { $values { "payload" "64-bit hexadecimal integer" } }

View File

@ -201,18 +201,6 @@
<key>name</key> <key>name</key>
<string>constant.character.factor</string> <string>constant.character.factor</string>
</dict> </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> <dict>
<key>match</key> <key>match</key>
<string>(^|(?&lt;=\s))-?+\d+\.\d+(E(\+|-)\d+)?(\s|$)</string> <string>(^|(?&lt;=\s))-?+\d+\.\d+(E(\+|-)\d+)?(\s|$)</string>

View File

@ -46,20 +46,19 @@
(defconst fuel-syntax--parsing-words (defconst fuel-syntax--parsing-words
'(":" "::" ";" "&:" "<<" "<PRIVATE" ">>" '(":" "::" ";" "&:" "<<" "<PRIVATE" ">>"
"ABOUT:" "AFTER:" "ALIAS:" "ALIEN:" "ARTICLE:" "ABOUT:" "AFTER:" "ALIAS:" "ALIEN:" "ARTICLE:"
"B" "BEFORE:" "BIN:" "B" "BEFORE:"
"C:" "CALLBACK:" "C-GLOBAL:" "C-TYPE:" "CHAR:" "COM-INTERFACE:" "CONSTANT:" "CONSULT:" "call-next-method" "C:" "CALLBACK:" "C-GLOBAL:" "C-TYPE:" "CHAR:" "COM-INTERFACE:" "CONSTANT:" "CONSULT:" "call-next-method"
"DEFER:" "DESTRUCTOR:" "DEFER:" "DESTRUCTOR:"
"EBNF:" ";EBNF" "ENUM:" "ERROR:" "EXCLUDE:" "EBNF:" ";EBNF" "ENUM:" "ERROR:" "EXCLUDE:"
"f" "FORGET:" "FROM:" "FUNCTION:" "FUNCTION-ALIAS:" "f" "FORGET:" "FROM:" "FUNCTION:" "FUNCTION-ALIAS:"
"GAME:" "GENERIC#" "GENERIC:" "GAME:" "GENERIC#" "GENERIC:"
"GLSL-SHADER:" "GLSL-PROGRAM:" "GLSL-SHADER:" "GLSL-PROGRAM:"
"HELP:" "HEX:" "HOOK:" "HELP:" "HOOK:"
"IN:" "initial:" "INSTANCE:" "INTERSECTION:" "IN:" "initial:" "INSTANCE:" "INTERSECTION:"
"LIBRARY:" "LIBRARY:"
"M:" "M::" "MACRO:" "MACRO::" "MAIN:" "MATH:" "M:" "M::" "MACRO:" "MACRO::" "MAIN:" "MATH:"
"MEMO:" "MEMO:" "METHOD:" "MIXIN:" "MEMO:" "MEMO:" "METHOD:" "MIXIN:"
"NAN:" "NAN:"
"OCT:"
"POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROTOCOL:" "PROVIDE:" "POSTPONE:" "PREDICATE:" "PRIMITIVE:" "PRIVATE>" "PROTOCOL:" "PROVIDE:"
"QUALIFIED-WITH:" "QUALIFIED:" "QUALIFIED-WITH:" "QUALIFIED:"
"read-only" "RENAME:" "REQUIRE:" "REQUIRES:" "read-only" "RENAME:" "REQUIRE:" "REQUIRES:"
@ -129,7 +128,7 @@
'("IN:" "USE:" "FROM:" "EXCLUDE:" "QUALIFIED:" "QUALIFIED-WITH:"))) '("IN:" "USE:" "FROM:" "EXCLUDE:" "QUALIFIED:" "QUALIFIED-WITH:")))
(defconst fuel-syntax--int-constant-def-regex (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 (defconst fuel-syntax--type-definition-regex
(fuel-syntax--second-word-regex (fuel-syntax--second-word-regex
@ -208,12 +207,11 @@
"DEFER:" "DESTRUCTOR:" "DEFER:" "DESTRUCTOR:"
"FORGET:" "FORGET:"
"GAME:" "GENERIC:" "GENERIC#" "GLSL-PROGRAM:" "GAME:" "GENERIC:" "GENERIC#" "GLSL-PROGRAM:"
"HEX:" "HOOK:" "HOOK:"
"IN:" "INSTANCE:" "IN:" "INSTANCE:"
"LIBRARY:" "LIBRARY:"
"MAIN:" "MATH:" "MIXIN:" "MAIN:" "MATH:" "MIXIN:"
"NAN:" "NAN:"
"OCT:"
"POSTPONE:" "PRIVATE>" "<PRIVATE" "POSTPONE:" "PRIVATE>" "<PRIVATE"
"QUALIFIED-WITH:" "QUALIFIED:" "QUALIFIED-WITH:" "QUALIFIED:"
"RENAME:" "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 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 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 region factorComplex start=/\<C{\>/ end=/\<}\>/ contains=@factorReal
syn match factorBinErr /\<BIN:\s\+-\=[01,]*[^01 ]\S*\>/ syn match factorBinErr /\<-\=0b[01,]*[^01 ]\S*\>/
syn match factorBinary /\<BIN:\s\+-\=[01,]\+\>/ syn match factorBinary /\<-\=0b[01,]\+\>/
syn match factorHexErr /\<HEX:\s\+-\=\(,\S*\|\S*,\|[-0-9a-fA-Fp,]*[^-0-9a-fA-Fp, ]\S*\)\>/ syn match factorHexErr /\<-\=0x\(,\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 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 /\<OCT:\s\+-\=\(,\S*\|\S*,\|[0-7,]*[^0-7, ]\S*\)\>/ syn match factorOctErr /\<-\=0o\(,\S*\|\S*,\|[0-7,]*[^0-7, ]\S*\)\>/
syn match factorOctal /\<OCT:\s\+-\=[0-7,]\+\>/ 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 factorNan /\<NAN:\s\+[0-9a-fA-F]\([0-9a-fA-F,]*[0-9a-fA-F]\)\?\>/
syn match factorIn /\<IN:\s\+\S\+\>/ syn match factorIn /\<IN:\s\+\S\+\>/