D, so it happend...

Baas hacker at webmail.co.za
Mon Apr 6 11:31:11 PDT 2009


> No. Just .. no.
> 
> On the off chance that you're serious about that - XML is a data format that encodes tree-like hierarchical information.
> 
> But if your parser isn't already using a tree-like structure internally, you're doing something wrong.
> 
> And if it is, there's absolutely no reason to use XML as some weird sort of intermediary stage.

I've used the "Analysis-Synthesis Model" for the overall design (to "re-invent the wheel" :) ), as I've done lots of times in the past.

The Analysis-Synthesis Model is clearly based on a tree-structure.
- Lexical Analysis
- Parsing/Syntax Analysis
- Semantic Analysis
- Intermediate Code Generator
- Code Optimizer
- Code Generator
Lexical- and Syntax Analysis is handled in a single pass. (just a reminder)

Instead of writing a lot of additional code to work with and to identify the source/tokens, I simply dump all the tokens into a xml format using Regular Expressions search/replace. 
This takes up to 30 passes for completion and, yes, this is where most of the time is used.
>From there on it's straight forward to do any kind of analysis with the code/tokens.
The key is when it gets to the phase of optimization. 
In this case, the compiler (or should I be fair and call it "the converter"), has a complete "engine" behind it which takes care of all the information in a proper manner.
Cutting, moving, merging, passing referenses and occasionally adding additional code is done with ease.
It's already possible at that stage to systematically assign (and measure) a "Unit of Fitness" (Genetic Analysis), if I may call it that, to the individual code blocks.
By measuring the fitness, the converter knows where to focus to improve performance.
After optimization, converting it to HLA obviously opens a Pandora's box of a different kind. You know the rest...

To summarize, optimization is taken care of even before convertion to HLA takes place, and that's why I use xml (it's a matter of preference).

Technically, thats the basic overview of the operation, and yes, I AM SERIOUS ABOUT THIS!

So, be positive... :)




More information about the Digitalmars-d mailing list