Exemplo n.º 1
0
        public KeyTerm Keyword(string keyword)
        {
            KeyTerm term = ToTerm(keyword);

            term.SetFlag(TermFlags.IsKeyword, true);
            term.SetFlag(TermFlags.IsReservedWord, true);
            term.EditorInfo         = new TokenEditorInfo(TokenType.Keyword, TokenColor.Keyword, TokenTriggers.None);
            term.AstConfig.NodeType = typeof(LuaLiteralNode);
            return(term);
        }
Exemplo n.º 2
0
 private void BracePair(KeyTerm open, KeyTerm close)
 {
     open.IsPairFor  = close;
     close.IsPairFor = open;
     open.SetFlag(TermFlags.IsOpenBrace);
     close.SetFlag(TermFlags.IsCloseBrace);
 }
Exemplo n.º 3
0
 public static void RegisterBracePair(KeyTerm openBrace, KeyTerm closeBrace)
 {
     openBrace.SetFlag(TermFlags.IsOpenBrace);
     openBrace.IsPairFor = closeBrace;
     closeBrace.SetFlag(TermFlags.IsCloseBrace);
     closeBrace.IsPairFor = openBrace;
 }
Exemplo n.º 4
0
        private KeyTerm RegisterTerm(string text, string name = null)
        {
            KeyTerm kt = ToTerm(text);

            kt.SetFlag(TermFlags.IsReservedWord);
            RegisteredTerms.Add(kt);
            return(kt);
        }
Exemplo n.º 5
0
        public KeyTerm Operator(string op)
        {
            KeyTerm term = new KeyTerm(CaseSensitive ? op : op.ToLower(), op);

            term.SetFlag(TermFlags.IsOperator, true);
            term.EditorInfo = new TokenEditorInfo(TokenType.Operator, TokenColor.Keyword, TokenTriggers.None);

            return(term);
        }
Exemplo n.º 6
0
        public KeyTerm Operator(string op)
        {
            string opCased = CaseSensitive ? op : op.ToLower();
            var    term    = new KeyTerm(opCased, op);

            term.SetFlag(TermFlags.IsOperator, true);
            term.EditorInfo         = new TokenEditorInfo(TokenType.Operator, TokenColor.Text, TokenTriggers.None);
            term.AstConfig.NodeType = typeof(LuaNode);
            return(term);
        }
Exemplo n.º 7
0
        internal UOSLBase(LanguageOption options = LanguageOption.Native)
        {
            if (CanCache)
            {
                grammars[options] = this;
            }

            Options = options;

            this.DefaultNodeType = typeof(ScopedNode);

            #region Declare Terminals Here

            NonGrammarTerminals.Add(blockComment);
            NonGrammarTerminals.Add(lineComment);

            Identifier.AstNodeType = typeof(UoFieldExpressionNode);

            _L = ToTerm("L");
            MarkReservedWords("L");

            #endregion

            #region Functions
            TypedFunction.Rule    = Function_void | Function_int | Function_string | Function_ustring | Function_loc | Function_obj | Function_list;
            Function_void.Rule    = _void + _functionname_void;
            Function_int.Rule     = _int + _functionname_int;
            Function_string.Rule  = _string + _functionname_str;
            Function_ustring.Rule = _ustring + _functionname_ustr;
            Function_loc.Rule     = _loc + _functionname_loc;
            Function_obj.Rule     = _obj + _functionname_obj;
            Function_list.Rule    = _list + _functionname_list;
            #endregion

            #region Externals
            _any.SetFlag(TermFlags.IsKeyword);
            if (!Keywords.ContainsKey(_any.Text))
            {
                Keywords[_any.Text] = _any;
            }
            ExternalParam.Rule       = (_int | _string | _ustring | _loc | _obj | _list | _any | _void) + (ToTerm("&").Q()) + (Identifier.Q());
            ExternalParams.Rule      = MakeStarRule(ExternalParams, _comma, ExternalParam);
            Function_any.Rule        = _any + _functionname_void; // only valid for Core Commands
            ExternalDeclaration.Rule = ToTerm("external") + (Function_any | TypedFunction) + _openparen_punc + ExternalParams + _closeparen_punc + _semicolon;
            #endregion


            BracePair(_openbracket, _closebracket);
            BracePair(_openparen_op, _closeparen_op);
            BracePair(_openparen_punc, _closeparen_punc);
            BracePair(_openbrace, _closebrace);
            BracePair(_openchevron, _closechevron);

            this.Delimiters = "{}[](),:;+-*/%&|^!~<>=";
            this.MarkPunctuation(_semicolon, _comma, _openparen_punc, _closeparen_punc, _openbrace, _closebrace, _openbracket, _closebracket, _colon);

            RegisterOperators(-1, _assignment);
            RegisterOperators(1, _logicalnegation, _increment, _decrement);
            RegisterOperators(0, _plus, _minus, _multiply, _divide, _remainder, _isequal, _isnotequal, _lowerthen, _greaterthen, _lowerthenorequal,
                              _greaterthenorequal, _logicaland, _logicalor, _bitwiseexclusiveor);

            this.LanguageFlags = LanguageFlags.CreateAst;
        }
 public void RegisterBracePair(KeyTerm open, KeyTerm close)
 {
     open.SetFlag(TermFlags.IsOpenBrace);
     open.IsPairFor = close;
     close.SetFlag(TermFlags.IsCloseBrace);
     close.IsPairFor = open;
 }