NAME
MarpaX::Languages::C::AST::Scope - Scope management when translating a C source to an AST
VERSION
version 0.07
SYNOPSIS
use strict;
use warnings FATAL => 'all';
use MarpaX::Languages::C::AST::Scope;
my $context = 'A string';
my $cAstScopeObject = MarpaX::Languages::C::AST::Scope->new();
$cAstScopeObject->parseEnterScope($context);
$cAstScopeObject->parseReenterScope($context);
$cAstScopeObject->parseEnterTypedef($context, "myTypedef");
$cAstScopeObject->parseEnterEnum($context, "myEnum");
$cAstScopeObject->parseObscureTypedef($context, "myVariable");
foreach (qw/myTypedef myEnum myVariable/) {
if ($cAstScopeObject->parseIsTypedef($context, $_)) {
print "\"$_\" is a typedef\n";
} elsif ($cAstScopeObject->parseIsEnum($context, $_)) {
print "\"$_\" is an enum\n";
}
}
$cAstScopeObject->parseExitScope($context);
DESCRIPTION
This modules manages the scopes when translation a C source into an AST tree. This module is an implementation of the article:
Resolving Typedefs in a Multipass C Compiler from Journal of C Languages Translation, Volume 2, Number 4, writen by W.M. McKeeman. A online version may be accessed at http://www.cs.dartmouth.edu/~mckeeman/references/JCLT/ResolvingTypedefsInAMultipassCCompiler.pdf. Please note that this module is logging via Log::Any.
SUBROUTINES/METHODS
new
Instance a new object. Takes no parameter.
parseEnterScope($self, $context)
Say we enter a new scope. $context is a free string used for logging.
parseExitScope($self, $context)
Say we leave current scope. $context is a free string used for logging.
parseReenterScope($self, $context)
Say we re-enter last scope. $context is a free string used for logging.
parseEnterTypedef($self, $context, $token)
Declare a new typedef with name $token, that will be visible until current scope is left. $context is a free string used for logging.
parseEnterEnum($self, $context, $token)
Declare a new enum with name $token, that will be visible at any scope from now on. $context is a free string used for logging.
parseObscureTypedef($self, $context, $token)
Obscures a typedef named $token. $context is a free string used for logging.
parseIsTypedef($self, $context, $token)
Return a true value if $token is a typedef. $context is a free string used for logging.
parseIsEnum($self, $context, $token)
Return a true value if $token is an enum. $context is a free string used for logging.
AUTHOR
Jean-Damien Durand <jeandamiendurand@free.fr>
COPYRIGHT AND LICENSE
This software is copyright (c) 2013 by Jean-Damien Durand.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.