--Code Snippet-- Dim x as Integer = 2 Print x I was curious how others have handled this in the past. I have a generic literal node in my syntax tree for...
In an earlier post on 9/21, I asked what information I should store in the symbol table. I made reference to the following key elements: - Name/ID - Type -...
... I have my tokenizer generate different tokens. For each identifier the tokenizer scans, it keeps track of whether certain characters occurred. E.g. int...
... I had intended to post some examples from compilers I've looked at (not having done this seriously myself in a long time) but couldn't remember where to...
... This is a drawback of the lex/yacc style of parsing where you tokenize first with no regard for context and then parse a token stream. An alternative is to...
... What's the problem? That's what you *want*, isn't it? At the end of a procedure you cannot access any variables inside that procedure and you never need...
... Ideally I do want to perform this promotion because I do not want to force the user to handle casting of types within my script language. Thus: Print 4/2...
So basically then the symbol table is used to validate only that the references to variables, functions, constants, and sub-routines that have been encountered...
... What a lovely bit of innuendo. There's nothing quite like nailing one's colours to the mast, hidden inside a brown paper envelope....
Rainer Thonnes
rainer@...
Oct 2, 2004 9:34 pm
426
... Depends how you choose to implement it. You can be 'pure' and not have your parser do any declaration checking, and just create AST nodes with the raw...
Graham - I just decided to take your advice and rewrote my two visitor classes into one class that does both symbol table population and type checking within ...
... The next significant step isn't necessary in your compiler as you do not yet have flow control, and I suspect that if you do have boolean expressions, you...
I decided to use my simple program: dim i as integer = 2 dim j as integer = 3 print 2/i+5; ... Line #2: DIM i AS Integer = 2 ... PUSH 2 PUSHA @i STORE ...
... Peter Robertson invented an intermediate code for multiple target languages many years ago. He made a critical observation which was that an intermediate...
Graham - My goal is bytecode output. Is there anyhing I need to consider with how I handle my addressing? Again I hate asking so many questions, but just ...
... for your basic-like language, with no procedures or nested declarations yet, just do the obvious thing of assigning an offset to the variable. Let's say ...
Hi, does anybody know of a flexible, simple and cross-platform (or at least portable) bytecode and associated VM to deploy to? I originally wanted to use the...
... yet, ... say ... an int ... address ... something ... Since all my data types are 8/16/32 bit values (real is single precision IEEE) couldn't I simply say...
Right now when I encounter a constant declaration in my source, I add a symbol table entry with that name like as follows: const MYVALUE = 2 ConstDecl /...
... yet, ... say ... an int ... address ... something ... Since all my data types are 8/16/32 bit values (real is single precision IEEE) couldn't I simply say...
... Before you start constant expression elimination, but otherwise as late as you want. Doing such substitutions late means you don't discard information ...
... I wrote it in Java. Though I could have written it in C++ just the same. I just thought Java out of a spontaneous thought. I usually hate Java, but it was...
... Don't know Java, can't help. Seems to be a lot of stuff easily findable with Google: http://joeq.sourceforge.net/other_os_java.htm As for other VMs,...
... You might give Parrot a try: http://www.parrotcode.org/ From the webpage: Parrot is a virtual machine designed to execute bytecode for interpreted...
... I haven't done it myself but I might add it to my demo soon just to check my common-sense guess, which is that you use a simple if/then/else node, and...
... My nodes allow any number of children. This works well in a number of cases. IF can be: (IF <expr> <truepart> <falsepart>) Where <falsepart> can be NULL. A...
I think I've got the hang of at least the "parsing" to the abstract syntax tree down pat. My parser now successfully creates an AST for variable declarations,...
... Hmm. Maybe it is a question of approach. I picture my AST as something I process to do something else. One of the side effects of processing my AST is to...
... OK, I'm not getting it here. What exactly is the difficulty? You have an expression like "X = Y + 1" The ast looks like = / \ Var(X) Op(+) / \ Var(Y)...