| 1 |
#----------------------------------------------------------------- |
| 2 |
# Rules for use |
| 3 |
#----------------------------------------------------------------- |
| 4 |
|
| 5 |
token_use: /\buse\s/ use_stuff /[;}]/ |
| 6 |
{ $return=$item{use_stuff} } |
| 7 |
|
| 8 |
use_stuff: (base | parent | version | module) |
| 9 |
|
| 10 |
base: "base" import_list |
| 11 |
|
| 12 |
parent: "parent" import_list |
| 13 |
{ $return='parent'; $return.=' '.$item[2] if $item[2] !~ /^\s*-norequire\b/; } |
| 14 |
|
| 15 |
module: module_name module_more |
| 16 |
{ $return=$item{module_name} } |
| 17 |
|
| 18 |
module_name: /[\w:]+/ |
| 19 |
|
| 20 |
module_more: eos | version(?) var(?) import_list(?) |
| 21 |
|
| 22 |
#----------------------------------------------------------------- |
| 23 |
# Rules for require |
| 24 |
#----------------------------------------------------------------- |
| 25 |
|
| 26 |
token_require: /\brequire\s/ require_stuff /[;}]/ |
| 27 |
{ $return=$item{require_stuff} } |
| 28 |
|
| 29 |
require_stuff: (version | require_name | module) |
| 30 |
|
| 31 |
require_name: <perl_quotelike> |
| 32 |
{ my $name=$item[1][2]; |
| 33 |
return 1 if ($name=~/\.pl$/); |
| 34 |
$name=~s(/)(::)g; |
| 35 |
$name=~s/\.pm//; |
| 36 |
$return=$name; |
| 37 |
} |
| 38 |
|
| 39 |
#----------------------------------------------------------------- |
| 40 |
# Rules for no |
| 41 |
#----------------------------------------------------------------- |
| 42 |
|
| 43 |
token_no: /\bno\s/ no_stuff /[;}]/ |
| 44 |
{ $return=$item{no_stuff} } |
| 45 |
|
| 46 |
no_stuff: (base | version | module) |
| 47 |
|
| 48 |
#---------------------------------------------------------------- |
| 49 |
# Functions provided by Module::Runtime |
| 50 |
#---------------------------------------------------------------- |
| 51 |
|
| 52 |
module_runtime_require_module: ( 'Module::Runtime::require_module(' | /\brequire_module\(/ ) <perl_quotelike> ')' |
| 53 |
{ $return = $item[2][2] } |
| 54 |
|
| 55 |
module_runtime_use_fcn: ( 'use_module' | 'use_package_optimistically' ) |
| 56 |
|
| 57 |
module_runtime_version: ',' /\s*/ version |
| 58 |
|
| 59 |
module_runtime_use: ( ( 'Module::Runtime::' module_runtime_use_fcn '(' ) | ( m/\b/ module_runtime_use_fcn '(' ) ) <perl_quotelike> module_runtime_version(?) ')' |
| 60 |
{ $return = $item[2][2] } |
| 61 |
|
| 62 |
token_module_runtime: module_runtime_require_module | module_runtime_use |
| 63 |
|
| 64 |
#----------------------------------------------------------------- |
| 65 |
# Functions provided by Class::Load |
| 66 |
#----------------------------------------------------------------- |
| 67 |
|
| 68 |
hash_pair: /\S+/ comma ( <perl_quotelike> | /[^\s,}]+/ ) |
| 69 |
|
| 70 |
comma_hash_pair: comma hash_pair |
| 71 |
|
| 72 |
hashref: '{' hash_pair comma_hash_pair(s?) '}' |
| 73 |
|
| 74 |
comma_hashref: comma hashref |
| 75 |
|
| 76 |
class_load_functions: 'load_class' | 'try_load_class' | 'load_optional_class' |
| 77 |
|
| 78 |
class_load: ( ( 'Class::Load::' class_load_functions ) | ( /\b/ class_load_functions ) ) '(' <perl_quotelike> comma_hashref(?) ')' |
| 79 |
{ $return = $item[3][2] } |
| 80 |
|
| 81 |
first_existing_arg: <perl_quotelike> comma_hashref(?) |
| 82 |
{ $return = $item[1][2] } |
| 83 |
|
| 84 |
comma_first_existing_arg: comma first_existing_arg |
| 85 |
{ $return = $item{first_existing_arg} } |
| 86 |
|
| 87 |
class_load_first_existing: ( 'Class::Load::load_first_existing_class' | /\bload_first_existing_class/ ) '(' first_existing_arg comma_first_existing_arg(s?) ')' |
| 88 |
{ $return = $item{first_existing_arg}; |
| 89 |
$return .= " " . join(" ", @{$item{'comma_first_existing_arg(s?)'}}) if $item{'comma_first_existing_arg(s?)'}; |
| 90 |
1; |
| 91 |
} |
| 92 |
|
| 93 |
token_class_load: class_load | class_load_first_existing |
| 94 |
|
| 95 |
#----------------------------------------------------------------- |
| 96 |
# General Rules |
| 97 |
#----------------------------------------------------------------- |
| 98 |
|
| 99 |
version: /v?[\d\._]+/ |
| 100 |
|
| 101 |
eos: { $text=~/^[\s;]+$/ ? 1 : undef;} |
| 102 |
|
| 103 |
var: /\$[\w+]/ |
| 104 |
|
| 105 |
import_list: /[(]?/ |
| 106 |
list_item |
| 107 |
comma_list_item(s?) |
| 108 |
/[)]?/ |
| 109 |
{ $return=$item[2]; |
| 110 |
$return.=" ".join(" ",@{$item[3]}) if $item[3]; |
| 111 |
} |
| 112 |
| |
| 113 |
/[(]\s*[)]/ { $return='' } |
| 114 |
|
| 115 |
list_item: <perl_quotelike> { $return=$item[1][2] } |
| 116 |
| |
| 117 |
<perl_codeblock (){}[]> { $return=$item[1] } |
| 118 |
| |
| 119 |
/-?\w+/ { $return=$item[1] } |
| 120 |
|
| 121 |
comma_list_item: comma list_item |
| 122 |
{ $return=$item{list_item} } |
| 123 |
|
| 124 |
comma: (',' | '=>') |