parser mit exceptions erweitert. praesentation darauf angepasst. aufzaehlungen leider nicht mehr moeglich :( zwischenseiten eingefuegt

master
Denis Knauf 2011-01-21 14:47:27 +01:00
parent 56c877b689
commit f6f851b650
2 changed files with 94 additions and 100 deletions

View File

@ -150,19 +150,24 @@ ptype-reset
: beep 0 term-height 2 - cursor! 7 emit s" *beep* not" type ; : beep 0 term-height 2 - cursor! 7 emit s" *beep* not" type ;
variable ok-
: block? ok- @ 0= throw ;
: block! ( i -- ) ok- dup @ throw ! ;
: !block ( i -- ) ok- @ <> throw 0 ok- ! ;
\ Es folgen ein paar syntaktische Textauszeichnungen. \ Es folgen ein paar syntaktische Textauszeichnungen.
: {i} ( addr -- addr ) 7 sgr ; : {i} ( addr -- addr ) 7 sgr ;
: <i> ( -- ) ['] {i} , ; : <i> ( -- ) block? ['] {i} , ;
: {/i} ( addr -- addr ) 27 sgr ; : {/i} ( addr -- addr ) 27 sgr ;
: </i> ( -- ) ['] {/i} , ; : </i> ( -- ) block? ['] {/i} , ;
: {b} ( addr -- addr ) 1 sgr ; \ bold : {b} ( addr -- addr ) 1 sgr ; \ bold
: <b> ( -- ) ['] {b} , ; : <b> ( -- ) block? ['] {b} , ;
: {/b} ( addr -- addr ) 22 sgr ; : {/b} ( addr -- addr ) 22 sgr ;
: </b> ( -- ) ['] {/b} , ; : </b> ( -- ) block? ['] {/b} , ;
: {u} ( addr -- addr ) 4 sgr ; \ underline : {u} ( addr -- addr ) 4 sgr ; \ underline
: <u> ( -- ) ['] {u} , ; : <u> ( -- ) block? ['] {u} , ;
: {/u} ( addr -- addr ) 24 sgr ; : {/u} ( addr -- addr ) 24 sgr ;
: </u> ( -- ) ['] {/u} , ; : </u> ( -- ) block? ['] {/u} , ;
: {fc} ( addr -- addr ) dup @ 30 + sgr cell+ ; \ frontcolor : {fc} ( addr -- addr ) dup @ 30 + sgr cell+ ; \ frontcolor
: <fc> ( -- ) ['] {fc} , , ; : <fc> ( -- ) ['] {fc} , , ;
: {/fc} ( addr -- addr ) 39 sgr ; : {/fc} ( addr -- addr ) 39 sgr ;
@ -188,7 +193,7 @@ ptype-reset
dup ptype-curx ! cursor> dup ptype-curx ! cursor>
cell+ {b} cell+ {b}
; \ header ; \ header
: <h> ( -- addr 0 , xt-{h} 0 ) ['] {h} , here 0 , 0 ; : <h> ( -- addr 0 , xt-{h} 0 ) [char] h block! ['] {h} , here 0 , 0 ;
: {/h} ( addr , len -- addr1 ) : {/h} ( addr , len -- addr1 )
{/b} cursorx@ 1+ \ addr x {/b} cursorx@ 1+ \ addr x
cr cr
@ -197,19 +202,19 @@ ptype-reset
cursorx@ +do ." =" loop \ addr cursorx@ +do ." =" loop \ addr
cr cell+ cr cell+
; ;
: </h> ( addr len -- , xt-{/h} len0 ) ['] {/h} , dup , swap ! ; : </h> ( addr len -- , xt-{/h} len0 ) ['] {/h} , dup , swap ! [char] h !block ;
: {p} ( addr -- addr ) cr ptype-reset cell+ ; \ paragraph : {p} ( addr -- addr ) cr ptype-reset cell+ ; \ paragraph
: <p> ( -- addr u0 , xt-{p} 0 ) ['] {p} , here 0 , 0 ; : <p> ( -- addr u0 , xt-{p} 0 ) [char] p block! ['] {p} , here 0 , 0 ;
: {/p} ( addr -- addr ) cr ; : {/p} ( addr -- addr ) cr ;
: </p> ( addr len -- , xt-{/p} ) ['] {/p} , swap ! ; : </p> ( addr len -- , xt-{/p} ) ['] {/p} , swap ! [char] p !block ;
: {li} ( addr -- addr ) : {li} ( addr -- addr )
2 cursor> space 1 cursor> 2 cursor> 32 sgr ." *" 39 sgr
6 dup ptype-indent ! ptype-curx ! 4 ptype-indent ! 3 ptype-curx !
cell+ cell+
; ;
: <li> ( -- addr u0 , xt-{li} 0 ) ['] {li} , here 0 , 0 ; : <li> ( -- addr u0 , xt-{li} 0 ) [char] l block! ['] {li} , here 0 , 0 ;
: {/li} ( addr -- addr ) cr ; : {/li} ( addr -- addr ) cr ;
: </li> ( addr len -- , xt-{/li} ) ['] {/li} , swap ! ; : </li> ( addr len -- , xt-{/li} ) ['] {/li} , swap ! [char] l !block ;
33 constant table-color 33 constant table-color
: {|} ( addr -- addr ) : {|} ( addr -- addr )
dup @ dup ptype-cursorx@ - \ addr > >-i dup @ dup ptype-cursorx@ - \ addr > >-i
@ -220,27 +225,28 @@ ptype-reset
endif endif
ptype-curx ! table-color sgr ." |" 39 sgr cell+ ptype-curx ! table-color sgr ." |" 39 sgr cell+
; ;
: <|> ( i -- addr , xt-{|} i ) ['] {|} , , ; : <|> ( i -- addr , xt-{|} i ) block? ['] {|} , , ;
: {-} ( addr -- addr ) cr dup @ 0 table-color sgr +do [char] - emit loop 39 sgr cell+ cr ; : {-} ( addr -- addr ) cr dup @ 0 table-color sgr +do [char] - emit loop 39 sgr cell+ cr ;
: <-> ( i -- addr , xt-{-} i ) ['] {-} , , ; : <-> ( i -- addr , xt-{-} i ) block? ['] {-} , , ;
variable enumerationCount ( -- addr ) variable enumerationCount ( -- addr )
: {||} ( addr -- addr ) \ increments enumeration count and prints prefix : {||} ( addr -- addr ) \ increments enumeration count and prints prefix
enumerationCount dup @ 1+ dup rot ! enumerationCount dup @ 1+ dup rot !
2 cursor> 0 u.r ." ." 1 cursor> 2 cursor> 0 u.r ." ." space
6 dup ptype-indent ! ptype-curx ! 5 ptype-curx !
; ;
: <||> ( -- , xt-{||} 0 ) ['] {||} , ; : <||> ( -- , xt-{||} ) [char] e ok- @ <> throw ['] {||} , ;
: {/||} ( addr -- addr ) cr ; : {/||} ( -- ) cr ;
: </||> ( -- , xt-{/||} ) ['] {/||} , ; : </||> ( -- , xt-{/||} ) ['] {/||} , ; \ [char] e ok- @ 2dup emit emit <> throw ;
: {en} ( -- ) : {en} ( -- )
cr
5 ptype-indent ! \ 6 Zeichen weit einruecken 5 ptype-indent ! \ 6 Zeichen weit einruecken
0 enumerationCount ! \ resets enumeration count 0 enumerationCount ! \ resets enumeration count
; ;
: <en> ( -- , xt-{en} ) ['] {en} , ; : <en> ( -- , xt-{en} ) [char] e block! ['] {en} , ;
: {/en} ( -- ) ptype-reset ; : {/en} ( -- ) ptype-reset ;
: </en> ( -- , xt-{/en} ) ['] {en} , ; : </en> ( -- , xt-{/en} ) ['] {en} , [char] e !block ;
256 Constant max-line 256 Constant max-line
Create line-buffer max-line 2 + allot Create line-buffer max-line 2 + allot
@ -250,9 +256,7 @@ Create line-buffer max-line 2 + allot
: printsource ( from to addr u 1/0 -- ) : printsource ( from to addr u 1/0 -- )
{ showLines } { showLines }
open-input open-input cr 0
cr
0
begin begin
1+ line-buffer max-line fd-in read-line throw 1+ line-buffer max-line fd-in read-line throw
while while
@ -263,7 +267,7 @@ Create line-buffer max-line 2 + allot
dup ptype-curx ! 1- \ i str l l indent dup ptype-curx ! 1- \ i str l l indent
swap - dup 0< if drop else cursor> then \ i str l swap - dup 0< if drop else cursor> then \ i str l
showLines if showLines if
type ." |" \ ... i \ Eingerueckt Zahl ausgeben 33 sgr type ." |" 39 sgr \ ... i \ Eingerueckt Zahl ausgeben
else 2drop \ Eingerueckt keine Zahl ausgeben else 2drop \ Eingerueckt keine Zahl ausgeben
endif endif
swap line-buffer swap ptype cr swap line-buffer swap ptype cr
@ -282,27 +286,26 @@ Create line-buffer max-line 2 + allot
2dup > if swap then \ addr namelen start/end end/start 2dup > if swap then \ addr namelen start/end end/start
showLines if dup 0 <# #s #> nip else 0 then ptype-reset 1+ ptype-indent ! showLines if dup 0 <# #s #> nip else 0 then ptype-reset 1+ ptype-indent !
2swap \ start end addr namelen 2swap \ start end addr namelen
showLines printsource cr showLines printsource
; ;
: {source} ( -- ) ; : {source} ( -- ) dup dup dup dup @ swap cell + @ 2swap cell 2 * +
: <source> ( -- , xt-{source} ) ['] {source} , ; @ swap cell 3 * + @ 1 printCodeHeader 4 cells + ptype-reset ;
: {/source} ( -- ) dup dup dup dup @ swap cell + @ 2swap cell 2 * + : <source> ( addr len from to -- , xt-{source} ) ['] {source} , , , , , ;
@ swap cell 3 * + @ 1 printCodeHeader 4 cells + ;
: </source> ( -- , xt-{/source} ) ['] {/source} , , , , , ;
: {file} ( -- ) ; : {file} ( -- ) dup dup dup dup @ swap cell + @ 2swap cell 2 * +
: <file> ( -- , xt-{file} ) ['] {file} , ; @ swap cell 3 * + @ 0 printCodeHeader 4 cells + ptype-reset ;
: {/file} ( -- ) dup dup dup dup @ swap cell + @ 2swap cell 2 * + : <file> ( addr len from to -- , xt-{file} ) ['] {file} , , , , , ;
@ swap cell 3 * + @ 0 printCodeHeader 4 cells + ;
: </file> ( -- , xt-{/file} ) ['] {/file} , , , , , ;
: {np} ( -- ) : {np} ( -- )
0 sgr \ Alle Bildschirmeigenschaften zuruecksetzen 0 sgr \ Alle Bildschirmeigenschaften zuruecksetzen
page \ Bildschirm leeren page \ Bildschirm leeren
; ;
variable np-sign
0 np-sign !
: {/np} ( -- ) : {/np} ( -- )
\ 30 sgr 40 sgr \ 30 sgr 40 sgr
np-sign @ dup if execute 0 np-sign ! else drop then
0 term-height dup cursory@ - 2 / dup 0< if drop else screen_ then 2 - cursor! 0 term-height dup cursory@ - 2 / dup 0< if drop else screen_ then 2 - cursor!
; ;
: <np> ( -- addr , xt-{/np} xt-{np} ) : <np> ( -- addr , xt-{/np} xt-{np} )
@ -385,6 +388,10 @@ variable pres-restore 3 cells allot
0 0
; ;
variable psee_
: psee' 20 0 +do [char] - emit loop cr psee_ @ xt-see ;
: psee ['] psee' np-sign ! ' psee_ ! u ;
: <presentation> ( -- addr0 0 addr1 , xt-{np} ) here 0 here ['] {np} , ; : <presentation> ( -- addr0 0 addr1 , xt-{np} ) here 0 here ['] {np} , ;
: </presentation> ( 0 <addr...> -- faddr laddr paddr 0 !! endaddr 0 0 0 0 <...addr> ) : </presentation> ( 0 <addr...> -- faddr laddr paddr 0 !! endaddr 0 0 0 0 <...addr> )
<np> <np>

View File

@ -46,32 +46,27 @@
71 <-> 71 <->
1 <|> !" Speicheraufbau" 18 <|> s\" {p} 5 {i} {!!} addr len {/i} {/p} " !! 56 <|> s\" here-\"stack\"" !! 71 <|> 1 <|> !" Speicheraufbau" 18 <|> s\" {p} 5 {i} {!!} addr len {/i} {/p} " !! 56 <|> s\" here-\"stack\"" !! 71 <|>
<br> <br>
1 <|> <b> a b </b> !! 18 <|> <b> c d !! </b> 56 <|> 71 <|> 1 <|> a b <b> !! </b> 18 <|> c d <b> !! </b> 56 <|> 71 <|>
71 <-> 71 <->
</p> </p>
; ;
<presentation> <presentation>
<p> <p> s" header.txt" 0 100 <file> </p>
<file> s" header.txt" 0 100 </file>
<br>
\ <b> !" Denis Knauf & Harald Steinlechner" </b>
</p>
<np> <np>
<h> !" Präsentationssoftware in Forth" </h> <h> !" Präsentationssoftware in Forth -- <sprache> </sprache>" </h>
<p> <p>
<br>
<br>
!" Die flexible Forth-Syntax erlaubt die deklarative Representation von formatierten Text in Forth." !" Die flexible Forth-Syntax erlaubt die deklarative Representation von formatierten Text in Forth."
<br> </p>
<p>
!" Die Präsentation selbst sowie ihre Seiten werden mittels <html> artigen Tags implementiert." !" Die Präsentation selbst sowie ihre Seiten werden mittels <html> artigen Tags implementiert."
</p> </p>
<np> <np>
<h> !" Grundstruktur " </h> <h> !" Grundstruktur " </h>
<p> <source> s" example.p.fs" 0 100 </source> </p> <p> s" example.p.fs" 0 100 <source> </p>
<np> <np>
<h> !" Grundstruktur " </h> <h> !" Grundstruktur " </h>
<p> <source> s" example.p.fs" 0 100 </source> </p> <p> s" example.p.fs" 0 100 <source> </p>
<h> !" Ergebnis" </h> <h> !" Ergebnis" </h>
<h> !" Dies ist eine Testpraesentation!" </h> <h> !" Dies ist eine Testpraesentation!" </h>
<p> <p>
@ -80,35 +75,37 @@
</p> </p>
( <np> ( <np>
<h> !" Mit den wichtigsten Wörtern:" </h> <h> !" Mit den wichtigsten Wörtern:" </h>
<p> <li> <f> !" <presentation>" </f> !" : damit beginnt die praesentation" </li>
<li> <f> !" <presentation>" </f> !" : damit beginnt die praesentation" </li> <li> <f> !" <h>" </f> !" : Eine Ueberschrift" </li>
<li> <f> !" <h>" </f> !" : Eine Ueberschrift" </li> <li> <f> !" <p>" </f> !" : Ein Paragraph" </li>
<li> <f> !" <p>" </f> !" : Ein Paragraph" </li> <li> <f> !" <b>" </f> !" : Fettdruck" </li>
<li> <f> !" <b>" </f> !" : Fettdruck" </li> <li> <f> !" <br>" </f> !" : Zeilenumbruch" </li>
<li> <f> !" <br>" </f> !" : Zeilenumbruch" </li> <li> <f> !\" !\"" </f> !" : Ein String" </li>
<li> <f> !\" !\"" </f> !" : Ein String" </li> )
</p> )
<np> <np>
<h> !" Benutzer Interaktion" </h> <h> !" Benutzerinteraktion" </h>
<p> <p> !" Präsentation liegt im Speicher." </p>
!" Die Präsentation liegt im Speicher" <p> !" eigener Interpreter (showpage, executiontokens)" </p>
</p> <p> !" ==> Dadurch wird die Navigation über Forth Wörter möglich." </p>
<p> <br>
!" ==> Dadurch wird die Navigation über Forth Wörter möglich."
</p>
<li> !" n => nächste Seite" </li> <li> !" n => nächste Seite" </li>
<li> !" p => vorige Seite" </li> <li> !" p => vorige Seite" </li>
<li> !" u => seite aktualisieren" </li> <li> !" u => seite aktualisieren" </li>
<li> !" 3 g => Zur dritten Seite springen" </li> <li> !" 3 g => Zur dritten Seite springen" </li>
<li> !" 3 n => 3 Seiten vor springen" </li> <li> !" 3 n => 3 Seiten vor springen" </li>
<np>
<p>
<b> !" Features" </b>
<br>
!" Features"
</p>
<np> p4-1 <np> p4-1
<np> p4-1 p4-2 <np> p4-1 p4-2
<np> p4-1 p4-2 p4-3 <np> p4-1 p4-2 p4-3
<np> p4-1 p4-2 p4-3 <np> p4-1 p4-2 p4-3
<p> !" Eine neue Seite definieren: " <f> !" <np>" </f> </li> <p> !" Eine neue Seite definieren: " <f> !" <np>" </f> </p>
<np> <np>
<h> !" Und Farben" </h> <h> !" Und Farben" </h>
<br>
<li> !" Hintergrundfarbe: " <f> s\" Yellow <bc> !\" text\" </bc> " !! </f> !" : " Yellow <bc> !\" text" </bc> </li> <li> !" Hintergrundfarbe: " <f> s\" Yellow <bc> !\" text\" </bc> " !! </f> !" : " Yellow <bc> !\" text" </bc> </li>
<li> !" Vordergrundfarbe: " <f> s\" Brown <fc> !\" text\" </fc> " !! </f> !" : " Brown <fc> !\" text" </fc> </li> <li> !" Vordergrundfarbe: " <f> s\" Brown <fc> !\" text\" </fc> " !! </f> !" : " Brown <fc> !\" text" </fc> </li>
<p> !" 8 Farben sind moeglich:" </p> <p> !" 8 Farben sind moeglich:" </p>
@ -160,41 +157,31 @@
<np> s" Execute" s" ^" interner-ablauf <np> s" Execute" s" ^" interner-ablauf
<np> <np>
<p> <h> !" Zeit für Makros!!" </h>
<h> !" Zeit für Makros!!" </h> <p> s" presentation.p.fs" 29 39 <source> </p>
<source> s" presentation.p.fs" 29 39 </source> <p> farbendemo </p>
<p> farbendemo </p>
</p>
<np> <np>
<p> <h> !" Beliebige Wörter können Inhalte erzeugen!!" </h>
<h> !" Beliebige Wörter können Inhalte erzeugen!!" </h> ( <p> <b> !" So kann man Aufzaehlungen erstellen" </b> </p>
<br> <br> <en>
<b> !" So kann man Aufzaehlungen erstellen" </b> <||> !" Das erstellen von Präsentationen und Formatierungen wirkt natürlich" </||>
<br> <br> <||> !" Unsere Sprache erbt die gesamte Funktionalität von Forth persönlich. " </||>
<en> <||> !" Makros generieren Inhalte" </||>
<||> !" Das erstellen von Präsentationen und Formatierungen wirkt natürlich" </||> </en> )
<||> !" Unsere Sprache erbt die gesamte Funktionalität von Forth persönlich. " </||> <p> s" presentation.p.fs" 112 116 <source> </p>
<||> !" Makros generieren Inhalte" </||> <p> !" Die Operatoren sehen so aus:" </p>
</en> <p> s" presentation.fs" 214 221 <source> </p>
<source> s" presentation.p.fs" 112 116 </source>
<br> !" Die Operatoren sehen so aus:" <br>
<source> s" presentation.fs" 214 221 </source>
</p>
<np> <np>
<p> <tw> <h> !" Spezielle (verwendete) Features von Forth" </h>
<h> !" Spezielle (verwendete) Features von Forth" </h> <br>
<br> <br> <li> !" Compiler VS Interpreter" </li>
<li> !" * Compiler VS Interpreter" </li> <li> !" Execution Tokens" </li>
<li> !" * Execution Tokens" </li> <li> !" Here, ," </li>
<li> !" * Here , ," </li> <li> !" Makros" </li>
<li> !" * Makros" </li> <li> !" Exception (beim Parsen)" </li>
</tw> </p>
<np> <np>
<p> <p>
<file> s" nochFragen.txt" 0 100 </file> s" nochFragen.txt" 0 100 <file>
<tw> <b> <tw> !" denis.knauf@gmail.com | haraldsteinlechner@gmail.com" </tw> </b>
<b> !" denis.knauf@gmail.com | haraldsteinlechner@gmail.com" </b>
</tw>
</p> </p>
</presentation> </presentation>