All of the code can be found here: 
http://github.com/alex/alex-s-language/tree/master
.  By "render" I meant execute the calculate method on each AST, as
you can see the method takes context, which is a dictionary mapping
names to values.  Than all name lookups occur within that dictionary.
I'm not sure if this is the best approach to name resolution.

Alex

On Oct 14, 2:23 am, "D.Hendriks (Dennis)" <[EMAIL PROTECTED]> wrote:
> Hello Alex,
>
> I'm not sure what you mean with 'render'? Anywhere we can see the code
> you currently have for function declarations and instantiations?
>
> Dennis
>
> Alex_Gaynor wrote:
> >I've made a lot of progress, specifically I've implemented if, elif,
> >and else statements(these were surprisingly easy), and now I've
> >implemented function definitions, which seem to work, the way I
> >implemented it was to render the asts with just the context they are
> >called with, however this prevents even basic things like recursion,
> >so my question, what would be the best way to implement scoping, my
> >goal is to just have global, and local scope.
>
> >On Oct 13, 3:10 pm, Alex_Gaynor <[EMAIL PROTECTED]> wrote:
>
> >>I've rewritten all my parse rules to be way more explicit and it's
> >>working way better now, thanks!  Which features to implement
> >>next... :P
>
> >>On Oct 13, 1:06 pm, Alex_Gaynor <[EMAIL PROTECTED]> wrote:
>
> >>>That type of thing is definately not meant to be allowed, I probably
> >>>need to review/rewrite the parse rules, as you're correct, the
> >>>currrent division of statements and expressions is ambigious at best,
> >>>and it's probably causing lots of problems that won't be obvious.
>
> >>>On Oct 13, 2:56 am, "D.Hendriks (Dennis)" <[EMAIL PROTECTED]> wrote:
>
> >>>>Hello Alex,
>
> >>>> > You could probably have seen this, if you would have called the
> >>>> > parse(...) function with debug=2 parameter. This outputs debugging
> >>>> > information during parsing. It shows the tokens scanned, parser
> >>>> > state, etc.
>
> >>>>This kind of output can still be useful. It gives you insight in what
> >>>>the parser is doing step by step. That, together with the generated
> >>>>parser.out file should give enough information to understand why it
> >>>>doesn't work the way you want it to work...
>
> >>>>One other thing, it looks to me like your syntax allows 'a < b += 5'. Is
> >>>>this what you want? Maybe statements and expressions should be
> >>>>separated completely?
>
> >>>>Dennis
>
> >>>>Alex_Gaynor wrote:
>
> >>>>>I've started to implement ASTs as an intermediate representation,
> >>>>>however I'm having a problem, I'm trying to do run this code:
> >>>>>http://dpaste.com/83715/andgettingthatoutput(the paste has the
> >>>>>code I'm trying to run, the final result of the parse, and the
> >>>>>tokens).  My parse rules are here:
> >>>>>http://github.com/alex/alex-s-language/tree/local%2Fast/alexs_lang/pa...
> >>>>>(you can also see teh asts and token code as well).  The actual code
> >>>>>to  create that output is here:http://dpaste.com/83717/.  I'm a)
> >>>>>unsure of why I'm getting the synax error, it should parse fine, since
> >>>>>assignment is an epxression), and b) I want the result of
> >>>>>parser.parse() to be the complete ASTs, how would I set it up to
> >>>>>return the full tree.
>
> >>>>>On Oct 9, 9:05 am, Alex_Gaynor <[EMAIL PROTECTED]> wrote:
>
> >>>>>>Thanks, that makes sense, not sure how i missed that in the docs.  Now
> >>>>>>I just need to figure out the multiline/if statements.
>
> >>>>>>On Oct 9, 2:12 am, "D.Hendriks (Dennis)" <[EMAIL PROTECTED]> wrote:
>
> >>>>>>>Hello Alex,
>
> >>>>>>>both the t_AND and the t_NAME rule match the string 'and' (without the
> >>>>>>>quotes). Since t_AND was previously a string, and t_NAME a function,
> >>>>>>>t_NAME took precedence (seehttp://www.dabeaz.com/ply/ply.html, section
> >>>>>>>3.3). You now changed them to both be functions. Then the t_AND takes
> >>>>>>>precedence (it is first in the file). Anyway, the same section 3.3
> >>>>>>>explains you should not use rules for and/or etc, but include them in
> >>>>>>>the identifier rule (t_NAME in your case).
>
> >>>>>>>You could probably have seen this, if you would have called the
> >>>>>>>parse(...) function with debug=2 parameter. This outputs debugging
> >>>>>>>information during parsing. It shows the tokens scanned, parser state,
> >>>>>>>etc. You would have seen that it scans a NAME tokens instead of an AND
> >>>>>>>token...
>
> >>>>>>>Good luck,
> >>>>>>>Dennis
>
> >>>>>>>Alex_Gaynor wrote:
>
> >>>>>>>>I was able to fix the 'and' 'or' 'not' issue by turning their
> >>>>>>>>definitions into functions, instead of just strings, not sure why that
> >>>>>>>>fixed it :/
>
> >>>>>>>>On Oct 7, 7:54 pm, Alex_Gaynor <[EMAIL PROTECTED]> wrote:
>
> >>>>>>>>>I was able to succesfully implement True and False by making them
> >>>>>>>>>tokens(I do want them to be reserved ala py3k), so thanks for the 
> >>>>>>>>>help
> >>>>>>>>>with that!  I am also looking over the things on indentation, 
> >>>>>>>>>although
> >>>>>>>>>I suspect that will be something that goes in later.  Right now I am
> >>>>>>>>>having some issue implementing 'and' 'or' and 'not'.  Right now I 
> >>>>>>>>>have
> >>>>>>>>>them implemented the same way I do other unary and binary operators
> >>>>>>>>>which I suspect isn't working.  Right now whenever I try True or
> >>>>>>>>>False, or not True, or True and False I get a syntax error, and I'm
> >>>>>>>>>not sure what causes this.  All my code is 
> >>>>>>>>>here:http://github.com/alex/alex-s-language/tree/master
>
> >>>>>>>>>On Oct 7, 6:59 pm, Bruce Frederiksen <[EMAIL PROTECTED]> wrote:
>
> >>>>>>>>>>If you make True/False tokens, that generally means that they are
> >>>>>>>>>>reserved words in your language.  That means that nobody can use 
> >>>>>>>>>>them
> >>>>>>>>>>for other purposes.
>
> >>>>>>>>>>If you want to let people use the words "True" and "False" for other
> >>>>>>>>>>purposes, then you probably don't want them to be tokens.  In this 
> >>>>>>>>>>case,
> >>>>>>>>>>you will probably end up doing a lookup at runtime, which might find
> >>>>>>>>>>some other value.
>
> >>>>>>>>>>In python 2.5, for example, you can use True and False for other 
> >>>>>>>>>>purposes:
>
> >>>>>>>>>>def False(): print "hi mom!"
>
> >>>>>>>>>>is OK.  But this becomes illegal in python 3.0.
>
> >>>>>>>>>>I've attached a scanner the does indenting ala python (i.e., the
> >>>>>>>>>>programmer can indent any amount so long as they line up).
>
> >>>>>>>>>>-bruce
>
> >>>>>>>>>>Alex_Gaynor wrote:
>
> >>>>>>>>>>>I'm looking to implement a boolean type in my language, where 
> >>>>>>>>>>>exactly
> >>>>>>>>>>>should I do this?  Should I make True and False both be tokens, and
> >>>>>>>>>>>just set t.value = True/False.  Or should the parser handle them?
>
> >>>>>>>>>>>Also, how would I go about implementing a language that uses 
> >>>>>>>>>>>indent/
> >>>>>>>>>>>dedent for blocks(ala python)?
>
> >>>>>>>>>>>Alex
>
> >>>>>>>>>>scanner.py
> >>>>>>>>>>19KViewDownload
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"ply-hack" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/ply-hack?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to