On Tue, Oct 20, 2009 at 12:00:57AM -0400, Brian Padalino wrote:
> To familiarize myself with the GHDL source code, I've decided to use
> the source as a library and try to perform some of my own analysis of
> parsed VHDL files.
> 
> I want to:
>   1) parse a VHDL file and check for syntax errors
>   2) if successful, walk the parsed design units / context clauses
>   3) output the filename and line/column at which design units /
> context clauses are declared
> 
> So far I am at a loss on how to even supply a filename to start to parse.
> 
> I saw libraries.ads has a Load_File( File_Name : Name_Id ) function,
> but Name_Id is just a natural number (0..Int32'last).
> 
> Is there a general initialization I need to do beforehand?  More
> functions I need to call which end up calling that?

Hi,

you'd better to look at how the 'ghdl -s' command is implemented.
See in ghdllocal.adb the procedure Analyze_Files.
There are two points:
* general initialization is performed by the procedure Init (before anything
else) and procedure Setup_Libraries (before parsing).  This is required.
* name_table.Get_Identifier is used to convert a string to a Name_Id.
* As you have found Libraries.Load_File is used to parse a file.

Back_End.Finish_Compilation is called after parsing to finish the work: that
is semantic analysis and code generation.

What may be unusual in GHDL is that 'everything' is an integer: nodes are
represented by an integer (which indexes a table), identifiers are integers...
In most other compilers these are pointers.
Using integers might be slightly slower (because a table has to be indexed),
but makes nodes smaller (as the integer are always 32 bits), and makes nodes
easily extendable.

But you don't really need to know that, because you always have to use
subprograms to read or modify fields.

Tristan.


_______________________________________________
Ghdl-discuss mailing list
[email protected]
https://mail.gna.org/listinfo/ghdl-discuss

Reply via email to