50 |
# delete everything except the grammar lines |
# delete everything except the grammar lines |
51 |
splice(@yacc_in, $in_marker_end, $#yacc_in - $in_marker_end); |
splice(@yacc_in, $in_marker_end, $#yacc_in - $in_marker_end); |
52 |
splice(@yacc_in, 0, $in_marker_begin + 1); |
splice(@yacc_in, 0, $in_marker_begin + 1); |
53 |
|
|
54 |
|
# remove C++ code |
55 |
|
$scalar_yacc_in = join("", @yacc_in); |
56 |
|
$scalar_yacc_in =~ s/'\{'|'\}'//mg; |
57 |
|
$scalar_yacc_in =~ s/\{(\d|[a-z]|[A-Z]|\#|;|:|<|>|\(|\)|\$|\[|\]|=|\+|-|\"|'|_|\\|\/|\.|,|\s|\n|\r)*\}//mgix; |
58 |
|
# remove surving '}' character ;-) |
59 |
|
#$scalar_yacc_in =~ s/\}/\n/g; |
60 |
|
|
61 |
|
# convert scalar, long string into a line array |
62 |
|
@yacc_in = split(/\n/, $scalar_yacc_in); |
63 |
|
|
64 |
# do the XML transformation |
# do the XML transformation |
65 |
$i = 0; |
$i = 0; |
66 |
foreach $line (@yacc_in) { |
foreach $line (@yacc_in) { |
67 |
$_ = $line; |
$_ = $line . "\n"; |
68 |
# remove C++ code |
# remove C++ code |
69 |
s/\{\p{IsASCII}*\}//g; |
s/\{\p{IsASCII}*\}//g; |
70 |
s/\/\/\p{IsASCII}*$/\n/g; |
s/\/\/\p{IsASCII}*$/\r\n/g; |
71 |
s/\{//g; |
s/\{//g; |
72 |
s/\}//g; |
s/\}//g; |
73 |
# place XML tags |
# place XML tags |
74 |
s!^(\w+)\s*:\s*(\p{IsASCII}*)!<t>$1 =\n\t<list>\n\t\t<t>$2!; |
s!^(\w+)\s*:\s*(\p{IsASCII}*)!<t>$1 =\r\n\t<list>\r\n\t\t<t>$2!; |
75 |
s!^\s+\|\s*(\p{IsASCII}*)!\t\t</t>\n\t\t<t>/ $1!; |
s!^\s+\|\s*(\p{IsASCII}*)!\t\t</t>\r\n\t\t<t>/ $1!; |
76 |
s!^\s*;(\p{IsASCII}*)!\t\t</t>\n\t</list>\n</t>!; |
s!^\s*;(\p{IsASCII}*)!\t\t</t>\r\n\t</list>\r\n</t>!; |
77 |
#s/:/<list>/g; |
#s/:/<list>/g; |
78 |
# remove space(s) at the end of each line |
# remove space(s) at the end of each line |
79 |
s/\s+$/\n/g; |
s/\s+$/\r\n/g; |
80 |
$yacc_in[$i] = $_; |
$yacc_in[$i] = $_; |
81 |
$i++; |
$i++; |
82 |
} |
} |