Archived OpenModelica forums. Posting is disabled.

Alternative forums include GitHub discussions or StackOverflow (make sure to read the Stack Overflow rules; you need to have well-formed questions)


Forgot password? | Forgot username? | Register

Traversing AST in C

Traversing AST in C

Hi there,

I was wondering if it's possible/feasible to traverse the AST constructed by the Modelica parser in C. I have looked through the C code and it seems as though the constructed AST's datatype can become fairly convoluted since there are not any structs that clearly define the tree that I can typecast the result to. Any insight would be greatly appreciated!

Re: Traversing AST in C

Check anyStringWork in https://openmodelica.org/svn/OpenModeli … modelica.c if you are using the bootstrapped OpenModelica compiler (libomparse.a). All data is stored in the data of a void*. Integers are stored in memory, with one bit lost to tag the data as integer.
Otherwise, the data is boxed and the header tells you what datatype it is. Use the meta_modelica.h macros to walk the AST since the format may change (we have some #ifdefs that changes the layout slightly, for example which bit decides if the data is Integer or not).

There are 0 guests and 0 other users also viewing this topic
You are here: