| 1 |
# Copyright 2022 Jeffrey Kegler |
| 2 |
# This file is part of Marpa::R2. Marpa::R2 is free software: you can |
| 3 |
# redistribute it and/or modify it under the terms of the GNU Lesser |
| 4 |
# General Public License as published by the Free Software Foundation, |
| 5 |
# either version 3 of the License, or (at your option) any later version. |
| 6 |
# |
| 7 |
# Marpa::R2 is distributed in the hope that it will be useful, |
| 8 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 9 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 10 |
# Lesser General Public License for more details. |
| 11 |
# |
| 12 |
# You should have received a copy of the GNU Lesser |
| 13 |
# General Public License along with Marpa::R2. If not, see |
| 14 |
# http://www.gnu.org/licenses/. |
| 15 |
|
| 16 |
use 5.010001; |
| 17 |
use strict; |
| 18 |
use warnings; |
| 19 |
use Carp; |
| 20 |
use English qw( -no_match_vars ); |
| 21 |
|
| 22 |
our $HEADER; |
| 23 |
|
| 24 |
sub offset { |
| 25 |
my ($desc) = @_; |
| 26 |
my @fields = split q{ }, $desc; |
| 27 |
my $offset = -1; |
| 28 |
my $in_comment = 0; |
| 29 |
|
| 30 |
no strict 'refs'; |
| 31 |
FIELD: for my $field (@fields) { |
| 32 |
|
| 33 |
if ($in_comment) { |
| 34 |
$in_comment = $field ne ':}' && $field ne '}'; |
| 35 |
next FIELD; |
| 36 |
} |
| 37 |
|
| 38 |
PROCESS_OPTION: { |
| 39 |
last PROCESS_OPTION if $field !~ /\A [{:] /xms; |
| 40 |
if ( $field =~ / \A [:] package [=] (.*) /xms ) { |
| 41 |
say "\npackage $1;"; |
| 42 |
$offset = -1; |
| 43 |
next FIELD; |
| 44 |
} |
| 45 |
if ( $field =~ / \A [:]? [{] /xms ) { |
| 46 |
$in_comment++; |
| 47 |
next FIELD; |
| 48 |
} |
| 49 |
} ## end PROCESS_OPTION: |
| 50 |
|
| 51 |
if ((substr $field, 0, 1) eq '=') { |
| 52 |
$field = substr $field, 1; |
| 53 |
} else { |
| 54 |
$offset++; |
| 55 |
} |
| 56 |
die "Unacceptable field name: $field" |
| 57 |
if $field =~ /[^A-Z0-9_]/xms; |
| 58 |
say "use constant $field => $offset;" |
| 59 |
|
| 60 |
} ## end for my $field (@fields) |
| 61 |
return 1; |
| 62 |
} ## end sub Marpa::R2::offset |
| 63 |
|
| 64 |
|
| 65 |
$HEADER =~ s/!!!PROGRAM_NAME!!!/$PROGRAM_NAME/; |
| 66 |
say $HEADER; |
| 67 |
$RS = undef; |
| 68 |
offset(<DATA>); |
| 69 |
say "\n1;"; |
| 70 |
|
| 71 |
BEGIN { |
| 72 |
|
| 73 |
$HEADER = <<'END_OF_HEADER'; |
| 74 |
# Copyright 2022 Jeffrey Kegler |
| 75 |
# This file is part of Marpa::R2. Marpa::R2 is free software: you can |
| 76 |
# redistribute it and/or modify it under the terms of the GNU Lesser |
| 77 |
# General Public License as published by the Free Software Foundation, |
| 78 |
# either version 3 of the License, or (at your option) any later version. |
| 79 |
# |
| 80 |
# Marpa::R2 is distributed in the hope that it will be useful, |
| 81 |
# but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 82 |
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
| 83 |
# Lesser General Public License for more details. |
| 84 |
# |
| 85 |
# You should have received a copy of the GNU Lesser |
| 86 |
# General Public License along with Marpa::R2. If not, see |
| 87 |
# http://www.gnu.org/licenses/. |
| 88 |
|
| 89 |
# DO NOT EDIT THIS FILE DIRECTLY |
| 90 |
# It was generated by !!!PROGRAM_NAME!!! |
| 91 |
|
| 92 |
package Marpa::R2::Internal; |
| 93 |
|
| 94 |
use 5.010001; |
| 95 |
use strict; |
| 96 |
use warnings; |
| 97 |
use Carp; |
| 98 |
|
| 99 |
use vars qw($VERSION $STRING_VERSION); |
| 100 |
$VERSION = '14.000000'; |
| 101 |
$STRING_VERSION = $VERSION; |
| 102 |
$VERSION = eval $VERSION; |
| 103 |
END_OF_HEADER |
| 104 |
|
| 105 |
} |
| 106 |
|
| 107 |
__DATA__ |
| 108 |
|
| 109 |
:package=Marpa::R2::HTML::Internal::TDesc |
| 110 |
TYPE |
| 111 |
START_TOKEN |
| 112 |
END_TOKEN |
| 113 |
VALUE |
| 114 |
RULE_ID |
| 115 |
|
| 116 |
:package=Marpa::R2::HTML::Internal::Token |
| 117 |
TOKEN_ID |
| 118 |
=TAG_NAME |
| 119 |
TYPE |
| 120 |
LINE |
| 121 |
COL |
| 122 |
=COLUMN |
| 123 |
START_OFFSET |
| 124 |
END_OFFSET |
| 125 |
IS_CDATA |
| 126 |
ATTR |