version 1.2, 2002/04/30 20:12:36
|
version 1.9, 2005/10/02 11:30:32
|
Line 1
|
Line 1
|
\ quote: S\" and .\" words |
\ quote: S\" and .\" words |
|
|
\ Copyright (C) 2002 Free Software Foundation, Inc. |
\ Copyright (C) 2002,2003 Free Software Foundation, Inc. |
|
|
\ This file is part of Gforth. |
\ This file is part of Gforth. |
|
|
Line 33
|
Line 33
|
create \-escape-table |
create \-escape-table |
7 c, 8 c, char c c, char d c, 27 c, 12 c, char g c, |
7 c, 8 c, char c c, char d c, 27 c, 12 c, char g c, |
char h c, char i c, char j c, char k c, char l c, char m c, 10 c, |
char h c, char i c, char j c, char k c, char l c, char m c, 10 c, |
char o c, char p c, char q c, 13 c, char s c, 8 c, char u c, |
char o c, char p c, char " c, 13 c, char s c, 9 c, char u c, |
11 c, |
11 c, |
|
|
: \-escape ( c-addr1 -- c-addr2 c ) |
: \-escape ( c-addr1 -- c-addr2 c ) |
Line 59 char o c, char p c, char q c, 13
|
Line 59 char o c, char p c, char q c, 13
|
endif |
endif |
1 chars under+ ; |
1 chars under+ ; |
|
|
: \"-parse ( "string"<"> -- c-addr u ) |
: \"-parse ( "string"<"> -- c-addr u ) \ gforth backslash-quote-parse |
\G parses string, translating @code{\}-escapes to characters (as in |
\G parses string, translating @code{\}-escapes to characters (as in |
\G C). The resulting string resides at @code{here char+}. The |
\G C). The resulting string resides at @code{here char+}. The |
\G supported @code{\-escapes} are: @code{\a} BEL (alert), @code{\b} |
\G supported @code{\-escapes} are: @code{\a} BEL (alert), @code{\b} |
Line 68 char o c, char p c, char q c, 13
|
Line 68 char o c, char p c, char q c, 13
|
\G @code{\}[0-7]+ octal numerical character value, @code{\x}[0-9a-f]+ |
\G @code{\}[0-7]+ octal numerical character value, @code{\x}[0-9a-f]+ |
\G hex numerical character value; a @code{\} before any other |
\G hex numerical character value; a @code{\} before any other |
\G character represents that character (only ', \, ? in C99). |
\G character represents that character (only ', \, ? in C99). |
here >r 0 c, |
here >r |
>in @ chars source chars over + >r + begin ( parse-area R: here parse-end ) |
>in @ chars source chars over + >r + begin ( parse-area R: here parse-end ) |
dup r@ < while |
dup r@ < while |
dup c@ [char] " <> while |
dup c@ [char] " <> while |
Line 82 char o c, char p c, char q c, 13
|
Line 82 char o c, char p c, char q c, 13
|
char+ source >r - r> min char/ >in ! |
char+ source >r - r> min char/ >in ! |
r> drop |
r> drop |
here r> - dup negate allot |
here r> - dup negate allot |
here swap char/ 1 /string ; |
here swap char/ ; |
|
|
:noname \"-parse save-mem ; |
:noname \"-parse save-mem ; |
:noname postpone (s") \"-parse dup c, 1+ chars allot drop ; |
:noname \"-parse save-mem 2dup postpone sliteral drop free throw ; |
interpret/compile: s\" ( compilation 'ccc"' -- ; run-time -- c-addr u ) \ gforth s-backslash-quote |
interpret/compile: s\" ( compilation 'ccc"' -- ; run-time -- c-addr u ) \ gforth s-backslash-quote |
\G Like @code{S"}, but translates C-like \-escape-sequences into |
\G Like @code{S"}, but translates C-like \-escape-sequences into |
\G single characters. See @code{\"-parse} for details. |
\G single characters. See @code{\"-parse} for details. |
|
|
:noname \"-parse type ; |
:noname \"-parse type ; |
:noname postpone (.") \"-parse dup c, 1+ chars allot drop ; |
:noname postpone s\" postpone type ; |
interpret/compile: .\" ( compilation 'ccc"' -- ; run-time -- ) \ gforth dot-backslash-quote |
interpret/compile: .\" ( compilation 'ccc"' -- ; run-time -- ) \ gforth dot-backslash-quote |
|
|
1 [if] \ test |
0 [if] \ test |
s" 123" drop 10 parse-num-x 123 <> throw drop .s |
s" 123" drop 10 parse-num-x 123 <> throw drop .s |
s" 123a" drop 10 parse-num 123 <> throw drop .s |
s" 123a" drop 10 parse-num 123 <> throw drop .s |
s" x1fg" drop \-escape 31 <> throw drop .s |
s" x1fg" drop \-escape 31 <> throw drop .s |
s" 00129" drop \-escape 10 <> throw drop .s |
s" 00129" drop \-escape 10 <> throw drop .s |
s" a" drop \-escape 7 <> throw drop .s |
s" a" drop \-escape 7 <> throw drop .s |
\"-parse " s" " compare 0<> throw .s |
\"-parse " s" " str= 0= throw .s |
\"-parse \a\b\c\e\f\n\r\t\v\100\x40xabcde" dump |
\"-parse \a\b\c\e\f\n\r\t\v\100\x40xabcde" dump |
s\" \a\bcd\e\fghijklm\12opq\rs\tu\v" \-escape-table over compare 0<> throw |
s\" \a\bcd\e\fghijklm\12op\"\rs\tu\v" \-escape-table over str= 0= throw |
s\" \w\0101\x041\"\\" name wAA"\ compare 0<> throw |
s\" \w\0101\x041\"\\" name wAA"\ str= 0= throw |
s\" s\\\" \\" ' evaluate catch 0= throw |
s\" s\\\" \\" ' evaluate catch 0= throw |
[endif] |
[endif] |