First terminology. This sort of analysis is not done as part of parsing, but as
part of the semantic analysis.
You need to develop a simplified representation of the important semantic
information, i.e., the names of public entities and their types and store that
for comparison. Typically the modules can be in separate files, and to minimize
processing it is useful to create a separate file for each module containing
the information. The file should be much smaller than a typical source code
file and the contents should have a structure as close as possible to the
internal representation used for the data. However it is also useful to have
additional information such as a time stamp, and a version number for the code
that generated the summary, so that you can identify whether the contents are
out of date either compared with the contents of the module or with the code of
your compiler/interpreter. Typically the "summary" file is a text file so that
problems can be visually identified, but a binary form can be more compact and
faster to process.
On Jan 20, 2010, at 2:49 AM, Gustaf Johansson wrote:
> Hi,
>
> I have a grammar in which there can be implicit imports of a few
> definitions example:
>
> module A {
> enum myEnumA { A1, A2, A3 }
> }
>
> module B {
> import module A;
> function myFuncB (int, myEnumA) {
> ...
> }
> }
>
>
> module Prog {
> import B;
> myFuncB (1, A2); *
> }
>
> *Here A2 is implicitly known to be of type myEnumA, since the
> definition of myFuncB is in B and B imports A.
>
> The problem i have is that my parser reports A2 as unknown.
> I have not come up with a good and simple solution to this.
> I have been thinking along the lines of:
> Check definition of myFuncB and if it takes a enum as argument, check
> the local module's imports for the definition of that enum.
>
> Any help is really appreciated.
>
> Best Regards Gustaf
>
> List: http://www.antlr.org/mailman/listinfo/antlr-interest
> Unsubscribe:
> http://www.antlr.org/mailman/options/antlr-interest/your-email-address
>
List: http://www.antlr.org/mailman/listinfo/antlr-interest
Unsubscribe:
http://www.antlr.org/mailman/options/antlr-interest/your-email-address
--
You received this message because you are subscribed to the Google Groups
"il-antlr-interest" 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/il-antlr-interest?hl=en.