本文整理匯總了C#中PerCederberg.Grammatica.Runtime.Production類的典型用法代碼示例。如果您正苦於以下問題:C# Production類的具體用法?C# Production怎麽用?C# Production使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
Production類屬於PerCederberg.Grammatica.Runtime命名空間,在下文中一共展示了Production類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: ExitPlayerNameAttribute
public override Node ExitPlayerNameAttribute(Production node)
{
var values = GetChildValues(node);
if(values.Count != 0)
node.AddValue(new PlayerName() { Value = (string)values[0] });
return node;
}
示例2: ExitExamples
public override Node ExitExamples(Production node)
{
var table = GetChildValues(node).Cast<Table>().Single();
node.AddValue(table);
return node;
}
示例3: Child
/**
* <summary>Called when adding a child to a parse tree
* node.</summary>
*
* <param name='node'>the parent node</param>
* <param name='child'>the child node, or null</param>
*
* <exception cref='ParseException'>if the node analysis
* discovered errors</exception>
*/
public override void Child(Production node, Node child)
{
switch (node.Id) {
case (int) IrfConstants.IRF_DOCUMENT:
ChildIrfDocument(node, child);
break;
case (int) IrfConstants.ROOT_NODE:
ChildRootNode(node, child);
break;
case (int) IrfConstants.USER_NODE:
ChildUserNode(node, child);
break;
case (int) IrfConstants.PLAYER_NOTE_NODE:
ChildPlayerNoteNode(node, child);
break;
case (int) IrfConstants.PLAYER_NAME_ATTRIBUTE:
ChildPlayerNameAttribute(node, child);
break;
case (int) IrfConstants.NOTE_TEXT_ATTRIBUTE:
ChildNoteTextAttribute(node, child);
break;
case (int) IrfConstants.TIMESTAMP_ATTRIBUTE:
ChildTimestampAttribute(node, child);
break;
case (int) IrfConstants.CLASSIFICATION_ATTRIBUTE:
ChildClassificationAttribute(node, child);
break;
}
}
示例4: ExitFeature
public override Node ExitFeature(Production node)
{
var values = GetChildValues(node);
var tags = (IEnumerable<string>) null;
int summaryLinesIndex = 0;
if (values[0] is IEnumerable<string>)
{
tags = values[0] as IEnumerable<string>;
summaryLinesIndex++;
}
var summaryLines = values[summaryLinesIndex] as IList<LineValue>;
var background = values[summaryLinesIndex + 1] as Background;
var featureIndex = summaryLinesIndex + (background == null ? 1 : 2);
// Rest of values are FeatureItems
var items = values.GetRange(featureIndex, values.Count - featureIndex).Cast<FeatureItem>().ToList();
var feature = new Feature(summaryLines, background, items, tags)
{
// TODO: Should this get a value?
Description = ""
};
node.AddValue(feature);
return node;
}
示例5: ExitClassificationAttribute
public override Node ExitClassificationAttribute(Production node)
{
var values = GetChildValues(node);
if (values.Count != 0)
{
Classification value = (Classification)int.Parse((string)values[0]);
node.AddValue(value);
}
return node;
}
示例6: ExitText
public override Node ExitText(Production node)
{
Node child = null;
for (int i = 0; i < node.GetChildCount(); i++)
{
child = node.GetChildAt(i);
HTML = HTML + child.GetValue(0);
//System.Console.WriteLine();
}
return base.ExitText(node);
}
示例7: Child
/**
* <summary>Called when adding a child to a parse tree
* node.</summary>
*
* <param name='node'>the parent node</param>
* <param name='child'>the child node, or null</param>
*
* <exception cref='ParseException'>if the node analysis
* discovered errors</exception>
*/
public override void Child(Production node, Node child)
{
switch (node.Id) {
case (int) CommandGrammarConstants.COMMANDS:
ChildCommands(node, child);
break;
case (int) CommandGrammarConstants.COMMAND:
ChildCommand(node, child);
break;
case (int) CommandGrammarConstants.EXPRESSION:
ChildExpression(node, child);
break;
}
}
示例8: ExitBackground
public override Node ExitBackground(Production node)
{
var values = GetChildValues(node);
// First value is either title from header or first FeatureStep
var title = values[0] as string;
var featureIndex = title == null ? 0 : 1;
// Rest of values are FeatureSteps
var steps = values.GetRange(featureIndex, values.Count - featureIndex).Cast<Step>().ToList();
var background = new Background(steps)
{
Title = title,
LineNumber = node.StartLine
};
node.AddValue(background);
return node;
}
示例9: ExitPlayerNoteNode
public override Node ExitPlayerNoteNode(Production node)
{
var values = GetChildValues(node);
if (values.Count != 0)
{
IrfNote note = new IrfNote();
note.PlayerName = (PlayerName)values[0];
for (int i = 1; i < values.Count; i++)
{
object value = values[i];
if (value is NoteText)
note.NoteText = (NoteText)value;
else if (value is DateTime)
note.DateTime = (DateTime)value;
else if (value is Classification)
note.Classification = (Classification)value;
}
node.AddValue(note);
}
return node;
}
示例10: ExitVoiceAction
public override Node ExitVoiceAction(Production node)
{
node.Values.AddRange(GetChildValues(node));
return node;
}
示例11: ExitValue
public override Node ExitValue(Production node)
{
System.Collections.ArrayList values = GetChildValues (node);
if (values.Count > 1) {
//position=value
string positionValue = "";
for (int i = 0; i < values.Count; i++) {
positionValue += values [i];
}
node.Values.Add (positionValue);
} else {
node.Values.AddRange(GetChildValues(node));
}
/*
Console.Write ("Value: ");
for (int i = 0; i < node.Values.Count; i++) {
Console.Write ("[" + i + "]" + node.Values[i] + " ");
}
Console.Write ("\n");
*/
return node;
}
示例12: ExitOption
public override Node ExitOption(Production node)
{
node.Values.AddRange(GetChildValues(node));
//Option action
Action optionAction = new Action (ScriptKeyword.OPTION, new Dictionary<string, string>(){
{ScriptKeyword.ID, node.Values[1].ToString()}
});
actions.Add (optionAction);
/*
Console.Write ("Option: ");
for (int i = 0; i < node.Values.Count; i++) {
Console.Write ("[" + i + "]" + node.Values[i] + " ");
}
Console.Write ("\n");
*/
return node;
}
示例13: ExitTableColumn
public override Node ExitTableColumn(Production node)
{
var cell = GetChildValues(node).Cast<string>().Single().Trim();
var column = new Cell(cell);
node.AddValue(column);
return node;
}
示例14: ExitStep
public override Node ExitStep(Production node)
{
var values = GetChildValues(node);
if (values.Count > 0)
{
var kindWord = (string) values[0];
CurrentStepKind = LookupStepKind(kindWord);
var stepBody = (string) values[1];
var table = (Table) null;
if (values.Count > 2)
table = (Table)values[3];
var step = new Step(table)
{
KindWord = kindWord,
Kind = CurrentStepKind,
Body = stepBody,
LineNumber = node.StartLine
};
node.AddValue(step);
}
return node;
}
示例15: ExitTimestampAttribute
public override Node ExitTimestampAttribute(Production node)
{
var values = GetChildValues(node);
if (values.Count != 0)
{
long seconds = long.Parse((string)values[0]);
node.AddValue(TimestampHelper.GetDateTime(seconds));
}
return node;
}