Geeks With Blogs

News
www.flickr.com
This is a Flickr badge showing public photos from hammett1. Make your own badge here.

hamilton *hammett* verissimo Another special person... just like everyone else

So among one phase and other of Manhunt, I'm improving my brain exercise. Now it's able to deal with boolean expressions. I had to review the AST nodes implementation to allow some tree rewriting.

a = 1 == 1 
b = 1 != 2
x = 10 
puts 3 * 90, a, b, x 

This produces the following initial AST

AssignmentExp
  NameReferenceExpression (a) 
  BinaryExp (....)

AssignmentExp
  NameReferenceExpression (b) 
  BinaryExp (....)

AssignmentExp
  NameReferenceExpression (x) 
  ConstantExp (10, int)

MethodInvocationExp
  Target NameReferenceExpression (puts)
  Arguments
    BinaryExp
    NameReferenceExpression (a) 
    NameReferenceExpression (b) 
    NameReferenceExpression (x) 

So I'm treating the names as some unknown entity that is rewrite as we discover more... The tree gets rewritten to

AssignmentExp
  VarRefExp (a) 
  BinaryExp (....)

AssignmentExp
  VarRefExp (b) 
  BinaryExp (....)

AssignmentExp
  VarRefExp (x) 
  ConstantExp (10, int)

MethodInvocationExp (puts)
  Target null
  Arguments
    BinaryExp
    VarRefExp (a) 
    VarRefExp (b) 
    VarRefExp (x) 

The code, once executed produces:

E:\dev\projects\Blah\BlahProj\bin\Debug>hello
270
True
True
10

Kinda cool. Now I'd like to introduce the dynamics capabilities, meaning: some names should be marked as dynamic, and thus the compiler should not attempt to type it and consequentially more code will be generated in order to perform checks and casts. It's kinda fun, but demands too many types to get something running :-\

Posted on Sunday, February 5, 2006 12:06 AM Programming | Back to top


Comments on this post: Language improvements

# re: Language improvements
Requesting Gravatar...
thank you for article
Left by Firma Rehberi on May 18, 2010 5:49 AM

# re: Language improvements
Requesting Gravatar...
<p>www.hitittuning.com</p>
<p>tuning</p>

Türkiye'nin Tuning Topluluğu
Left by hitittuning on May 23, 2010 10:00 AM

# re: Language improvements
Requesting Gravatar...
thank you very much
Left by oto emlak on Jan 19, 2011 6:06 AM

Your comment:
 (will show your gravatar)


Copyright © hamilton verissimo | Powered by: GeeksWithBlogs.net