NTP Analyzer  0.8.2
Analyze the operation of time servers
Ntp.Analyzer.Config.Syntax.StatSyntaxNode Class Reference
Inheritance diagram for Ntp.Analyzer.Config.Syntax.StatSyntaxNode:
Collaboration diagram for Ntp.Analyzer.Config.Syntax.StatSyntaxNode:

Public Member Functions

 StatSyntaxNode (Symbol symbol, string name, int line)
 
- Public Member Functions inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< StatConfiguration >
void Add (ISyntaxNode node)
 
void Assemble (ISyntaxNode node)
 
Compile ()
 
void CompileNode ()
 
IEnumerator< ISyntaxNodeGetEnumerator ()
 
void Resolve (SymbolTable table)
 
void Validate (SymbolTable table)
 

Protected Member Functions

override StatConfiguration InternalCompile ()
 
override void InternalResolve (SymbolTable table)
 
override void ValidateMandatories ()
 Override to validates the mandatory types in this syntax node. More...
 
override void ValidateReferences (SymbolTable table)
 
override void ValidateTypes ()
 Override to validates the types in this syntax node. More...
 
- Protected Member Functions inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< StatConfiguration >
 SyntaxNode (Symbol symbol, string name, int line, bool requirePath=false)
 
void AddError (string message)
 
void AddReferenceNameError (ISyntaxNode node, string keyword, string name)
 
void AddReferenceTypeError (ISyntaxNode node, string keyword, string section, string name)
 
void CheckAllIsPresent (IEnumerable< Symbol > list)
 
void CheckIsUnique (IEnumerable< Symbol > list)
 
Uri CheckLink (string link, string keyword)
 
void CheckOneIsPresent (IEnumerable< Symbol > list)
 
void CheckOnlyOneIsPresent (IEnumerable< Symbol > list)
 
void CheckTypeIs< TU > (Symbol symbol)
 
void CheckTypeIs< TU, TV > (Symbol symbol)
 
virtual void InternalResolve (SymbolTable table)
 Override to resolve references to other syntax nodes from this syntax node. More...
 
virtual void ValidateReferences (SymbolTable table)
 Override to validates the references in this syntax node. More...
 

Private Attributes

ReadingSyntaxNode bulk
 

Additional Inherited Members

- Public Attributes inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< StatConfiguration >
ConfigurationNode CompiledNode
 
IEnumerable< string > Errors
 
bool HasErrors
 
- Properties inherited from Ntp.Analyzer.Config.Syntax.SyntaxNode< StatConfiguration >
int Line [get]
 
string Name [get]
 
List< ISyntaxNodeNodes [get]
 
bool RequirePath [get]
 
Symbol Symbol [get]
 

Detailed Description

Definition at line 31 of file StatSyntaxNode.cs.

Constructor & Destructor Documentation

Ntp.Analyzer.Config.Syntax.StatSyntaxNode.StatSyntaxNode ( Symbol  symbol,
string  name,
int  line 
)
inline

Definition at line 33 of file StatSyntaxNode.cs.

34  : base(symbol, name, line)
35  {
36  }

Member Function Documentation

override StatConfiguration Ntp.Analyzer.Config.Syntax.StatSyntaxNode.InternalCompile ( )
inlineprotectedvirtual

Implements Ntp.Analyzer.Config.Syntax.SyntaxNode< StatConfiguration >.

Definition at line 40 of file StatSyntaxNode.cs.

41  {
42  var initialRun = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordInitialRun) as BooleanSettingNode;
43  var fixedRun = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordFixedRun) as BooleanSettingNode;
44  var stamp = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordTimeStamp) as TimeStampNode;
45 
46  var freq = bulk == null
47  ? Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordFrequency) as IntegerSettingNode
48  : null;
49 
50  if (Symbol != Symbol.KeywordDriftStats)
51  return new StatConfiguration(
52  Name,
53  bulk?.Compile(),
54  stamp?.DateTimeKind,
55  freq?.Value,
56  initialRun?.Value,
57  fixedRun?.Value);
58 
59  var file = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordFile) as StringSettingNode;
60 
61  return new DriftStatConfiguration(
62  Name,
63  file?.Value,
64  bulk?.Compile(),
65  stamp?.DateTimeKind,
66  freq?.Value,
67  initialRun?.Value,
68  fixedRun?.Value);
69  }
override void Ntp.Analyzer.Config.Syntax.StatSyntaxNode.InternalResolve ( SymbolTable  table)
inlineprotected

Definition at line 71 of file StatSyntaxNode.cs.

References Ntp.Analyzer.Config.Table.SymbolTable.Lookup().

72  {
73  var freq = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordFrequency) as StringSettingNode;
74  if (freq != null)
75  bulk = table.Lookup(freq.Value) as ReadingSyntaxNode;
76  }
ISyntaxNode Lookup(string name)
Definition: SymbolTable.cs:41

Here is the call graph for this function:

override void Ntp.Analyzer.Config.Syntax.StatSyntaxNode.ValidateMandatories ( )
inlineprotectedvirtual

Override to validates the mandatory types in this syntax node.

When overriding this method do not call the base method.

Reimplemented from Ntp.Analyzer.Config.Syntax.SyntaxNode< StatConfiguration >.

Definition at line 78 of file StatSyntaxNode.cs.

79  {
80  CheckIsUnique(new List<Symbol>
81  {
82  Symbol.KeywordInitialRun,
83  Symbol.KeywordFixedRun,
84  Symbol.KeywordFrequency,
85  Symbol.KeywordTimeStamp,
86  Symbol.KeywordFile
87  });
88 
89  CheckAllIsPresent(new List<Symbol> {Symbol.KeywordFrequency});
90 
91  if (Symbol == Symbol.KeywordDriftStats)
92  {
93  CheckAllIsPresent(new List<Symbol> {Symbol.KeywordFile});
94  }
95  }
override void Ntp.Analyzer.Config.Syntax.StatSyntaxNode.ValidateReferences ( SymbolTable  table)
inlineprotected

Definition at line 97 of file StatSyntaxNode.cs.

References Ntp.Analyzer.Config.Table.Keyword.Find(), Ntp.Analyzer.Config.Table.SymbolTable.Lookup(), and Ntp.Analyzer.Config.Table.Keyword.Name.

98  {
99  string keyword = Keyword.Find(Symbol.KeywordFrequency).Name;
100  string name = Keyword.Find(Symbol.KeywordReading).Name;
101 
102  var freq = Nodes.SingleOrDefault(n => n.Symbol == Symbol.KeywordFrequency);
103  if (!(freq is IntegerSettingNode || freq is StringSettingNode))
104  {
105  AddError($"{keyword} must be either an integer value or the name of a {name} section.");
106  }
107 
108  var freqName = freq as StringSettingNode;
109  if (freqName == null)
110  return;
111 
112  var reference = table.Lookup(freqName.Value);
113  if (reference == null)
114  {
115  AddReferenceNameError(freqName, keyword, freqName.Value);
116  }
117  else if (!(reference is ReadingSyntaxNode))
118  {
119  AddReferenceTypeError(freqName, keyword, name, freqName.Value);
120  }
121 
122  if (Symbol == Symbol.KeywordDriftStats || Nodes.Count(n => n.Symbol == Symbol.KeywordFile) == 0)
123  return;
124 
125  string fileKeyword = Keyword.Find(Symbol.KeywordFile).Name;
126  string sectionKeyword = Keyword.Find(Symbol).Name;
127  AddError($"{fileKeyword} is not a valid setting in a {sectionKeyword} section.");
128  }
void AddReferenceTypeError(ISyntaxNode node, string keyword, string section, string name)
Definition: SyntaxNode.cs:441
static Keyword Find(Symbol symbol)
Definition: Keyword.cs:216
void AddReferenceNameError(ISyntaxNode node, string keyword, string name)
Definition: SyntaxNode.cs:428
ISyntaxNode Lookup(string name)
Definition: SymbolTable.cs:41

Here is the call graph for this function:

override void Ntp.Analyzer.Config.Syntax.StatSyntaxNode.ValidateTypes ( )
inlineprotectedvirtual

Override to validates the types in this syntax node.

When overriding this method do not call the base method.

Reimplemented from Ntp.Analyzer.Config.Syntax.SyntaxNode< StatConfiguration >.

Definition at line 130 of file StatSyntaxNode.cs.

131  {
132  CheckTypeIs<BooleanSettingNode>(Symbol.KeywordInitialRun);
133  CheckTypeIs<BooleanSettingNode>(Symbol.KeywordFixedRun);
134  CheckTypeIs<TimeStampNode>(Symbol.KeywordTimeStamp);
135  CheckTypeIs<IntegerSettingNode, StringSettingNode>(Symbol.KeywordFrequency);
136  CheckTypeIs<StringSettingNode>(Symbol.KeywordFile);
137  }

Member Data Documentation

ReadingSyntaxNode Ntp.Analyzer.Config.Syntax.StatSyntaxNode.bulk
private

Definition at line 38 of file StatSyntaxNode.cs.


The documentation for this class was generated from the following file: