IronKonoha.KonohaSpace.makeSyntaxRule C# (CSharp) Method

makeSyntaxRule() private method

private makeSyntaxRule ( IList tls, int s, int e, List &adst ) : bool
tls IList
s int
e int
adst List
return bool
        private bool makeSyntaxRule(IList<Token> tls, int s, int e, out List<Token> adst)
        {
            int i;
            adst = new List<Token>();
            Symbol nameid = null;
            for (i = s; i < e; i++)
            {
                Token tk = tls[i];
                if (tk.Type == TokenType.INDENT) continue;
                if (tk.Type == TokenType.TEXT /*|| tk.Type == TK_STEXT*/)
                {
                    if (checkNestedSyntax(tls, ref i, e, TokenType.AST_PARENTHESIS, '(', ')') ||
                        checkNestedSyntax(tls, ref i, e, TokenType.AST_BRANCET, '[', ']') ||
                        checkNestedSyntax(tls, ref i, e, TokenType.AST_BRACE, '{', '}'))
                    {
                    }
                    else
                    {
                        tk.Type = TokenType.CODE;
                        tk.Keyword = ctx.kmodsugar.keyword_(tk.Text, Symbol.NewID).Type;
                    }
                    adst.Add(tk);
                    continue;
                }
                if (tk.Type == TokenType.SYMBOL)
                {
                    if (i > 0 && tls[i - 1].TopChar == '$')
                    {
                        var name = string.Format("${0}", tk.Text);
                        tk.Keyword = ctx.kmodsugar.keyword_(name, Symbol.NewID).Type;
                        tk.Type = TokenType.METANAME;
                        if (nameid == null) nameid = Symbol.Get(ctx, tk.Text);
                        tk.nameid = nameid;
                        nameid = null;
                        adst.Add(tk);
                        continue;
                    }
                    if (i + 1 < e && tls[i + 1].TopChar == ':')
                    {
                        Token tk2 = tls[i];
                        nameid = Symbol.Get(ctx, tk2.Text);
                        i++;
                        continue;
                    }
                }
                if (tk.Type == TokenType.OPERATOR)
                {
                    if (checkNestedSyntax(tls, ref i, e, TokenType.AST_OPTIONAL, '[', ']'))
                    {
                        adst.Add(tk);
                        continue;
                    }
                    if (tls[i].TopChar == '$') continue;
                }
                ctx.SUGAR_P(ReportLevel.ERR, tk.ULine, 0, "illegal sugar syntax: {0}", tk.Text);
                return false;
            }
            return true;
        }