Пример #1
0
        public void Error(SyntaxType expected)
        {
            if (this.testModeLayer <= 0)
            {
                if (this.CurrentToken == null)
                {
                    return;
                }

                string text = expected.GetText();

                if (string.IsNullOrEmpty(text))
                {
                    return;
                }

                this.errorList.Add(new GLSLError($"{text} expected", this.CurrentToken.Span));

                SyntaxNode node = new SyntaxNode(this.tree, expected, this.snapshot.CreateTrackingSpan(this.CurrentToken.Span));

                node.IsMissing = true;

                this.stack.Peek().AddChild(node);
            }
        }
Пример #2
0
        private bool IsExpressionNode(SyntaxType type)
        {
            switch (type)
            {
            case SyntaxType.AssignmentExpression:
            case SyntaxType.ConditionalExpression:
            case SyntaxType.LogicalOrExpression:
            case SyntaxType.LogicalXorExpression:
            case SyntaxType.LogicalAndExpression:
            case SyntaxType.InclusiveOrExpression:
            case SyntaxType.ExclusiveOrExpression:
            case SyntaxType.AndExpression:
            case SyntaxType.EqualityExpression:
            case SyntaxType.RelationalExpression:
            case SyntaxType.ShiftExpression:
            case SyntaxType.AdditiveExpression:
            case SyntaxType.MultiplicativeExpression:
            case SyntaxType.UnaryExpression:
            case SyntaxType.PostfixExpression:
            case SyntaxType.Expression:
                return(true);

            default:
                return(false);
            }
        }
Пример #3
0
        public static char ToChar(SyntaxType type)
        {
            if (!Enum.IsDefined(typeof(SyntaxType), type))
            {
                return('\0');
            }
            if (type == SyntaxType.Add)
            {
                return('+');
            }
            if (type == SyntaxType.Subtract)
            {
                return('-');
            }
            if (type == SyntaxType.Multiply)
            {
                return('*');
            }
            if (type == SyntaxType.Divide)
            {
                return('/');
            }

            return('\0');
        }
Пример #4
0
 internal Token(string?Text, int Start, SyntaxType Type, object?Value)
 {
     this.Text  = Text;
     this.Start = Start;
     this.Type  = Type;
     this.Value = Value;
 }
        protected CompileTestsBase(SyntaxType syntaxType)
        {
#if NETCOREAPP
            TestsInitializer.Initialize();
#endif
#if NET452 || NET471 || NETCOREAPP
            var    appEnv            = PlatformServices.Default.Application;
            string baseDirectoryPath = Path.Combine(appEnv.ApplicationBasePath, "../../../");
#elif NET40
            string baseDirectoryPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "../../");
#else
#error No implementation for this target
#endif
            _filesDirectoryPath = Path.GetFullPath(Path.Combine(baseDirectoryPath, "../SharedFiles"));
            _syntaxType         = syntaxType;

            if (syntaxType == SyntaxType.Sass)
            {
                _fileExtension  = ".sass";
                _subfolderName  = "sass";
                _indentedSyntax = true;
            }
            else if (syntaxType == SyntaxType.Scss)
            {
                _fileExtension  = ".scss";
                _subfolderName  = "scss";
                _indentedSyntax = false;
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Пример #6
0
 /// <summary>
 /// 设置行类型
 /// </summary>
 /// <param name="rowid">行号</param>
 /// <param name="st">syntax类型</param>
 public void SetRow(int rowid, SyntaxType st)
 {
     if (0 <= rowid && rowid < this.rowCount)
     {
         leftNodesDict.Add(st, rowid);
     }
 }
Пример #7
0
 internal Token(SyntaxType type, Span span, SourceLine line, string text, SyntaxTrivia leadingTrivia)
 {
     this.SyntaxType    = type;
     this.Span          = span;
     this.Line          = line;
     this.Text          = text;
     this.LeadingTrivia = leadingTrivia;
 }
Пример #8
0
 public AbstractSyntaxObject()
 {
     this.Context    = string.Empty;
     this.Syntax     = new List <ISyntaxObject>();
     this.Elements   = new SyntaxElement();
     this.IsNullable = false;
     this.Type       = SyntaxType.SyntaxElement;
 }
Пример #9
0
        private Token MatchToken(SyntaxType type)
        {
            if (current.Type == type)
            {
                return(NextToken());
            }

            return(new Token(null, current.Start, type, null));
        }
Пример #10
0
        private void ReadNodeOrKeyword()
        {
            while (char.IsLetterOrDigit(current))
            {
                position++;
            }

            text = input.Slice(start, position);
            type = GetKeywordKind(text);
        }
Пример #11
0
        public static string GetText(this SyntaxType syntaxType)
        {
            string text;

            if (!lookupTable.TryGetValue(syntaxType, out text))
            {
                return(string.Empty);
            }

            return(text);
        }
Пример #12
0
        internal SyntaxToken(SyntaxTree tree, SyntaxType type, TrackingSpan span, string text, SyntaxTrivia leadingTrivia, SyntaxTrivia trailingTrivia, Snapshot snapshot, bool isMissing = false) : base(tree, type, span)
        {
            this.Text           = text;
            this.LeadingTrivia  = leadingTrivia;
            this.TrailingTrivia = trailingTrivia;

            int start = this.HasLeadingTrivia ? this.LeadingTrivia.Span.GetSpan(snapshot).Start : this.Span.GetSpan(snapshot).Start;
            int end   = this.HasTrailingTrivia ? this.TrailingTrivia.Span.GetSpan(snapshot).End : this.Span.GetSpan(snapshot).End;

            this.fullSpan  = snapshot.CreateTrackingSpan(GLSL.Text.Span.Create(start, end));
            this.IsMissing = isMissing;
        }
Пример #13
0
        internal static bool Contains(this SyntaxType[] array, SyntaxType type)
        {
            for (int i = 0; i < array.Length; i++)
            {
                if (array[i] == type)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #14
0
 public SyntaxConcept(
     SyntaxType type,
     string value,
     string script,
     int line,
     int column)
 {
     this.Type = type;
     this.Value = value;
     this.Script = script;
     this.Line = line;
     this.Column = column;
 }
Пример #15
0
 internal static FieldDefinition Create(SyntaxType type, string name, bool isArray)
 {
     if (isArray)
     {
         return(new FieldDefinition(null, new TypeDefinition(type), name, new List <ColoredString> {
             ColoredString.Create("[", ColorType.Punctuation), ColoredString.Create("]", ColorType.Punctuation)
         }, string.Empty, Scope.BuiltIn, null));
     }
     else
     {
         return(new FieldDefinition(null, new TypeDefinition(type), name, string.Empty, Scope.BuiltIn, null));
     }
 }
Пример #16
0
 public SyntaxConcept(
     SyntaxType type,
     string value,
     string script,
     int line,
     int column)
 {
     this.Type   = type;
     this.Value  = value;
     this.Script = script;
     this.Line   = line;
     this.Column = column;
 }
Пример #17
0
        public static ColoredString ToColoredString(this SyntaxType syntaxType)
        {
            string text = syntaxType.GetText();

            if (!string.IsNullOrEmpty(text))
            {
                return(ColoredString.Create(text, ColorType.Keyword));
            }
            else
            {
                return(null);
            }
        }
        public static DddTokenTypes ConceptToToken(SyntaxType syntax)
        {
            switch (syntax)
            {
            case SyntaxType.Keyword:
                return(DddTokenTypes.Keyword);

            case SyntaxType.Identifier:
                return(DddTokenTypes.Identifier);

            default:
                return(DddTokenTypes.StringQuote);
            }
        }
Пример #19
0
        private void ReadNumber()
        {
            var start      = position;
            var hasDecimal = false;

            if (current == '-')
            {
                position++;
            }

            while (char.IsDigit(current) || current == '_' || current == '.')
            {
                if (current == '.' && hasDecimal)
                {
                    hasDecimal = true;
                    position++;
                }
                else
                {
                    position++;
                }
            }

            var t = input.Slice(start, position);

            //double? val = Convert.ToDouble(t);
            if (double.TryParse(t, out double val))
            {
                value = val;
                type  = SyntaxType.NUMBER_TOKEN;
            }
            else
            {
                var span  = new TextSpan(start, position);
                var piece = new TextPiece(input, span);

                Error("Invalid number", piece);
            }

            /*if (!val.HasValue)
             * {
             *  var span = new TextSpan(start, position);
             *  var loc = new TextLocation(input, span);
             *
             *  Error("Invalid number", loc);
             * }
             *
             * value = val;
             * type = SyntaxType.NUMBER_TOKEN;*/
        }
Пример #20
0
 public static string ToString(SyntaxType syntax)
 {
     return(syntax switch
     {
         SyntaxType.PlainText => "Text",
         SyntaxType.CPlusPlus => "C++",
         SyntaxType.CSharp => "C#",
         SyntaxType.HTML => "HTML",
         SyntaxType.Java => "Java",
         SyntaxType.JavaScript => "JavaScript",
         SyntaxType.PHP => "PHP",
         SyntaxType.Tex => "Tex",
         SyntaxType.XML => "XML",
         SyntaxType.Python => "Python",
         _ => "Text"
     });
Пример #21
0
        private Data.Field.Index GetIndexType(SyntaxType syntaxType)
        {
            switch (syntaxType)
            {
            case SyntaxType.NONE:
                return(Hubble.Core.Data.Field.Index.None);

            case SyntaxType.TOKENIZED:
                return(Hubble.Core.Data.Field.Index.Tokenized);

            case SyntaxType.UNTOKENIZED:
                return(Hubble.Core.Data.Field.Index.Untokenized);

            default:
                return(Hubble.Core.Data.Field.Index.None);
            }
        }
Пример #22
0
 /// <summary>
 /// 取得节点的处理函数
 /// </summary>
 /// <param name="left">语法类型</param>
 /// <param name="leave">Token类型</param>
 /// <param name="nilserver">空节点展开式处理函数</param>
 /// <returns>候选式实例</returns>
 public CandidateFunction GetCFunction(SyntaxType left, TokenType leave, iHandle nilserver)
 {
     try
     {
         if (left == SyntaxType.epsilonLeave)
         {
             return new CandidateFunction(nilserver, CFunctionType.umi_epsilon);
         }
         CandidateFunction candidator = this.GetCFunction(this.leftNodesDict[left], this.nextLeavesDict[leave]);
         return candidator == null ? new CandidateFunction(null, CFunctionType.umi_errorEnd) : candidator;
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         Console.WriteLine(String.Format("{0} --> {1}", left.ToString(), leave.ToString()));
         throw;
     }
 }
Пример #23
0
 /// <summary>
 /// 取得节点的处理函数
 /// </summary>
 /// <param name="left">语法类型</param>
 /// <param name="leave">Token类型</param>
 /// <param name="nilserver">空节点展开式处理函数</param>
 /// <returns>候选式实例</returns>
 public CandidateFunction GetCFunction(SyntaxType left, TokenType leave, iHandle nilserver)
 {
     try
     {
         if (left == SyntaxType.epsilonLeave)
         {
             return(new CandidateFunction(nilserver, CFunctionType.umi_epsilon));
         }
         CandidateFunction candidator = this.GetCFunction(this.leftNodesDict[left], this.nextLeavesDict[leave]);
         return(candidator ?? new CandidateFunction(null, CFunctionType.umi_errorEnd));
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.ToString());
         Console.WriteLine(String.Format("{0} --> {1}", left.ToString(), leave.ToString()));
         throw;
     }
 }
Пример #24
0
        private void ReadString()
        {
            position++;

            var sb   = "";
            var done = false;

            while (!done)
            {
                switch (current)
                {
                case '\0':
                case '\r':
                case '\n':
                    var span  = new TextSpan(start, 1);
                    var piece = new TextPiece(input, span);

                    Error("Unterminated string", piece);
                    done = true;
                    break;

                case '"':
                    if (peek == '"')
                    {
                        sb       += current;
                        position += 2;
                    }
                    else
                    {
                        position++;
                        done = true;
                    }
                    break;

                default:
                    sb += current;
                    position++;
                    break;
                }
            }

            type  = SyntaxType.STRING_TOKEN;
            value = sb;
        }
Пример #25
0
        private SyntaxToken CreateToken(SyntaxType type, TrackingSpan span, bool isMissing = false)
        {
            if (type == SyntaxType.IdentifierToken)
            {
                if (isMissing)
                {
                    return(new IdentifierSyntax(this.tree, span, string.Empty, null, null, this.snapshot, isMissing));
                }

                return(new IdentifierSyntax(this.tree, span, this.CurrentToken.Text, this.CurrentToken.LeadingTrivia, this.CurrentToken.TrailingTrivia, this.snapshot, isMissing));
            }
            else
            {
                if (isMissing)
                {
                    return(new SyntaxToken(this.tree, type, span, string.Empty, null, null, this.snapshot, isMissing));
                }

                return(new SyntaxToken(this.tree, type, span, this.CurrentToken.Text, this.CurrentToken.LeadingTrivia, this.CurrentToken.TrailingTrivia, this.snapshot));
            }
        }
        protected PhysicalFileSystemTestsBase(SyntaxType syntaxType)
        {
            _currentDirectory = Path.GetDirectoryName(this.GetType().Assembly.Location);

            if (syntaxType == SyntaxType.Sass)
            {
                _fileExtension  = ".sass";
                _subfolderName  = "sass";
                _indentedSyntax = true;
            }
            else if (syntaxType == SyntaxType.Scss)
            {
                _fileExtension  = ".scss";
                _subfolderName  = "scss";
                _indentedSyntax = false;
            }
            else
            {
                throw new NotSupportedException();
            }
        }
Пример #27
0
        public SyntaxReader(SyntaxType syntax)
        {
            string fileResouce = "";

            switch (syntax)
            {
                case SyntaxType.CSharp:
                    fileResouce = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Resources.cs.syntax";
                    break;
                case SyntaxType.VBNet:
                    fileResouce = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Resources.vb.syntax";
                    break;
                default:
                    throw new Exception("Syntax not catered for.");
            }
            using (Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(fileResouce))
            {
                TextReader tr = new StreamReader(s);
                TheFile = tr.ReadToEnd();
            }
            FillArrays();
        }
Пример #28
0
        protected CompileTestsBase(SyntaxType syntaxType)
        {
            if (syntaxType == SyntaxType.Sass)
            {
                _fileExtension = ".sass";
                _subfolderName = "sass";
                _indentedSyntax = true;
            }
            else if (syntaxType == SyntaxType.Scss)
            {
                _fileExtension = ".scss";
                _subfolderName = "scss";
                _indentedSyntax = false;
            }
            else
            {
                throw new NotSupportedException();
            }

            _resourcesDirectoryPath = Path.GetFullPath(
                Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"../../Resources/"));
        }
Пример #29
0
        public SyntaxException(string message, object curSyntax, DFAException e, LexicalAnalysis.Lexical.Token token)
            : base(message, e)
        {
            _State = e.State;

            try
            {
                _SyntaxType = (SyntaxType)e.Action;
            }
            catch
            {
            }

            _Word = token.Text;

            _Row = token.Row;
            _Col = token.Col;

            if (curSyntax != null)
            {
                _CurrentSyntax = curSyntax.GetType().Name;
            }
        }
Пример #30
0
        public static SyntaxHighlighter GetHighlighter(SyntaxType synType)
        {
            SyntaxHighlighter sh = null;

            switch (synType)
            {
            case SyntaxType.CSharp:
                sh = new CSharpHighlighter();
                break;

            case SyntaxType.HTML:
                sh = new HTMLHighlighter();
                break;

            case SyntaxType.VisualBasic:
                break;

            default:
                break;
            }

            return(sh);
        }
Пример #31
0
        public SyntaxReader(SyntaxType syntax)
        {
            string fileResouce = "";

            switch (syntax)
            {
            case SyntaxType.CSharp:
                fileResouce = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Resources.cs.syntax";
                break;

            case SyntaxType.VBNet:
                fileResouce = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name + ".Resources.vb.syntax";
                break;

            default:
                throw new Exception("Syntax not catered for.");
            }
            using (Stream s = System.Reflection.Assembly.GetExecutingAssembly().GetManifestResourceStream(fileResouce))
            {
                TextReader tr = new StreamReader(s);
                TheFile = tr.ReadToEnd();
            }
            FillArrays();
        }
Пример #32
0
        internal static ParameterDefinition[] Create(SyntaxType typeQualifier, string type, string name)
        {
            string[] types;

            if (BuiltInData.GenTypes.TryGetValue(type, out types))
            {
                ParameterDefinition[] parameters = new ParameterDefinition[types.Length];

                for (int i = 0; i < types.Length; i++)
                {
                    parameters[i] = new ParameterDefinition(new List <SyntaxType> {
                        typeQualifier
                    }, new TypeDefinition(types[i].GetSyntaxType()), name, string.Empty, Scope.BuiltIn, null);
                }

                return(parameters);
            }
            else
            {
                return(new ParameterDefinition[] { new ParameterDefinition(new List <SyntaxType> {
                        typeQualifier
                    }, new TypeDefinition(type.GetSyntaxType()), name, string.Empty, Scope.BuiltIn, null) });
            }
        }
Пример #33
0
        public SyntaxNode StartNode(SyntaxType type)
        {
            if (this.testModeLayer <= 0)
            {
                SyntaxNode node = this.CreateNode(type, this.CurrentToken.Span.Start);

                if (this.stack.Count != 0)
                {
                    this.stack.Peek().AddChild(node);
                }
                else
                {
                    this.tree.Root = node;
                }

                this.stack.Push(node);

                return(node);
            }
            else
            {
                return(null);
            }
        }
Пример #34
0
 /// <summary>
 /// 设置节点分析函数
 /// </summary>
 /// <param name="left">语法类型</param>
 /// <param name="leave">Token类型</param>
 /// <param name="proc">产生式</param>
 public void SetCellular(SyntaxType left, TokenType leave, CandidateFunction proc)
 {
     this.SetCellular(this.leftNodesDict[left], this.nextLeavesDict[leave], proc);
 }
Пример #35
0
        private void SetSelectionStyle(SyntaxType syntaxType)
        {
            // set the color
            SyntaxStyle style = SyntaxStyle.Style(syntaxType);

            this.TextBox.SelectionColor = style.Foreground;

            Color bg = style.Background;
            if (bg == Color.Transparent)
            {
                if (style.Type != SyntaxType.Default)
                {
                    bg = SyntaxStyle.Style(SyntaxType.Default).Background;
                }

                if (bg == Color.Transparent)
                {
                    bg = SystemColors.Window;
                }
            }

            this.TextBox.SelectionBackColor = bg;

            if (style.FontStyle != FontStyle.Regular)
            {
                this.TextBox.SelectionFont = new Font(this.TextBox.SelectionFont, style.FontStyle);
            }
        }
Пример #36
0
 public Highlighter(SourceViewer sourceViewer)
 {
     this.sourceViewer = sourceViewer;
     this.textBox = this.sourceViewer.TextBox;
     this.output = new StringBuilder();
     this.currentType = SyntaxType.Default;
 }
Пример #37
0
 /// <summary>
 /// 调用产生式处理函数
 /// </summary>
 /// <param name="subroot">匹配树根节点</param>
 /// <param name="syntaxer">语法类型</param>
 /// <param name="detail">节点信息</param>
 /// <returns>产生式的处理函数</returns>
 public SyntaxTreeNode Call(SyntaxTreeNode subroot, SyntaxType syntaxer, Token detail)
 {
     return this.candidateProcessor(subroot, this.candidateType, syntaxer, detail);
 }
Пример #38
0
 /// <summary>
 /// 通用产生式处理函数
 /// </summary>
 /// <param name="myNode">产生式节点</param>
 /// <param name="myType">候选式类型</param>
 /// <param name="mySyntax">节点语法类型</param>
 /// <param name="myToken">命中单词</param>
 /// <returns>下一个展开节点的指针</returns>
 private SyntaxTreeNode Derivate(SyntaxTreeNode myNode, CFunctionType myType, SyntaxType mySyntax, Token myToken)
 {
     // 更新节点信息
     if (myNode != null)
     {
         myNode.NodeType = myType;
         myNode.NodeValue = myToken.OriginalCodeStr;
         myNode.NodeSyntaxType = mySyntax;
         myNode.NodeName = mySyntax.ToString();
         myNode.Line = myToken.Line;
         myNode.Column = myToken.Column;
         if (myToken.IsVar)
         {
             myNode.NodeVarType = myToken.IsGlobal ? VarScopeType.GLOBAL : VarScopeType.LOCAL;
         }
     }
     // 取候选向量
     List<SyntaxType> iSvec = this.derivatorTypeDict[Convert.ToInt32(myType)];
     // 左边出栈
     this.parseStack.Pop();
     // 如果她是一个非终结符
     if (myType < CFunctionType.DERI_UMI_BOUNDARY)
     {
         // 自右向左压匹配栈
         for (int i = iSvec.Count - 1; i >= 0; i--)
         {
             this.parseStack.Push(iSvec[i]);
         }
         // 自左向右构造子节点
         bool flag = false;
         SyntaxTreeNode successor = null;
         myNode.Children = new List<SyntaxTreeNode>();
         for (int i = 0; i < iSvec.Count; i++)
         {
             SyntaxTreeNode newNode = new SyntaxTreeNode();
             newNode.Parent = myNode;
             myNode.Children.Add(newNode);
             if (flag == false)
             {
                 successor = newNode;
                 flag = true;
             }
         }
         // 返回第一个产生式
         return successor;
     }
     // 如果她是一个终结符
     else
     {
         // 递增token指针
         if (myType != CFunctionType.umi_epsilon)
         {
             this.nextTokenPointer++;
         }
         // 返回她的后继
         return this.RecursiveDescent(myNode);
     }
 }
Пример #39
0
 /// <summary>
 /// 复位匹配器:命令推导向推导过程转化时内部使用
 /// </summary>
 private void DashReset(SyntaxType startNodeType)
 {
     // 变数初期化
     this.nextTokenPointer = 0;
     this.parseStack.Clear();
     this.commandDerivatorQueue.Clear();
     // 放置初始节点
     this.parseStack.Push(SyntaxType.tail_startEndLeave);
     this.parseStack.Push(startNodeType);
     // 在流的末尾,放置结束标记
     Token ccToken = new Token();
     ccToken.Length = 1;
     ccToken.OriginalCodeStr = "#";
     ccToken.ErrorBit = false;
     ccToken.Type = TokenType.startend;
     ccToken.Line = this.dealingLine;
     ccToken.Column = this.istream.Count > 0 ? this.istream.Last().Column + 1 : -1;
     this.istream.Add(ccToken);
 }
Пример #40
0
 private void AddSyntaxText(string text, SyntaxType syntaxType)
 {
     this.TextBox.Select(this.TextBox.TextLength, 0);
     this.SetSelectionStyle(syntaxType);
     this.TextBox.AppendText(text);
 }
Пример #41
0
 /// <summary>
 /// 为参数的字典节点追加LL1文法推导项
 /// </summary>
 /// <param name="arg">参数在字典中的名字</param>
 /// <param name="derivator">LL1文法推导起始类型</param>
 private void ProcessArgumentDerivator(SyntaxTreeNode statementNode, ref int prescanPointer, string arg, SyntaxType derivator)
 {
     statementNode.ParamDict[arg].Children = new List<SyntaxTreeNode>();
     SyntaxTreeNode derivationNode = new SyntaxTreeNode(derivator, statementNode.ParamDict[arg]);
     derivationNode.ParamTokenStream = new List<Token>();
     prescanPointer += 2;
     while (prescanPointer < this.istream.Count
         && !this.istream[prescanPointer].Type.ToString().StartsWith("Token_p")
         && this.istream[prescanPointer].Type != TokenType.startend)
     {
         derivationNode.ParamTokenStream.Add(this.istream[prescanPointer++]);
     }
     statementNode.ParamDict[arg].Children.Add(derivationNode);
     // 加入命令推导队列
     this.commandDerivatorQueue.Enqueue(derivationNode);
 }
Пример #42
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="type">节点类型</param>
 /// <param name="parent">节点的双亲</param>
 public SyntaxTreeNode(SyntaxType type = SyntaxType.Unknown, SyntaxTreeNode parent = null)
 {
     this.NodeName = type.ToString();
     this.NodeSyntaxType = type;
     this.Parent = parent;
 }
Пример #43
0
 public Token(int line, string value, SyntaxType type)
 {
     Line = line;
     Value = value;
     ValueType = type;
 }
Пример #44
0
 /// <summary>
 /// 设置行类型
 /// </summary>
 /// <param name="rowid">行号</param>
 /// <param name="st">syntax类型</param>
 public void SetRow(int rowid, SyntaxType st)
 {
     if (0 <= rowid && rowid < this.rowCount)
     {
         leftNodesDict.Add(st, rowid);
     }
 }
Пример #45
0
 /// <summary>
 /// 为命令推导项追加参数字典
 /// </summary>
 /// <param name="statementNode">命令在树上的节点</param>
 /// <param name="sType">命令的语法类型</param>
 /// <param name="argv">参数列表</param>
 private void ConstructArgumentDict(SyntaxTreeNode statementNode, SyntaxType sType, params string[] argv)
 {
     statementNode.NodeSyntaxType = sType;
     foreach (string arg in argv)
     {
         statementNode.ParamDict[arg] = new SyntaxTreeNode(
             (SyntaxType)Enum.Parse(typeof(SyntaxType), String.Format("para_{0}", arg)), statementNode);
     }
 }
 private static void AddSyntaxType(Dictionary<eType, SyntaxType> SyntaxOccurences, SyntaxType st)
 {
     if (!SyntaxOccurences.ContainsKey(st.Type))
         SyntaxOccurences.Add(st.Type, st);
 }
Пример #47
0
 protected CompiledContentTestsBase(SyntaxType syntaxType)
     : base(syntaxType)
 {
 }
Пример #48
0
 private void SetStyle(SyntaxType syntaxType)
 {
     if (syntaxType != this.currentType)
     {
         this.CommitText();
         this.currentType = syntaxType;
     }
 }