source: devel-tools/trunk/LL1GrammarAnalyzers/LLAnalyzerInRfp2k9/src/GrPrn.rf @ 4103

Last change on this file since 4103 was 4103, checked in by yura, 11 years ago
  • Copy from LLAnalyzerInRfp2k7.
  • Property svn:eol-style set to native
File size: 1.7 KB
Line 
1//
2// File GRPRN.RF
3//
4// Project: GR
5//
6
7$use StdIO;
8
9$func PrintSetLoop e.TkList = ;
10$func PrintSetRest e.TkList = ;
11
12PrintGrammar (e.Tokens) (e.Rules) =
13  <PrintLn "%token\n  ">,
14  <PrintSet e.Tokens>,
15  <PrintLn "\n%%\n">,
16  <PrintRules e.Rules>;
17
18PrintSet e.TkList =
19  <Print "(">
20  <PrintSetLoop e.TkList>
21  <Print ")">;
22
23PrintSetLoop
24  {
25  s1 s2 s3 s4 s5 v.Rest =
26    <Print s1><Print " | ">
27    <Print s2><Print " | ">
28    <Print s3><Print " | ">
29    <Print s4><Print " | ">
30    <Print s5><Print " | ">
31    <Print "\n  ">,
32    = <PrintSetLoop v.Rest>;
33  s1 s2 s3 s4 s5 =
34    <Print s1><Print " | ">
35    <Print s2><Print " | ">
36    <Print s3><Print " | ">
37    <Print s4><Print " | ">
38    <Print s5>;
39  e.Rest =
40    <PrintSetRest e.Rest>;
41  };
42
43PrintSetRest
44  {
45  s1 v.Rest =
46    <Print s1><Print " | "><PrintSetRest v.Rest>;
47  s1 =
48    <Print s1>;
49  = ;
50  };
51
52PrintRules
53  {
54  $l e (sN e.Rules) e,
55    <PrintLn sN>,
56    \{
57    e.Rules : $l eL (e.Rhs) eR,
58      { eL : = ":"; = "|";} :: s.Prefix,
59      <Print "        "><Print s.Prefix><Print "   ">
60      <PrintRhs e.Rhs>
61      <PrintLn>, $fail;
62    <Print "        ;\n\n">,
63      $fail;
64    },
65    $fail;
66  e;
67  };
68
69PrintRhs
70  {
71  = <Print "/* empty */">;
72  $l e (s.Tag s.Sym) e,
73    <Print s.Sym>,
74    <Print " "> $fail;
75  e = ;
76  };
77
78PrintAnnSym (e.Nullable) s.Sym =
79  {
80  e.Nullable : e s.Sym e
81    = <Print "#">;
82    = ;
83  },
84  <Print s.Sym>;
85
86PrintAnnRhs (e.Nullable) (e.Rhs) =
87  e.Rhs :
88  {
89  = <Print "/* empty */">;
90  $l e (s.Tag s.Sym) e,
91    <PrintAnnSym (e.Nullable) s.Sym>,
92    <Print " "> $fail;
93  e = ;
94  };
95
96PrintEnv
97  {
98  $l e (s.N (eV)) e,
99    <PrintLn><Print s.N><Print " ->\n  ">,
100    <PrintSet eV> $fail;
101  e = <PrintLn>;
102  };
Note: See TracBrowser for help on using the repository browser.