| 1 | 3 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 2 | 3 | ▶ | use warnings FATAL => 'all'; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 3 | |||
| 4 | package MarpaX::Languages::IDL::AST::Value; | ||
| 5 | 3 | ▶ | use Scalar::Util qw/blessed/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 6 | |||
| 7 | # ABSTRACT: Translate an IDL source to an AST - parse tree value helpers | ||
| 8 | |||
| 9 | 3 | our $VERSION = '0.007'; # VERSION | |
| 10 | |||
| 11 | |||
| 12 | 3 | ▶ | use constant { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 13 | 3 | LEXEME_INDEX => 0 | |
| 14 | 3 | }; | |
| 15 | |||
| 16 | 3 | ▶ | use constant { |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 17 | 3 | LEXEME_INDEX_START => 0, | |
| 18 | LEXEME_INDEX_LENGTH => 1, | ||
| 19 | LEXEME_INDEX_VALUE => 2 | ||
| 20 | 3 | }; | |
| 21 | |||
| 22 | 1 | ▶ | sub new { |
|
Subroutine
new: called CC=1 SCAR=0.0
Pod
documented
| |||
| 23 | 1 | my ($class) = @_; | |
| 24 | |||
| 25 | # | ||
| 26 | # "Contents of an entire IDL file, together with the contents of any files referenced by #include statements, forms a naming scope. | ||
| 27 | # Definitions that do not appear inside a scope are part of the global scope. There is only a single global scope, irrespective | ||
| 28 | # of the number of source files that form a specification." | ||
| 29 | # | ||
| 30 | # Scopes can be nested. | ||
| 31 | # | ||
| 32 | 1 | my $self = { | |
| 33 | }; | ||
| 34 | |||
| 35 | 1 | bless($self, $class); | |
| 36 | |||
| 37 | 1 | return $self; | |
| 38 | } | ||
| 39 | |||
| 40 | 279 | ▶ | sub _scopedName { |
|
Subroutine
_scopedName: called CC=1 SCAR=0.0
| |||
| 41 | 279 | my ($self, $scopedName) = @_; | |
| 42 | |||
| 43 | # | ||
| 44 | # We concatenate identifiers to have a single-like lexeme | ||
| 45 | # | ||
| 46 | 279 | my @scopedNames = (); | |
| 47 | 279 | my $firstIdentifier = $scopedName->[0]; | |
| 48 | 279 | my $lastIdentifier = $scopedName->[-1]; | |
| 49 | 279 | my $firstLexeme = $firstIdentifier->[LEXEME_INDEX]; | |
| 50 | 279 | my $lastLexeme = $lastIdentifier->[LEXEME_INDEX]; | |
| 51 | |||
| 52 | 279 | my $start = $firstLexeme->[LEXEME_INDEX_START]; | |
| 53 | 279 | my $length = $lastLexeme->[LEXEME_INDEX_START] + $lastLexeme->[LEXEME_INDEX_LENGTH] - $start; | |
| 54 | 279 | map {push(@scopedNames, $_->[LEXEME_INDEX]->[LEXEME_INDEX_VALUE])} @{$scopedName}; | |
| 55 | 279 | my $value = join('::', @scopedNames); | |
| 56 | 279 | my $rc = bless [$start, $length, $value ], blessed($scopedName); | |
| 57 | |||
| 58 | 279 | return $rc; | |
| 59 | } | ||
| 60 | |||
| 61 | 3 | 1; | |
| 62 | |||
| 63 | __END__ | ||