本文整理汇总了C#中Irony.Parsing.ParseTree类的典型用法代码示例。如果您正苦于以下问题:C# ParseTree类的具体用法?C# ParseTree怎么用?C# ParseTree使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ParseTree类属于Irony.Parsing命名空间,在下文中一共展示了ParseTree类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: TryParse
public bool TryParse(string sourceText, out MarkupExtension graph)
{
graph = null;
try
{
ParseTree tree = _parser.Parse(sourceText);
#if DEBUG
// Save result tree for debugging purposes
LastParseTree = tree;
LastException = null;
#endif
if (tree.Status == ParseTreeStatus.Parsed)
{
graph = MarkupExtension.Create(tree.Root);
return true;
}
}
#if DEBUG
catch (Exception ex)
{
LastParseTree = null;
LastException = ex;
}
#else
catch
{
// ignored
}
#endif
return false;
}
开发者ID:NicoVermeir,项目名称:XamlStyler,代码行数:32,代码来源:MarkupExtensionParser.cs
示例2: BuildAst
public override void BuildAst(LanguageData language, ParseTree parseTree) {
var opHandler = new OperatorHandler(language.Grammar.CaseSensitive);
Util.Check(!parseTree.HasErrors(), "ParseTree has errors, cannot build AST.");
var astContext = new InterpreterAstContext(language, opHandler);
var astBuilder = new AstBuilder(astContext);
astBuilder.BuildAst(parseTree);
}
开发者ID:androdev4u,项目名称:XLParser,代码行数:7,代码来源:InterpretedLanguageGrammar.cs
示例3: BuildAst
public virtual void BuildAst(LanguageData language, ParseTree parseTree)
{
if (!LanguageFlags.IsSet(LanguageFlags.CreateAst))
return;
var astContext = new AstContext(language);
var astBuilder = new AstBuilder(astContext);
astBuilder.BuildAst(parseTree);
}
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:8,代码来源:Grammar.cs
示例4: NormalizeParseTree
private string NormalizeParseTree(ParseTree tree) {
StringBuilder fullString = new StringBuilder();
foreach (ParseTreeNode node in tree.Root.ChildNodes) {
fullString.Append(node.Token.Value);
}
fullString = fullString.Replace("\r\n", "\\n");
fullString = fullString.Replace("\n", "\\n");
return fullString.ToString();
}
开发者ID:Rezura,项目名称:LiveSplit,代码行数:9,代码来源:HeredocTerminalTests.cs
示例5: BuildAst
public virtual void BuildAst(ParseTree parseTree) {
if (parseTree.Root == null)
return;
Context.Messages = parseTree.ParserMessages;
if (!Context.Language.AstDataVerified)
VerifyLanguageData();
if (Context.Language.ErrorLevel == GrammarErrorLevel.Error)
return;
BuildAst(parseTree.Root);
}
开发者ID:androdev4u,项目名称:XLParser,代码行数:10,代码来源:AstBuilder.cs
示例6: ParseString
public Block ParseString(string Chunk)
{
var parseTree = parser.Parse(Chunk);
curParseTree = parseTree;
var root = parseTree.Root;
if (root == null)
{
var msg = parseTree.ParserMessages[0];
throw new LuaException("", msg.Location.Line, msg.Location.Column, msg.Message);
}
return (ParseBlock(root));
}
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:12,代码来源:Parser.cs
示例7: GetParserMessages
private string GetParserMessages(ParseTree parseTree)
{
var sb = new StringBuilder();
foreach (var message in parseTree.ParserMessages)
{
sb.AppendFormat("{0} at line {1}, column {2}", message.Message, message.Location.Line, message.Location.Column);
}
sb.AppendLine();
sb.AppendLine("Source Code:");
sb.AppendLine();
sb.Append(parseTree.SourceText);
return sb.ToString();
}
开发者ID:mayurshkl,项目名称:NCicode,代码行数:13,代码来源:CicodeFileTests.cs
示例8: ParseFile
public Block ParseFile(string Filename)
{
var source = File.ReadAllText(Filename);
var parseTree = parser.Parse(source, Filename);
curParseTree = parseTree;
var root = parseTree.Root;
if (root == null)
{
var msg = parseTree.ParserMessages[0];
throw new LuaException(Filename, msg.Location.Line, msg.Location.Column, msg.Message);
}
return (ParseBlock(root));
}
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:13,代码来源:Parser.cs
示例9: Refresh
public void Refresh(ParseTree tree)
{
var root = tree.Root;
if (root != null)
{
File = new LuaFile(FileManager.Instance.CurrentFile.File, tree.Tokens); ;
RefreshTree(root);
FileManager.Instance.CurrentFile = File;
System.Diagnostics.Debug.Print("file refreshed.");
}
}
开发者ID:peterdocter,项目名称:BabeLua,代码行数:14,代码来源:TreeParser.cs
示例10: Analyze
private Expression Analyze(ParseTree tree, CompilerState state)
{
if (tree == null)
{
throw new ArgumentNullException("tree");
}
if (tree.Status != ParseTreeStatus.Parsed)
{
throw new ArgumentException("Cannot build expression on incomplete tree");
}
var root = tree.Root;
return Analyze(root, state);
}
开发者ID:adrobyazko-softheme,项目名称:PQL,代码行数:15,代码来源:ExpressionEvaluatorRuntime(Compiler).cs
示例11: Read
/// <summary>
/// Reads a Dql query into an abstract syntax tree.
/// </summary>
/// <param name="query">Dql query.</param>
/// <param name="node">The current abstract syntax tree to construct.</param>
/// <returns>Time taken to build the abstract syntax tree in milliseconds.</returns>
public long Read(string query, out ParseTree node)
{
var parser = new Parser(language);
var tree = parser.Parse(query);
if (tree.HasErrors())
{
// TODO: Throw LQL errors.
throw new InvalidOperationException();
}
#if DEBUG
this.DisplayTree(tree.Root, 0);
#endif
node = tree;
return tree.ParseTimeMilliseconds;
}
开发者ID:kellabyte,项目名称:Dazzle.NET,代码行数:23,代码来源:DqlQueryReader.cs
示例12: ParseSample
public void ParseSample(string code)
{
if (parser == null || !parser.Language.CanParse()) return;
ParseTree = null;
GC.Collect(); //to avoid disruption of perf times with occasional collections
parser.Context.TracingEnabled = false;//parsetrace not needed for us
try {
parser.Parse(code, "<source>");
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
throw;
}
finally {
ParseTree = parser.Context.CurrentParseTree;
}
}
开发者ID:zackszhu,项目名称:ZodiacLanguage,代码行数:17,代码来源:GrammarAnalysizer.cs
示例13: GenerateCode
public CodeCompileUnit GenerateCode(ParseTree tree)
{
var generator = new RuleCodeGenerator();
var unit = new CodeCompileUnit();
var ns = new CodeNamespace(GetType().Namespace);
ns.Imports.Add(new CodeNamespaceImport(GetType().Namespace));
var rules = tree.Root.ChildNodes[0].ChildNodes;
var count = 1;
foreach (var rule in rules)
{
ns.Types.Add(generator.GenerateRuleClass("Rule" + count, rule));
count++;
}
unit.Namespaces.Add(ns);
return unit;
}
开发者ID:ByteCarrot,项目名称:Masslog,代码行数:18,代码来源:RulesCodeGenerator.cs
示例14: ConvertParseTreeToModel
public static LPModel ConvertParseTreeToModel(ParseTree tree)
{
string modelName = "";
var lpGoal = new LPGoal();
var lpConstraints = new List<LPConstraint>();
if (tree.Root.ToString() == "lpApp")
{
foreach (ParseTreeNode node in tree.Root.ChildNodes)
{
switch (node.ToString())
{
case "lpAppName":
modelName = ParseModelName(node);
break;
case "lpModel":
foreach (ParseTreeNode subNodes in node.ChildNodes)
{
switch (subNodes.ToString())
{
case "lpGoal":
lpGoal = ParseGoal(subNodes);
break;
case "lpConstraints":
lpConstraints = ParseConstraints(subNodes);
break;
}
}
break;
}
}
}
else
{
throw new Exception("The Root element is not Correct");
}
return new LPModel(modelName.Replace("(appIdentifier)", "").Replace(" ", ""), lpGoal, lpConstraints);
}
开发者ID:taesiri,项目名称:lpSolver,代码行数:39,代码来源:Modeler.cs
示例15: Generate
public void Generate(ParseTree parseTree) {
if (parseTree == null) return;
GeneratedOK = true;
defaultClass = ag.Public.Class("Default");
typeTable.Add("Default", defaultClass);
mainMethod = defaultClass.Public.Static.Method(typeof(void), "Main");
//generator stack
typeStack.Push(defaultClass);
funcStack.Push(mainMethod);
//InitIO();
InitRequiredType();
PushScope();
var ioOperand = mainMethod.Local(exp.New(typeTable["IO"]));
ParseNode(parseTree.Root);
if (GeneratedOK) {
ag.Save();
AppDomain.CurrentDomain.ExecuteAssembly(name + ".exe");
}
}
开发者ID:zackszhu,项目名称:ZodiacLanguage,代码行数:23,代码来源:CodeGenerator.cs
示例16: CreateParser
private void CreateParser()
{
ParseTree = null;
language = new LanguageData(grammar);
parser = new Parser(language);
}
开发者ID:zackszhu,项目名称:ZodiacLanguage,代码行数:6,代码来源:GrammarAnalysizer.cs
示例17: Evaluate
public object Evaluate(ParseTree parsedScript)
{
var result = App.Evaluate(parsedScript);
return result;
}
开发者ID:Rew,项目名称:SharpDevelop,代码行数:5,代码来源:ExpressionEvaluator.cs
示例18: Validate
public void Validate(ParseTree parseTree)
{
if (parseTree.HasErrors() && parseTree.ParserMessages.Count > 0)
{
var message = parseTree.ParserMessages[0];
var error = message.Message + " at " + message.Location.ToUiString();
throw new Exception(error);
}
}
开发者ID:paralect,项目名称:Schematra,代码行数:9,代码来源:SchematraGrammer.cs
示例19: RunSample
public override string RunSample(ParseTree parsedSample)
{
var converter = new WikiHtmlConverter();
var html = converter.Convert(this, parsedSample.Tokens);
var path = Path.Combine(Path.GetTempPath(), "@wikiSample.html");
File.WriteAllText(path, html);
System.Diagnostics.Process.Start(path);
return html;
}
开发者ID:cubean,项目名称:CG,代码行数:9,代码来源:WikiCodeplexGrammar.cs
示例20: ParseSample
private void ParseSample() {
ClearParserOutput();
if (_parser == null || !_parser.Language.CanParse()) return;
_parseTree = null;
GC.Collect(); //to avoid disruption of perf times with occasional collections
_parser.Context.TracingEnabled = chkParserTrace.Checked;
try {
_parser.Parse(txtSource.Text, "<source>");
} catch (Exception ex) {
gridCompileErrors.Rows.Add(null, ex.Message, null);
tabBottom.SelectedTab = pageParserOutput;
throw;
} finally {
_parseTree = _parser.Context.CurrentParseTree;
ShowCompilerErrors();
if (chkParserTrace.Checked) {
ShowParseTrace();
}
ShowCompileStats();
ShowParseTree();
ShowAstTree();
}
}
开发者ID:androdev4u,项目名称:XLParser,代码行数:23,代码来源:fmGrammarExplorer.cs
注:本文中的Irony.Parsing.ParseTree类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论