Пример #1
0
 private TokenType(string label, TokenTypeConfig config = null)
 {
     Label            = label;
     Keyword          = config?.Keyword;
     BeforeExpr       = config?.BeforeExpr ?? false;
     StartsExpr       = config?.StartsExpr ?? false;
     RightAssociative = config?.RightAssociative ?? false;
     IsLoop           = config?.IsLoop ?? false;
     IsAssign         = config?.IsAssign ?? false;
     Prefix           = config?.Prefix ?? false;
     Postfix          = config?.Postfix ?? false;
     Binop            = config?.Binop;
     UpdateContext    = null;
 }
Пример #2
0
        private static TokenType Kw(string name, TokenTypeConfig options = null)
        {
            var cfg = options ?? new TokenTypeConfig();

            cfg.Keyword = name;

            var tokenType = new TokenType(name, cfg);

            if (name == "function")
            {
                tokenType.UpdateContext = FunctionUpdateContext;
            }

            Types.Add("_" + name, tokenType);

            return(tokenType);
        }