移転 -> http://sru.ikejima.org
SRU1 -> http://sru.ikejisoft.com
SRU2についてつらつら書く
* 目標
何ごとも目標が重要だよね。
次のコードが実行できるのが目標という事で一つ
<@code>
usesyntax "sruthon"
class Jewel:
def hello(self):
console.WriteLine("hello, from " + self.lang() + " like syntax")
class Python(Jewel):
def lang(self):
"python"
endsyntax
class Ruby < Jewel
def lang()
"Ruby"
end
end
Python.new().hello()
Ruby.new().hello()
</@>
Pythonのマニュアルを調べながら書いた。
<@code>
a = /.*/ # => Error
</@>
<@code>
require 'regex'
a = /.*/ # => Regex object
</@>
<@code>
if ""
puts("Zero length string is true")
end
String.instance_fields.if_true = {|self| (self != "").if_true }
if ""
puts("Zero length string is true")
else
puts("Zero length string is false")
end
</@>
<@code>
require "precondition"
def proc(a>0,b<100)
console.WriteLine(a+b)
end
a(-3,101) # => Error
</@>
<@code>
# {|oldexpression|
# yuno = "X / _ / X < 来週も見てくださいね!"
# mite = "ひだまりスケッチ×365 来週も見てくださいね!"
# Interpriter.expression = {|str,start|
# if(str.substring(start,start + yuno.size) == yuno)
# return (true,CallExpression.new(RefExpression.new(nil,"puts"),
# ConstString.new(mite)))
# else
# return oldexpression
# end
# end
# }(Interpriter.expression)
defsyntax expression("X / _ / X < 来週も見てくださいね!")
Interpriter.parse("puts 'ひだまりスケッチ×365 来週も見てくださいね!'")
end
X / _ / X < 来週も見てくださいね!
</@>
* もくじ
<@graph>
digraph G {
SRU -> "SRU VM" -> "SRU IL"
SRU -> "SRU Interpriter"
SRU -> "SRU Lib"
"SRU Interpriter" -> "SRU NativeInterpriter"
"SRU NativeInterpriter" -> "SRU PrimitiveInterpriter"
"SRU NativeInterpriter" -> "SRU BasicInterpriter"
"SRU Interpriter" -> "SRU ExpansionInterpriter"
"SRU Lib" -> Object
Object -> Nil
Object -> Bool
Bool -> True
Bool -> False
Object -> Proc
Object -> Console
Object -> Integer
Object -> Float
Object -> Math
Object -> Hash
Object -> Array
Object -> String
}