Commit 4ed104771b3a06c4fc7a1d84b26df7e6686b2770
1 parent
8d65866e
*** empty log message ***
Showing
2 changed files
with
42 additions
and
1 deletions
Show diff stats
anubis_dev/library/tools/streams.anubis
| ... | ... | @@ -53,7 +53,7 @@ public define List(StreamCapability) get_capabilities(Stream s). |
| 53 | 53 | |
| 54 | 54 | *** Reading from a stream. |
| 55 | 55 | |
| 56 | -public define Maybe(Word8) read_byte (Stream s). | |
| 56 | +public define Maybe(Word8) read_byte (Stream s). | |
| 57 | 57 | public define Maybe(String) read_line (Stream s). |
| 58 | 58 | public define One skip_blanks (Stream s). |
| 59 | 59 | public define Maybe(String) read_symbol (Stream s). |
| ... | ... | @@ -103,6 +103,7 @@ public define One unput_byte (Word8 c, Stream s). |
| 103 | 103 | public define Int32 current_offset (Stream s). |
| 104 | 104 | public define Int32 current_line (Stream s). |
| 105 | 105 | public define Int32 current_column (Stream s). |
| 106 | + public define Bool at_end_of_input (Stream s). | |
| 106 | 107 | |
| 107 | 108 | 'current_offset' returns the number of bytes read so far. |
| 108 | 109 | ... | ... |
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + Transforming a list of Word8 into a list of Word32. | |
| 6 | + | |
| 7 | +define List(Word32) | |
| 8 | + to_list_word32 | |
| 9 | + ( | |
| 10 | + List(Word8) l | |
| 11 | + ) = | |
| 12 | + if l is | |
| 13 | + { | |
| 14 | + [ ] then [ ], | |
| 15 | + [a1 . t1] then if t1 is | |
| 16 | + { | |
| 17 | + [ ] then [word32(word16(0,0),word16(0,a1))], | |
| 18 | + [a2 . t2] then if t2 is | |
| 19 | + { | |
| 20 | + [ ] then [word32(word16(0,0),word16(a2,a1))], | |
| 21 | + [a3 . t3] then if t3 is | |
| 22 | + { | |
| 23 | + [ ] then [word32(word16(0,a3),word16(a2,a1))], | |
| 24 | + [a4 . t4] then [word32(word16(a4,a3),word16(a2,a1)) . to_list_word32(t4)] | |
| 25 | + } | |
| 26 | + } | |
| 27 | + } | |
| 28 | + }. | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | +public define Nat | |
| 33 | + to_Nat | |
| 34 | + ( | |
| 35 | + List(Word8) l | |
| 36 | + ) = | |
| 37 | + to_Nat(to_list_word32(l)). | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 0 | 41 | \ No newline at end of file | ... | ... |