See Also
Printy Config Namespace
Parser Class
net.stefanhauser.Printy.GUI.Config.Parser
C++
public: class Parser;
C#
public class Parser;
Visual Basic
Public Class Parser
File
Remarks

Dieser Parser wird zum Lesen einer Konfigurationsdatei verwendet. Er wurde mit dem Werkzeug COCO erstellt. 

 

/*-----------------------------------------------------------------
Config.atg
2005-11 Stefan Hauser
 
 
Original Version by Philip Grasböck
 
-------------------------------------------------------------------*/
 
COMPILER PrintyConfig
 
CHARACTERS
  digit      = "0123456789".
  tab        = '\t'.
  cr         = '\r'.
  lf         = '\n'.
  eol        = cr + lf.
 
TOKENS
  number = ['-'] digit { digit }.
 
COMMENTS FROM "/*" TO "*/" NESTED
COMMENTS FROM "//" TO cr lf
 
IGNORE eol + tab
 
/*-------------------------------------------------------------------------*/
 
PRODUCTIONS
 
PrintyConfig
=
  {
                  (. Rule r = new Rule();               .)
    Rule<r>
    ';'             (. Rules.Add(r);                      .)
  }
.
 
Rule<Rule r> = ConfigRule<r> | HyperConfigRule<r>.
 
ConfigRule<Rule r>
=
  ( SpaceRule<r>        (. r.Type = RuleType.SpaceRule;       .)
  | BreakRule<r>        (. r.Type = RuleType.BreakRule;       .)
  | OpenRule<r>         (. r.Type = RuleType.OpenRule;        .)
  | CloseRule<r>        (. r.Type = RuleType.CloseRule;       .)
  | HideRule<r>         (. r.Type = RuleType.HideRule;        .)
  | OverlapRule<r>        (. r.Type = RuleType.OverlapRule;     .)
  )
.
 
HyperConfigRule<Rule r>
=
  ( StyleRule<r>                (. r.Type = RuleType.StyleRule;       .)
  | ClassRule<r>        (. r.Type = RuleType.ClassRule;       .)
  )
.
 
SpaceRule<Rule r>
= "space"
  SymbolAllIndent<out r.FirstSymbol>
  SymbolAll<out r.SecondSymbol>
  number                        (. r.Number = Convert.ToInt32(t.val); .)
.
 
BreakRule<Rule r>
= "break"
  SymbolAll<out r.FirstSymbol>
  SymbolAll<out r.SecondSymbol>
  ( number                      (. r.Number = Convert.ToInt32(t.val); .)
  | "default"                   (. r.BreakMode = BreakMode.Default;   .)
  | "always"                    (. r.BreakMode = BreakMode.Always;    .)
  | "never"                     (. r.BreakMode = BreakMode.Never;     .)
  )
.
 
OpenRule<Rule r>
= "open"
  (                 (. r.CreateBitSet();                  .)
      BitSet<r>
  |
      Bit<out r.FirstSymbol>
  )
.
 
CloseRule<Rule r>
= "close"
  (                 (. r.CreateBitSet();                  .)
      BitSet<r>
  |
      Bit<out r.FirstSymbol>
  )
.
 
HideRule<Rule r>
= "hide"
  (                 (. r.CreateBitSet();                   .)
      BitSet<r>
  |
      Bit<out r.FirstSymbol>
  )
.
 
OverlapRule<Rule r>
= "overlap"
  (                 (. r.CreateBitSet();                  .)
      BitSet<r>
  |
      Bit<out r.FirstSymbol>
  )
.
 
StyleRule<Rule r>
= "style"
  (                 (. r.CreateBitSet();                  .)
      BitSet<r>
  |
      Bit<out r.FirstSymbol>
  )
.
 
ClassRule<Rule r>
= "class"
  Text                (. r.Text = t.val;                    .)
  [
      SymbolAll<out r.FirstSymbol>
  ]
  Text                        (. r.FurtherText = new ArrayList();
                     r.FurtherText.Add(t.val);          .)
 
  {
      Text                    (. r.FurtherText.Add(t.val);          .)
  }
.
 
Bit<out Symbol sym>
= SymbolAll <out sym>
.
 
BitSet<Rule rule>
=                         (. Symbol sym = Symbol.UNSET; .)
  '['
  { SingleSymbol<out sym>        (. rule.Add(sym);             .)
  }
  ']'
.
 
SymbolAll<out Symbol sym>
=                                       (. sym = Symbol.UNSET;        .)
  ( "ALL"                (. sym = Symbol.ALL;          .)
  | SingleSymbol<out sym>
  )
.
 
SymbolAllIndent<out Symbol sym>
=                                       (. sym = Symbol.UNSET;        .)
  ( "INDENT"                 (. sym = Symbol.INDENT;       .)
  | SymbolAll<out sym>
  )
.
 
SingleSymbol<out Symbol sym>
=                      (. sym = Symbol.UNSET;        .)
  ( "Production"            (. sym = Symbol.Production;   .)
  | "Symbol"                            (. sym = Symbol.Symbol;       .)
  | "Literal"                           (. sym = Symbol.Literal;      .)
  | "Open"                              (. sym = Symbol.Open;         .)
  | "Close"                             (. sym = Symbol.Close;        .)
  | "Assign"                            (. sym = Symbol.Assign;       .)
  | "Separator"                         (. sym = Symbol.Seperator;    .)
  | "Delimiter"                         (. sym = Symbol.Delimiter;    .)
  | "InnerComment"                      (. sym = Symbol.InnerComment; .)
  | "OuterComment"                      (. sym = Symbol.OuterComment; .)
  | "Attribute"                         (. sym = Symbol.Attribute;    .)
  | "Resolver"                          (. sym = Symbol.Resolver;     .)
  | "Prolog"                            (. sym = Symbol.Prolog;       .)
  | "Epilog"                            (. sym = Symbol.Epilog;       .)
  | "Action"                            (. sym = Symbol.Action;       .)
  | "LineNumber"                        (. sym = Symbol.LineNumber;   .)
  )
.
 
Text
= '<'
  { ANY }
  '>'
.
 
END PrintyConfig.
 
See Also
Created with a demo version of Doc-O-Matic. This version is supplied for evaluation purposes only, do not distribute this documentation. To obtain a commercial license please see http://www.doc-o-matic.com/purchase.html.
Copyright (c) 2005. All rights reserved.