• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Parsing.LanguageData类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中Irony.Parsing.LanguageData的典型用法代码示例。如果您正苦于以下问题:C# LanguageData类的具体用法?C# LanguageData怎么用?C# LanguageData使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



LanguageData类属于Irony.Parsing命名空间,在下文中一共展示了LanguageData类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: SetUp

 public void SetUp()
 {
     var grammar = new CustomDslGrammar();
     var language = new LanguageData(grammar);
     _parser = new Parser(language);
     _visitor = new CSharpExpressionBuilder();
 }
开发者ID:calebjenkins,项目名称:presentations,代码行数:7,代码来源:CustomDslCSharpExpressionVisitorTest.cs


示例2: ScriptApp

    public ParseTree LastScript { get; private set; } //the root node of the last executed script


    #region Constructors
    public ScriptApp(LanguageData language) {
      Language = language;
      var grammar = language.Grammar as InterpretedLanguageGrammar;
      Runtime = grammar.CreateRuntime(language);
      DataMap = new AppDataMap(Language.Grammar.CaseSensitive); 
      Init(); 
    }
开发者ID:androdev4u,项目名称:XLParser,代码行数:11,代码来源:ScriptApp.cs


示例3: ExpressionEvaluator

 //Default constructor, creates default evaluator 
 public ExpressionEvaluator(ExpressionEvaluatorGrammar grammar) {
   Grammar = grammar;
   Language = new LanguageData(Grammar);
   Parser = new Parser(Language);
   Runtime = Grammar.CreateRuntime(Language);
   App = new ScriptApp(Runtime);
 }
开发者ID:Rezura,项目名称:LiveSplit,代码行数:8,代码来源:ExpressionEvaluator.cs


示例4: Parser

        /// <summary>
        /// Initializes a new instance of the <see cref="Parser"/> class.
        /// </summary>
        /// <param name="language">The language.</param>
        /// <param name="scanner">The scanner.</param>
        /// <param name="root">The root.</param>
        /// <exception cref="Exception">
        ///   </exception>
        public Parser(LanguageData language, Scanner scanner, NonTerminal root)
        {
            Language = language;
            Context = new ParsingContext(this);
            Scanner = scanner ?? language.CreateScanner();

            if (Scanner != null)
            {
                Scanner.Initialize(this);
            } 
            else
            {
                Language.Errors.Add(GrammarErrorLevel.Error, null, "Scanner is not initialized for this grammar");
            }
            CoreParser = new CoreParser(this);
            Root = root;
            if (Root == null)
            {
                Root = Language.Grammar.Root;
                InitialState = Language.ParserData.InitialState;
            }
            else
            {
                if (Root != Language.Grammar.Root && !Language.Grammar.SnippetRoots.Contains(Root))
                {
                    throw new Exception(string.Format(Resources.ErrRootNotRegistered, root.Name));
                }

                InitialState = Language.ParserData.InitialStates[Root];
            }
        }
开发者ID:cg123,项目名称:xenko,代码行数:39,代码来源:Parser.cs


示例5: Parse

        public static ParseTreeNode Parse(string src)
        {
            if (IsValid(src, new KISGrammer()))
            {
                var x = GetRoot(src, new KISGrammer());

                // DispTree(x, 100);
                return x;
            }
            else
            {
                LanguageData language = new LanguageData(new KISGrammer());

                Parser parser = new Parser(language);

                ParseTree parseTree = parser.Parse(src);

                foreach (var i in parseTree.ParserMessages)
                {
                    ErrorStack.Add(i.Message + " on line: " + (i.Location.Line + 1) + " Column: " + (i.Location.Column + 1) + " at Position: " + (i.Location.Position + 1));
                }

                return null;
            }
        }
开发者ID:Myvar,项目名称:PashOS,代码行数:25,代码来源:KISParser.cs


示例6: Setup

 public void Setup()
 {
     _grammar = new TestGrammar();
       _language = new LanguageData(_grammar);
       _parser = new Parser(_language);
       _context = _parser.Context;
 }
开发者ID:cubean,项目名称:CG,代码行数:7,代码来源:_TerminalTestBase.cs


示例7: ScriptInterpreter

 public ScriptInterpreter(LanguageData language) {
   Language = language;
   Runtime = Language.Grammar.CreateRuntime(Language);
   Parser = new Parser(Language);
   EvaluationContext = new EvaluationContext(Runtime);
   Status = _internalStatus = InterpreterStatus.Ready;
 }
开发者ID:cg123,项目名称:xenko,代码行数:7,代码来源:ScriptInterpreter.cs


示例8: Apply

 public override void Apply(LanguageData language, LRItem owner) {
   var state = owner.State;
   var conflicts = state.BuilderData.Conflicts;
   if (conflicts.Count == 0) return;
   switch (ActionType) {
     case PreferredActionType.Shift:
       var currTerm = owner.Core.Current as Terminal;
       if (currTerm == null || !conflicts.Contains(currTerm)) return; //nothing to do
       //Current term for shift item (hint owner) is a conflict - resolve it with shift action
       var newState = owner.ShiftedItem.State;
       var shiftAction = new ShiftParserAction(owner);
       state.Actions[currTerm] = shiftAction;
       conflicts.Remove(currTerm);
       return;
     case PreferredActionType.Reduce:
       if (!owner.Core.IsFinal) return; //we take care of reduce items only here
       //we have a reduce item with "Reduce" hint. Check if any of lookaheads are in conflict
       ReduceParserAction reduceAction = null;
       foreach (var lkhead in owner.Lookaheads)
         if (conflicts.Contains(lkhead)) {
           if (reduceAction == null)
             reduceAction = new ReduceParserAction(owner.Core.Production);
           state.Actions[lkhead] = reduceAction;
           conflicts.Remove(lkhead);
         }
       return;
   }//switch
 }//method
开发者ID:kayateia,项目名称:climoo,代码行数:28,代码来源:PreferredActionHint.cs


示例9: PrintTerminals

 public static string PrintTerminals(LanguageData language)
 {
     var termList = language.GrammarData.Terminals.ToList();
     termList.Sort((x, y) => string.Compare(x.Name, y.Name));
     var result = string.Join(Environment.NewLine, termList);
     return result;
 }
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:7,代码来源:ParserDataPrinter.cs


示例10: InternCreateScriptApp

        protected static MtCompiler InternCreateScriptApp(Stream output, Stream debugStream)
        {
            var grammar = new MtGrammar();
            var lang = new LanguageData(grammar);
            var parser = new Parser(grammar);
            var runtime = grammar.CreateRuntime(lang) as MultiTasksRuntime;

            if (output != null)
            {
                runtime.OutputStream = output;
            }
            #if DEBUG && !SILVERLIGHT

            if (debugStream != null)
            {
                // Add as a listener to debug
                var listener = new TextWriterTraceListener(debugStream);
                Debug.Listeners.Add(listener);
            }

            #endif
            var app = new ScriptApp(runtime);

            // Add constants
            app.Globals.Add("TRUE", MtResult.True);
            app.Globals.Add("FALSE", MtResult.False);

            #if DEBUG && !SILVERLIGHT
            MultiTasksRuntime.DebugDisplayInfo();
            #endif

            return new MtCompiler(app);
        }
开发者ID:fabriceleal,项目名称:Multitasks,代码行数:33,代码来源:MultiTasksCompiler.cs


示例11: Main

 static void Main(string[] args) {
   Console.Title = "Irony Console Sample";
   Console.WriteLine("Irony Console Sample.");
   Console.WriteLine("");
   Console.WriteLine("Select a grammar to load:");
   Console.WriteLine("  1. Expression Evaluator");
   Console.WriteLine("  2. mini-Python");
   Console.WriteLine("  Or press any other key to exit.");
   Console.WriteLine("");
   Console.Write("?");
   var choice = Console.ReadLine();
   Grammar grammar; 
   switch (choice) {
     case "1": 
       grammar = new SampleExpressionEvaluatorGrammar();
       break;
     case "2":
       grammar = new MiniPython.MiniPythonGrammar();
       break; 
     default:
       return;
   }
   Console.Clear();
   var language = new LanguageData(grammar);
   var runtime = new LanguageRuntime(language);
   var commandLine = new CommandLine(runtime);
   commandLine.Run();
 }
开发者ID:androdev4u,项目名称:XLParser,代码行数:28,代码来源:Program.cs


示例12: 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


示例13: Setup

        public void Setup()
        {
            var grammar = new XamlMarkupExtensionGrammar();
            var language = new LanguageData(grammar);

            _parser = new Parser(language) {Context = {TracingEnabled = true}};
        }
开发者ID:NicoVermeir,项目名称:XamlStyler,代码行数:7,代码来源:XamlMarkupExtensionGrammarUnitTests.cs


示例14: LanguageRuntime

 public LanguageRuntime(LanguageData language)
 {
     Language = language;
     NoneValue = NoneClass.Value;
     BuiltIns = new BindingSourceTable(Language.Grammar.CaseSensitive);
     Init();
 }
开发者ID:HyperSharp,项目名称:Hyperspace.DotLua,代码行数:7,代码来源:LanguageRuntime.cs


示例15: AssemblyBlock

        public bool AssemblyBlock(eBLOCK200_BLOCKTYPES blockType, int blockNr, eBLOCK200_OB_VERSIONS blockVer, 
            bool forceExpandedFormat, bool bNoWizardInfo, bool bUseChineseOpcode,
            string source, out byte[] dest)
        {
            dest = null;

            var server = new CoMsSig200Lib.Sig200ServerClass();
            Sig200SignatureList InsList = null;
            server.CreateInstructionSignatures(null);
            server.SetMnemonic(eSIG200_MNEMONICS.eSIG200_MNEMONIC_SIMATIC);
            server.GetInstructionSignatureList(ref InsList);

            var grammar = new STLCompiler.STLGrammar();
            LanguageData language = new LanguageData(grammar);
            Parser parser = new Parser(language);
            ParseTree parseTree = parser.Parse(source);
            ParseTreeNode root = parseTree.Root;

            var project = new STLCompiler.S7Project(root.AstNode as Block, server);
            var builder = new CoMsBlock200Lib.Block200Class() as IBlock200Fix;
            int pnOBSize, pnOBSizeNoWiz, pnDBArea3Size;

            builder.CalcBlockSizes(project, server,
                (int)eBLOCK200_OB_VERSIONS.eBLOCK200_OB_VERSION_2ND_GEN_5,
                2, /* Must 2, from reverse */
                out pnOBSize,
                out pnOBSizeNoWiz,
                out pnDBArea3Size);

            IntPtr ppbyDestBlock = Marshal.AllocCoTaskMem(pnOBSize);
            IntPtr ppbyEdgeData = IntPtr.Zero;
            int nDestBytes = pnOBSize, nEdges = 0;

            try
            {
                builder.AssembleBlock(project,
                server,
                (int)eBLOCK200_BLOCKTYPES.eBLOCK200_BLOCKTYPE_OB,
                1,
                (int)eBLOCK200_OB_VERSIONS.eBLOCK200_OB_VERSION_2ND_GEN_5,
                0,
                1,
                1,
                out ppbyDestBlock,
                out nDestBytes,
                out ppbyEdgeData,
                out nEdges);

                dest = new byte[nDestBytes];
                Marshal.Copy(ppbyDestBlock, dest, 0, nDestBytes);
             }
            catch(COMException e)
            {
                Console.Write(e.Message);
                return false;
            }

            return true;
        }
开发者ID:cubean,项目名称:CG,代码行数:59,代码来源:Compiler.cs


示例16: EditorAdapter

 public EditorAdapter(LanguageData language) {
   _parser = new Parser(language);
   _scanner = _parser.Scanner;
   _colorizerThread = new Thread(ColorizerLoop);
   _colorizerThread.IsBackground = true;
   _parserThread = new Thread(ParserLoop);
   _parserThread.IsBackground = true;
 }
开发者ID:Rezura,项目名称:LiveSplit,代码行数:8,代码来源:EditorAdapter.cs


示例17: 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


示例18: DqlQueryReader

 public DqlQueryReader(LanguageData languageData)
 {
     if (languageData == null)
     {
         throw new ArgumentNullException("languageData");
     }
     this.language = languageData;
 }
开发者ID:kellabyte,项目名称:Dazzle.NET,代码行数:8,代码来源:DqlQueryReader.cs


示例19: PrintTerminals

 public static string PrintTerminals(LanguageData language) {
   StringBuilder sb = new StringBuilder();
   foreach (Terminal term in language.GrammarData.Terminals) {
     sb.Append(term.ToString());
     sb.AppendLine();
   }
   return sb.ToString();
 }
开发者ID:o2platform,项目名称:O2.Platform.Projects,代码行数:8,代码来源:ParserDataPrinter.cs


示例20: SqlDefaultParser

        public SqlDefaultParser(SqlGrammarBase grammar)
        {
            languageData = new LanguageData(grammar);
            parser = new Irony.Parsing.Parser(languageData);

            if (!languageData.CanParse())
                throw new InvalidOperationException();
        }
开发者ID:prepare,项目名称:deveeldb,代码行数:8,代码来源:SqlDefaultParser.cs



注:本文中的Irony.Parsing.LanguageData类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Parsing.NonTerminal类代码示例发布时间:2022-05-26
下一篇:
C# Interpreter.ScriptThread类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap