Changeset 4111 for devel-tools


Ignore:
Timestamp:
Dec 14, 2009, 8:49:55 PM (11 years ago)
Author:
yura
Message:
  • Write annotated grammar to file.
Location:
devel-tools/trunk/LL1GrammarAnalyzers/LLAnalyzerInRfp2k9/src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • devel-tools/trunk/LL1GrammarAnalyzers/LLAnalyzerInRfp2k9/src/Gr.rf

    r4103 r4111  
    2020  <Arg 1> :: e.FileName,
    2121  <ReadGrammar e.FileName> :: (e.Tokens) (e.Rules),
    22   <Analyze (e.Tokens) (e.Rules)>;
     22  <Arg 2> :: e.FileName,
     23  <OpenFile &WriteFileCh e.FileName "W">,
     24  <Analyze (e.Tokens) (e.Rules)>,
     25  <CloseChannel &WriteFileCh>;
    2326
  • devel-tools/trunk/LL1GrammarAnalyzers/LLAnalyzerInRfp2k9/src/GrAnal.rf

    r4103 r4111  
    5252  {
    5353  e.Dead : ;
    54   <Print "\nDead nonterminals:\n\n  ">,
    55     <PrintSet e.Dead>,<PrintLn "\n">,
     54  <PrintCh &WriteFileCh "\nDead nonterminals:\n\n  ">,
     55    <PrintSet e.Dead>,<PrintLnCh &WriteFileCh "\n">,
    5656    <Exit 1>;
    5757  },
     
    6060  {
    6161  e.Unreachable : ;
    62   <Print "\nUnreachable nonterminals:\n\n  ">,
    63     <PrintSet e.Unreachable>,<PrintLn "\n">,
     62  <PrintCh &WriteFileCh "\nUnreachable nonterminals:\n\n  ">,
     63    <PrintSet e.Unreachable>,<PrintLnCh &WriteFileCh "\n">,
    6464    <Exit 1>;
    6565  },
     
    6767  {
    6868  e.Nullable : ;
    69   <Print "\nNullable nonterminals:\n\n  ">,
    70     <PrintSet e.Nullable>,<PrintLn "\n">;
     69  <PrintCh &WriteFileCh "\nNullable nonterminals:\n\n  ">,
     70    <PrintSet e.Nullable>,<PrintLnCh &WriteFileCh "\n">;
    7171  },
    7272  e.Rules : (s.Start e) e,
    7373  ("$START" ( (N s.Start) (T "$END") )) e.Rules :: e.Rules_,
    7474  <FindStarters (e.Nullable) (e.Rules_)> :: e.SEnv,
    75   <PrintLn "\nThe starters of nonterminals:">,
     75  <PrintLnCh &WriteFileCh "\nThe starters of nonterminals:">,
    7676  e.SEnv : t e.SEnv1,
    77   <PrintEnv e.SEnv1>,<PrintLn>,
     77  <PrintEnv e.SEnv1>,<PrintLnCh &WriteFileCh>,
    7878  <FindFollowers (e.Nullable) (e.SEnv) (e.Rules_)> :: e.FEnv,
    79   <PrintLn "\nThe followers of nullable nonterminals:">,
     79  <PrintLnCh &WriteFileCh "\nThe followers of nullable nonterminals:">,
    8080  e.FEnv : t e.FEnv1,
    8181  <EnvWith (e.Nullable) (e.FEnv1)> :: e.FEnv1,
    82   <PrintEnv e.FEnv1>,<PrintLn>,
    83   <Print "\n*** Annotated grammar ***\n\n">,
     82  <PrintEnv e.FEnv1>,<PrintLnCh &WriteFileCh>,
     83  <PrintCh &WriteFileCh "\n*** Annotated grammar ***\n\n">,
    8484  <PrintAnnGrammar (e.Nullable) (e.SEnv) (e.FEnv) (e.Rules)>
    8585  ;
     
    301301  = ;
    302302  (sN eL) e.Rest =
    303     <PrintAnnSym (e.Nullable) sN><PrintLn>
     303    <PrintAnnSym (e.Nullable) sN><PrintLnCh &WriteFileCh>
    304304    <PrintAnnRules ":" (e.Nullable) (e.SEnv) (e.FEnv) () sN (eL)>
    305305    <PrintAnnGrammar (e.Nullable) (e.SEnv) (e.FEnv) (e.Rest)>;
     
    309309  eL :
    310310  {
    311   = <PrintLn ";\n">;
     311  = <PrintLnCh &WriteFileCh ";\n">;
    312312  (eR) e.Rest =
    313313    <RhsStarters (e.Nullable) (e.SEnv) (eR)> :: e.Sel,
     
    317317      = e.Sel;
    318318    } :: e.Sel,
    319     <Print sC><Print " "><PrintSet e.Sel><PrintLn>,
     319    <PrintCh &WriteFileCh sC><PrintCh &WriteFileCh " "><PrintSet e.Sel><PrintLnCh &WriteFileCh>,
    320320    {
    321321    e.S : e s0 e, e.Sel : e s0 e =
    322322      <PrintLnCh &StdErr "*** Conflict !!! ***">,
    323       <PrintLn "*** Conflict !!! ***">;
     323      <PrintLnCh &WriteFileCh "*** Conflict !!! ***">;
    324324      = ;
    325325    },
    326326    <SetUnion (e.S) (e.Sel)> :: e.S,
    327     <Print "     "><PrintAnnRhs (e.Nullable) (eR)><PrintLn>,
     327    <PrintCh &WriteFileCh "     "><PrintAnnRhs (e.Nullable) (eR)><PrintLnCh &WriteFileCh>,
    328328    = <PrintAnnRules "|" (e.Nullable) (e.SEnv) (e.FEnv) (e.S) sN (e.Rest)>;
    329329  };
  • devel-tools/trunk/LL1GrammarAnalyzers/LLAnalyzerInRfp2k9/src/GrPrn.rf

    r4103 r4111  
    1111
    1212PrintGrammar (e.Tokens) (e.Rules) =
    13   <PrintLn "%token\n  ">,
     13  <PrintLnCh &WriteFileCh "%token\n  ">,
    1414  <PrintSet e.Tokens>,
    15   <PrintLn "\n%%\n">,
     15  <PrintLnCh &WriteFileCh "\n%%\n">,
    1616  <PrintRules e.Rules>;
    1717
    1818PrintSet e.TkList =
    19   <Print "(">
     19  <PrintCh &WriteFileCh "(">
    2020  <PrintSetLoop e.TkList>
    21   <Print ")">;
     21  <PrintCh &WriteFileCh ")">;
    2222
    2323PrintSetLoop
    2424  {
    2525  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  ">,
     26    <PrintCh &WriteFileCh s1><PrintCh &WriteFileCh " | ">
     27    <PrintCh &WriteFileCh s2><PrintCh &WriteFileCh " | ">
     28    <PrintCh &WriteFileCh s3><PrintCh &WriteFileCh " | ">
     29    <PrintCh &WriteFileCh s4><PrintCh &WriteFileCh " | ">
     30    <PrintCh &WriteFileCh s5><PrintCh &WriteFileCh " | ">
     31    <PrintCh &WriteFileCh "\n  ">,
    3232    = <PrintSetLoop v.Rest>;
    3333  s1 s2 s3 s4 s5 =
    34     <Print s1><Print " | ">
    35     <Print s2><Print " | ">
    36     <Print s3><Print " | ">
    37     <Print s4><Print " | ">
    38     <Print s5>;
     34    <PrintCh &WriteFileCh s1><PrintCh &WriteFileCh " | ">
     35    <PrintCh &WriteFileCh s2><PrintCh &WriteFileCh " | ">
     36    <PrintCh &WriteFileCh s3><PrintCh &WriteFileCh " | ">
     37    <PrintCh &WriteFileCh s4><PrintCh &WriteFileCh " | ">
     38    <PrintCh &WriteFileCh s5>;
    3939  e.Rest =
    4040    <PrintSetRest e.Rest>;
     
    4444  {
    4545  s1 v.Rest =
    46     <Print s1><Print " | "><PrintSetRest v.Rest>;
     46    <PrintCh &WriteFileCh s1><PrintCh &WriteFileCh " | "><PrintSetRest v.Rest>;
    4747  s1 =
    48     <Print s1>;
     48    <PrintCh &WriteFileCh s1>;
    4949  = ;
    5050  };
     
    5353  {
    5454  $l e (sN e.Rules) e,
    55     <PrintLn sN>,
     55    <PrintLnCh &WriteFileCh sN>,
    5656    \{
    5757    e.Rules : $l eL (e.Rhs) eR,
    5858      { eL : = ":"; = "|";} :: s.Prefix,
    59       <Print "        "><Print s.Prefix><Print "   ">
     59      <PrintCh &WriteFileCh "        "><PrintCh &WriteFileCh s.Prefix><PrintCh &WriteFileCh "   ">
    6060      <PrintRhs e.Rhs>
    61       <PrintLn>, $fail;
    62     <Print "        ;\n\n">,
     61      <PrintLnCh &WriteFileCh>, $fail;
     62    <PrintCh &WriteFileCh "        ;\n\n">,
    6363      $fail;
    6464    },
     
    6969PrintRhs
    7070  {
    71   = <Print "/* empty */">;
     71  = <PrintCh &WriteFileCh "/* empty */">;
    7272  $l e (s.Tag s.Sym) e,
    73     <Print s.Sym>,
    74     <Print " "> $fail;
     73    <PrintCh &WriteFileCh s.Sym>,
     74    <PrintCh &WriteFileCh " "> $fail;
    7575  e = ;
    7676  };
     
    7979  {
    8080  e.Nullable : e s.Sym e
    81     = <Print "#">;
     81    = <PrintCh &WriteFileCh "#">;
    8282    = ;
    8383  },
    84   <Print s.Sym>;
     84  <PrintCh &WriteFileCh s.Sym>;
    8585
    8686PrintAnnRhs (e.Nullable) (e.Rhs) =
    8787  e.Rhs :
    8888  {
    89   = <Print "/* empty */">;
     89  = <PrintCh &WriteFileCh "/* empty */">;
    9090  $l e (s.Tag s.Sym) e,
    9191    <PrintAnnSym (e.Nullable) s.Sym>,
    92     <Print " "> $fail;
     92    <PrintCh &WriteFileCh " "> $fail;
    9393  e = ;
    9494  };
     
    9797  {
    9898  $l e (s.N (eV)) e,
    99     <PrintLn><Print s.N><Print " ->\n  ">,
     99    <PrintLnCh &WriteFileCh><PrintCh &WriteFileCh s.N><PrintCh &WriteFileCh " ->\n  ">,
    100100    <PrintSet eV> $fail;
    101   e = <PrintLn>;
     101  e = <PrintLnCh &WriteFileCh>;
    102102  };
  • devel-tools/trunk/LL1GrammarAnalyzers/LLAnalyzerInRfp2k9/src/GrPrn.rfi

    r4103 r4111  
    1212$func PrintAnnSym (e.Nullable) s.Sym = ;
    1313$func PrintAnnRhs (e.Nullable) (e.Rhs) = ;
     14
     15$channel WriteFileCh;
Note: See TracChangeset for help on using the changeset viewer.