Changeset c5cb943d in mainline for uspace/dist/src
- Timestamp:
- 2010-06-09T19:01:08Z (15 years ago)
- Branches:
- lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 1113c9e
- Parents:
- 051bc69a
- Location:
- uspace/dist/src/sysel
- Files:
-
- 3 added
- 23 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/dist/src/sysel/demos/arith.sy
r051bc69a rc5cb943d 28 28 29 29 class ArithmeticDemo is 30 fun Main() is30 fun Main(), static is 31 31 -- Test addition, multiplication and precedence. 32 32 Builtin.Write("2*2 + 2*2 = "); … … 88 88 89 89 -- Return factorial of n. 90 fun Factorial(n : int) : int is90 fun Factorial(n : int) : int, static is 91 91 var i : int; 92 92 var val : int; -
uspace/dist/src/sysel/demos/array.sy
r051bc69a rc5cb943d 28 28 29 29 class ArrayDemo is 30 fun Main() is30 fun Main(), static is 31 31 var a : int[,]; 32 32 var i : int; -
uspace/dist/src/sysel/demos/autobox.sy
r051bc69a rc5cb943d 28 28 29 29 class AutoboxingDemo is 30 fun Main() is30 fun Main(), static is 31 31 var b : Bool; 32 32 var c : Char; … … 51 51 end 52 52 53 fun foo(args : Object[], packed) is53 fun foo(args : Object[], packed), static is 54 54 end 55 55 end -
uspace/dist/src/sysel/demos/count.sy
r051bc69a rc5cb943d 28 28 29 29 class CountDemo is 30 fun Count(a : int; b : int) is30 fun Count(a : int; b : int), static is 31 31 var i : int; 32 32 … … 39 39 end 40 40 41 fun Main() is41 fun Main(), static is 42 42 Count(0, 10); 43 43 end -
uspace/dist/src/sysel/demos/ctor.sy
r051bc69a rc5cb943d 28 28 29 29 class ConstructorDemo is 30 fun Main() is30 fun Main(), static is 31 31 var a : A; 32 32 -
uspace/dist/src/sysel/demos/deleg.sy
r051bc69a rc5cb943d 28 28 29 29 class DelegateDemo is 30 fun Main() is30 fun Main(), static is 31 31 var demo : DelegateClass; 32 32 -
uspace/dist/src/sysel/demos/enum.sy
r051bc69a rc5cb943d 28 28 29 29 class EnumDemo is 30 fun Main() is30 fun Main(), static is 31 31 var color : ChessColor; 32 32 -
uspace/dist/src/sysel/demos/except.sy
r051bc69a rc5cb943d 28 28 29 29 class ExceptionDemo is 30 fun foo() is30 fun foo(), static is 31 31 Builtin.WriteLine("Entered foo()."); 32 32 raise new BaseException(); 33 33 end 34 34 35 fun Main() is35 fun Main(), static is 36 36 do 37 37 foo(); -
uspace/dist/src/sysel/demos/gen.sy
r051bc69a rc5cb943d 30 30 31 31 class GenericsDemo is 32 fun Main() is32 fun Main(), static is 33 33 Builtin.WriteLine("Let's try some generics."); 34 34 -
uspace/dist/src/sysel/demos/hello.sy
r051bc69a rc5cb943d 28 28 29 29 class HelloWorld is 30 fun Main() is30 fun Main(), static is 31 31 Builtin.WriteLine("Hello world!"); 32 32 end -
uspace/dist/src/sysel/demos/hexec.sy
r051bc69a rc5cb943d 28 28 29 29 class HelenOSExecDemo is 30 fun Main() is30 fun Main(), static is 31 31 Task.Exec("/app/tester"); 32 32 Task.Exec("/app/tester", "print1"); -
uspace/dist/src/sysel/demos/htxtfile.sy
r051bc69a rc5cb943d 28 28 29 29 class TextFileDemo is 30 fun Main() is30 fun Main(), static is 31 31 var name : string; 32 32 var line : string; -
uspace/dist/src/sysel/demos/inherit.sy
r051bc69a rc5cb943d 43 43 44 44 class InheritanceDemo is 45 fun Main() is45 fun Main(), static is 46 46 var a : A; 47 47 var c : C; -
uspace/dist/src/sysel/demos/list.sy
r051bc69a rc5cb943d 29 29 -- Using the List class from the library. 30 30 class ListDemo is 31 fun Main() is31 fun Main(), static is 32 32 var list : List/int; 33 33 … … 39 39 list.Append(8); 40 40 41 var n : ListNode/int;41 var e : IEnumerator/int; 42 42 43 n = list.First; 44 while n != nil do 45 Builtin.WriteLine(n.Data); 46 n = n.Next; 43 e = list.GetEnumerator(); 44 while e.MoveNext() do 45 Builtin.WriteLine(e.Data); 47 46 end 48 47 end -
uspace/dist/src/sysel/demos/map.sy
r051bc69a rc5cb943d 29 29 -- Using the Map class from the library. 30 30 class MapDemo is 31 fun Main() is31 fun Main(), static is 32 32 var map : Map/string/int; 33 33 … … 39 39 map["four"] = 4; 40 40 41 Builtin.WriteLine(map["one"]); 42 Builtin.WriteLine(map["two"]); 43 Builtin.WriteLine(map["three"]); 44 Builtin.WriteLine(map["four"]); 41 var e : IEnumerator/string; 42 43 e = map.GetEnumerator(); 44 while e.MoveNext() do 45 Builtin.Write(e.Data); 46 Builtin.Write(" -> "); 47 Builtin.WriteLine(map[e.Data]); 48 end 45 49 end 46 50 end -
uspace/dist/src/sysel/demos/property.sy
r051bc69a rc5cb943d 98 98 99 99 class PropertyDemo is 100 fun Main() is100 fun Main(), static is 101 101 var a : Foo; 102 102 var i : int; -
uspace/dist/src/sysel/demos/string.sy
r051bc69a rc5cb943d 28 28 29 29 class StringDemo is 30 fun Main() is30 fun Main(), static is 31 31 -- Concatenate some strings. 32 32 Builtin.WriteLine("One-" + "two-" + "three!"); -
uspace/dist/src/sysel/demos/varargs.sy
r051bc69a rc5cb943d 33 33 -- with the attribute 'packed'. 34 34 -- 35 fun Print(args : string[], packed) is35 fun Print(args : string[], packed), static is 36 36 var i : int; 37 37 var error : bool; … … 53 53 end 54 54 55 fun Main() is55 fun Main(), static is 56 56 Print("One", "Two", "Three", "Four", "Five"); 57 57 end -
uspace/dist/src/sysel/lib/arith.sy
r051bc69a rc5cb943d 29 29 class Arith is 30 30 -- Return factorial of n. 31 fun Factorial(n : int) : int is31 fun Factorial(n : int) : int, static is 32 32 var i : int; 33 33 var val : int; -
uspace/dist/src/sysel/lib/boxed.sy
r051bc69a rc5cb943d 38 38 class Char is 39 39 var Value : char; 40 41 fun get_as_string() : string, builtin; 42 43 -- String representation. 44 prop AsString : string is 45 get is 46 return get_as_string(); 47 end 48 end 40 49 end 41 50 42 51 class Int is 43 52 var Value : int; 53 54 fun get_as_string() : string, builtin; 55 56 -- String representation. 57 prop AsString : string is 58 get is 59 return get_as_string(); 60 end 61 end 44 62 end 45 63 -
uspace/dist/src/sysel/lib/libflist
r051bc69a rc5cb943d 1 1 arith.sy 2 2 boxed.sy 3 ienum.sy 3 4 list.sy 4 5 map.sy -
uspace/dist/src/sysel/lib/list.sy
r051bc69a rc5cb943d 28 28 29 29 -- Doubly-linked list. 30 class List/t is30 class List/t : IEnumerable/t is 31 31 var head : ListNode/t; 32 32 … … 59 59 prop First : ListNode/t is 60 60 get is 61 61 return get_first(); 62 62 end 63 end 64 65 -- Return first node in the list or @c nil if there is none. 66 fun GetEnumerator() : IEnumerator/t is 67 return new ListEnumerator/t(get_first()); 63 68 end 64 69 … … 131 136 end 132 137 end 138 end 133 139 140 class ListEnumerator/t : IEnumerator/t is 141 var first : ListNode/t; 142 var current : ListNode/t; 143 var started : bool; 144 145 new(first_node : ListNode/t) is 146 first = first_node; 147 current = nil; 148 started = false; 149 end 150 151 fun MoveNext() : bool is 152 if started then 153 current = current.Next; 154 else 155 current = first; 156 started = true; 157 end 158 159 return current != nil; 160 end 161 162 prop Data : t is 163 get is 164 return current.Data; 165 end 166 end 134 167 end -
uspace/dist/src/sysel/lib/map.sy
r051bc69a rc5cb943d 91 91 end 92 92 end 93 94 fun GetEnumerator() : IEnumerator/tkey is 95 return new MapEnumerator/tkey/tvalue(data.get_first()); 96 end 93 97 end 94 98 … … 97 101 var Value : tvalue; 98 102 end 103 104 class MapEnumerator/tkey/tvalue : IEnumerator/tkey is 105 var first : ListNode/(MapPair/tkey/tvalue); 106 var current : ListNode/(MapPair/tkey/tvalue); 107 var started : bool; 108 109 new(first_node : ListNode/(MapPair/tkey/tvalue)) is 110 first = first_node; 111 current = nil; 112 started = false; 113 end 114 115 fun MoveNext() : bool is 116 if started then 117 current = current.Next; 118 else 119 current = first; 120 started = true; 121 end 122 123 return current != nil; 124 end 125 126 prop Data : tkey is 127 get is 128 return current.Data.Key; 129 end 130 end 131 end
Note:
See TracChangeset
for help on using the changeset viewer.