Permalink
Browse files

permettre de faire des constructeurs qui sont init et generent des __…

…construct()
  • Loading branch information...
1 parent c017ead commit 3f0a8a6b33487cfe7f72bd4878babb6e288dd55e Julien Desrosiers committed Aug 22, 2009
Showing with 35 additions and 7 deletions.
  1. +1 −2 .gitignore
  2. +7 −2 awesomephp.rb
  3. +21 −0 compiled.php
  4. +5 −2 input.aw
  5. +1 −1 lexer.rb
View
@@ -1,4 +1,3 @@
test.rb
yield.rb
-compiled.txt
-compiled.php
+
View
@@ -40,7 +40,11 @@ def classnode(name, body)
def defnode(name, params, body)
@f.write('function ')
- yield name
+ if name=='init'
+ @f.write('__construct')
+ else
+ @f.write(name)
+ end
@f.write('(')
yield params
@f.write("){\n")
@@ -237,7 +241,8 @@ def node(objet)
end
-@f = File.open("compiled.txt", "w")
+@f = File.open("compiled.php", "w")
+@f.write("<?php\n\n")
if objects.instance_of?(Nodes)
objarray = objects.instance_variable_get(:@nodes)
objarray.each do |object|
View
@@ -0,0 +1,21 @@
+<?php
+
+function pass(){
+echo("joie");
+}
+
+class Awesome{
+
+function __construct(){
+pass();
+}
+
+function x(){
+return(2);
+}
+
+}
+
+if (true) {
+$aw = new Awesome("brilliant!",2);
+}
View
@@ -1,9 +1,12 @@
+def pass():
+ echo("joie")
+
class Awesome:
- def initialize(name):
+ def init():
pass()
def x:
- return(2,3,"joy!")
+ return(2)
if true:
aw = Awesome.new("brilliant!",2)
View
@@ -26,7 +26,7 @@ def tokenize(code)
# Matching standard tokens.
#
# Matching if, print, method names, etc.
- if identifier = chunk[/\A([a-z]\w*)/, 1]
+ if identifier = chunk[/\A([_a-z]\w*)/, 1]
# Keywords are special identifiers tagged with their own
# name, 'if' will result in an [:IF, "if"] token
if KEYWORDS.include?(identifier)

0 comments on commit 3f0a8a6

Please sign in to comment.