Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit81a82a1

Browse files
author
Michael Meskes
committed
Added script to check if all rule re-definition in ecpg.addons are indeed used
in the build process. If not the build process will stop with an error message.
1 parentf0edaec commit81a82a1

File tree

2 files changed

+138
-1
lines changed

2 files changed

+138
-1
lines changed

‎src/interfaces/ecpg/preproc/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#
55
# Copyright (c) 1998-2009, PostgreSQL Global Development Group
66
#
7-
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.146 2009/09/02 19:14:14 mha Exp $
7+
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/Makefile,v 1.147 2009/11/27 10:00:40 meskes Exp $
88
#
99
#-------------------------------------------------------------------------
1010

@@ -54,6 +54,7 @@ endif
5454

5555
preproc.y: ../../../backend/parser/gram.y parse.pl ecpg.addons ecpg.header ecpg.tokens ecpg.trailer ecpg.type
5656
$(PERL)$(srcdir)/parse.pl$(srcdir)<$<>$@
57+
$(PERL)$(srcdir)/check_rules.pl$(srcdir)$<
5758

5859
ecpg_keywords.oc_keywords.okeywords.opreproc.oparser.o: preproc.h
5960

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
#!/usr/bin/perl
2+
# $PostgreSQL: pgsql/src/interfaces/ecpg/preproc/check_rules.pl,v 1.1 2009/11/27 10:00:40 meskes Exp $
3+
# test parser generater for ecpg
4+
# call with backend parser as stdin
5+
#
6+
# Copyright (c) 2009, PostgreSQL Global Development Group
7+
#
8+
# Written by Michael Meskes <meskes@postgresql.org>
9+
#
10+
# Placed under the same license as PostgreSQL.
11+
#
12+
13+
if (@ARGV) {
14+
$path =$ARGV[0];
15+
$parser =$ARGV[1];
16+
}
17+
18+
$[ = 1;# set array base to 1
19+
20+
if ($patheq'') {$path ="."; }
21+
$filename =$path ."/ecpg.addons";
22+
23+
if ($parsereq'') {$parser ="../../../backend/parser/gram.y"; }
24+
25+
$replace_line{'ExecuteStmtEXECUTEnameexecute_param_clause'} ='EXECUTE prepared_name execute_param_clause execute_rest';
26+
$replace_line{'ExecuteStmtCREATEOptTempTABLEcreate_as_targetASEXECUTEnameexecute_param_clause'} ='CREATE OptTemp TABLE create_as_target AS EXECUTE prepared_name execute_param_clause';
27+
$replace_line{'PrepareStmtPREPAREnameprep_type_clauseASPreparableStmt'} ='PREPARE prepared_name prep_type_clause AS PreparableStmt';
28+
29+
$block ='';
30+
$ret = 0;
31+
$yaccmod = 0;
32+
$brace_indent = 0;
33+
34+
open GRAM,$parserordie$!;
35+
while (<GRAM>) {
36+
chomp;# strip record separator
37+
38+
if (/^%%/) {
39+
$yaccmode++;
40+
}
41+
42+
if ($yaccmode != 1) {
43+
next;
44+
}
45+
46+
$S =$_;
47+
$prec = 0;
48+
49+
# Make sure any braces are split
50+
$S =~s/{/ {/g;
51+
$S =~s/}/ }/g;
52+
# Any comments are split
53+
$S =~s#[/][*]# /*#g;
54+
$S =~s#[*][/]# */#g;
55+
56+
# Now split the line into individual fields
57+
$n = (@arr =split('',$S));
58+
59+
# Go through each field in turn
60+
for ($fieldIndexer = 1;$fieldIndexer <=$n;$fieldIndexer++) {
61+
if ($arr[$fieldIndexer]eq'*/' &&$comment) {
62+
$comment = 0;
63+
next;
64+
}
65+
elsif ($comment) {
66+
next;
67+
}
68+
elsif ($arr[$fieldIndexer]eq'/*') {
69+
# start of a multiline comment
70+
$comment = 1;
71+
next;
72+
}
73+
elsif ($arr[$fieldIndexer]eq'//') {
74+
next;
75+
}
76+
elsif ($arr[$fieldIndexer]eq'}') {
77+
$brace_indent--;
78+
next;
79+
}
80+
elsif ($arr[$fieldIndexer]eq'{') {
81+
$brace_indent++;
82+
next;
83+
}
84+
85+
if ($brace_indent > 0) {
86+
next;
87+
}
88+
89+
if ($arr[$fieldIndexer]eq';' ||$arr[$fieldIndexer]eq'|') {
90+
$block =$non_term_id .$block;
91+
if ($replace_line{$block}) {
92+
$block = &generate_block($replace_line{$block});
93+
}
94+
$found{$block} ='found';
95+
$block ='';
96+
}
97+
elsif (($arr[$fieldIndexer] =~'[A-Za-z0-9]+:') ||$arr[$fieldIndexer + 1]eq':') {
98+
$non_term_id =$arr[$fieldIndexer];
99+
$non_term_id =~s/://g;
100+
}
101+
else {
102+
$block =$block .$arr[$fieldIndexer];
103+
}
104+
}
105+
}
106+
107+
close GRAM;
108+
109+
open ECPG,$filenameordie$!;
110+
111+
line:while (<ECPG>) {
112+
chomp;# strip record separator
113+
@Fld =split('',$_, -1);
114+
115+
if (!/^ECPG:/) {
116+
next line;
117+
}
118+
119+
if ($found{$Fld[2]}ne'found') {
120+
printf$Fld[2] ." is not used for building parser!\n";
121+
$ret = 1;
122+
}
123+
}
124+
125+
close ECPG;
126+
127+
exit$ret;
128+
129+
subgenerate_block {
130+
local($line) =@_;
131+
$block =$non_term_id .$line;
132+
$block =~s///g;
133+
$s ="\\|",$block =~s/$s//g;
134+
return$block;
135+
}
136+

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp