コード例 #1
0
ファイル: Lexer.cs プロジェクト: danieladacruz/Parsers
 public CompressedState(Lexer lexer)
 {
     this._hereDocLabel = lexer._hereDocLabel;
     this._currentState = lexer.CurrentLexicalState;
     this._stateStack   = lexer.stateStack.ToArray();
     this._phpDoc       = lexer.DocBlock;
 }
コード例 #2
0
        /// <summary>
        /// Initializes a new instance of the <c>LuatSyntaxLanguage</c> class.
        /// </summary>
        public LuatSyntaxLanguage(LuaIntellisenseBroker plugin)
            : base("Luat")
        {
            m_plugin = plugin;

            ExampleText = @"/*
                            function HelloWorld()
                              local a = 1
                              local b : FwVector4;
                            end";

            // Initialize highlighting styles (same as the LuaDefinition.xml values); helps SkinService
            HighlightingStyles.Add(new HighlightingStyle(ReservedWordStyleString, null, Color.Blue, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(FunctionStyleString, null, Color.Magenta, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(GlobalVariableStyleString, null, Color.Teal, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(OperatorStyleString, null, Color.Black, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(NumberStyleString, null, Color.Purple, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(StringDelimiterStyleString, null, Color.Maroon, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(StringDefaultStyleString, null, Color.Maroon, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(CommentDelimiterStyleString, null, Color.Green, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(CommentUrlStyleString, null, Color.Green, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(CommentTagStyleString, null, Color.Gray, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(CommentDefaultStyleString, null, Color.Green, Color.Empty));

            // Initialize custom highlighting styles
            HighlightingStyles.Add(new HighlightingStyle(WarningStyleString, null, Color.Green, Color.Empty));
            HighlightingStyles.Add(new HighlightingStyle(ReferenceStyleString, null, Color.Empty, Color.LightCyan));
            HighlightingStyles.Add(new HighlightingStyle(AssignmentStyleString, null, Color.Empty, Color.MistyRose));

            // Initialize lexical states
            LexicalStates.Add(new DefaultLexicalState(LuatLexicalStateId.Default, "DefaultState"));
            DefaultLexicalState = LexicalStates["DefaultState"];
            LexicalStates["DefaultState"].DefaultHighlightingStyle = HighlightingStyles["DefaultStyle"];
        }
コード例 #3
0
 private bool yy_pop_state()
 {
     if (stateStack.Count == 0)
     {
         return(false);
     }
     current_lexical_state = stateStack.Pop();
     return(true);
 }
コード例 #4
0
ファイル: StrToTimeScanner.cs プロジェクト: dw4dev/Phalanger
		public void Initialize(System.IO.TextReader reader, LexicalStates lexicalState, bool atBol)
		{
			this.expanding_token = false;
			this.token_start = 0;
			this.chars_read = 0;
			this.lookahead_index = 0;
			this.token_chunk_start = 0;
			this.token_end = 0;
			this.reader = reader;
			this.yy_at_bol = atBol;
			this.current_lexical_state = lexicalState;
		}
コード例 #5
0
ファイル: jsonLexer.cs プロジェクト: jiahao42/weverca
 public void Initialize(System.IO.TextReader reader, LexicalStates lexicalState, bool atBol)
 {
     this.expanding_token       = false;
     this.token_start           = 0;
     this.chars_read            = 0;
     this.lookahead_index       = 0;
     this.token_chunk_start     = 0;
     this.token_end             = 0;
     this.reader                = reader;
     this.yy_at_bol             = atBol;
     this.current_lexical_state = lexicalState;
 }
コード例 #6
0
        /// <summary>
        /// Lexer constructor that initializes all the necessary members
        /// </summary>
        /// <param name="reader">Text reader containing the source code.</param>
        /// <param name="encoding">Source file encoding to convert UTF characters.</param>
        /// <param name="errors">Error sink used to report lexical error.</param>
        /// <param name="features">Allow or disable short oppening tags for PHP.</param>
        /// <param name="positionShift">Starting position of the first token, used during custom restart.</param>
        /// <param name="initialState">Initial state of the lexer, used during custom restart.</param>
        public Lexer(
            System.IO.TextReader reader,
            Encoding encoding,
            IErrorSink <Span> errors   = null,
            LanguageFeatures features  = LanguageFeatures.Basic,
            int positionShift          = 0,
            LexicalStates initialState = LexicalStates.INITIAL)
        {
            _encoding       = encoding ?? Encoding.UTF8;
            _errors         = errors ?? new EmptyErrorSink <Span>();
            _charOffset     = positionShift;
            _allowShortTags = (features & LanguageFeatures.ShortOpenTags) != 0;

            Initialize(reader, initialState);
        }
コード例 #7
0
 bool ProcessText(int count, LexicalStates newState, char ending, out Tokens token)
 {
     _yyless(count);
     token = Tokens.T_ENCAPSED_AND_WHITESPACE;
     yy_push_state(newState);
     if (TokenLength > 0)
     {
         this._tokenSemantics.Object = ProcessEscapedStringWithEnding(GetTokenString(), _encoding, false, ending);
         return(true);
     }
     else
     {
         yymore();
         return(false);
     }
 }
コード例 #8
0
ファイル: Lexer.cs プロジェクト: danieladacruz/Parsers
 bool ProcessText(int count, LexicalStates newState, char ending, out Tokens token)
 {
     _yyless(count);
     token = Tokens.T_ENCAPSED_AND_WHITESPACE;
     yy_push_state(newState);
     if (TokenLength > 0)
     {
         _tokenSemantics.Object = new KeyValuePair <string, string>((string)ProcessEscapedStringWithEnding(buffer, BufferTokenStart, TokenLength, ending), GetTokenString());
         return(true);
     }
     else
     {
         yymore();
         return(false);
     }
 }
コード例 #9
0
ファイル: Lexer.cs プロジェクト: danieladacruz/Parsers
        /// <summary>
        /// Lexer constructor that initializes all the necessary members
        /// </summary>
        /// <param name="reader">Text reader containing the source code.</param>
        /// <param name="encoding">Source file encoding to convert UTF characters.</param>
        /// <param name="errors">Error sink used to report lexical error.</param>
        /// <param name="features">Allow or disable short oppening tags for PHP.</param>
        /// <param name="positionShift">Starting position of the first token, used during custom restart.</param>
        /// <param name="initialState">Initial state of the lexer, used during custom restart.</param>
        public Lexer(
            System.IO.TextReader reader,
            Encoding encoding,
            IErrorSink <Span> errors   = null,
            LanguageFeatures features  = LanguageFeatures.Basic,
            int positionShift          = 0,
            LexicalStates initialState = LexicalStates.INITIAL)
        {
            _encoding   = encoding ?? Encoding.UTF8;
            _errors     = errors ?? new EmptyErrorSink <Span>();
            _charOffset = positionShift;
            _features   = features;
            _strings    = StringTable.GetInstance();

            Initialize(reader, initialState);
        }
コード例 #10
0
        /// <summary>
        /// Lexer constructor that initializes all the necessary members
        /// </summary>
        /// <param name="reader">Text reader containing the source code.</param>
        /// <param name="encoding">Source file encoding to convert UTF characters.</param>
        /// <param name="errors">Error sink used to report lexical error.</param>
        /// <param name="features">Allow or disable short oppening tags for PHP.</param>
        /// <param name="docBlockFactory">Factory for documentary comment semantic elements.</param>
        /// <param name="positionShift">Starting position of the first token, used during custom restart.</param>
        /// <param name="initialState">Initial state of the lexer, used during custom restart.</param>
        public Lexer(
            System.IO.TextReader reader,
            Encoding encoding,
            IErrorSink <Span> errors         = null,
            LanguageFeatures features        = LanguageFeatures.Basic,
            IDocBlockFactory docBlockFactory = null,
            int positionShift          = 0,
            LexicalStates initialState = LexicalStates.INITIAL)
        {
            _encoding                  = encoding ?? Encoding.UTF8;
            _errors                    = errors ?? new EmptyErrorSink <Span>();
            _docblockFactory           = docBlockFactory ?? DefaultDocBlockFactory.Instance;
            _charOffset                = positionShift;
            _features                  = features;
            _strings                   = StringTable.GetInstance();
            _processDoubleQuotedString = ProcessDoubleQuotedString;

            Initialize(reader, initialState);
        }
コード例 #11
0
ファイル: Tokenizer.cs プロジェクト: ruo2012/peachpie
 public CompressedState(Tokenizer tokenizer)
 {
     this.hereDocLabel = tokenizer.hereDocLabel;
     this.currentState = tokenizer.CurrentLexicalState;
     this.stateStack   = tokenizer.StateStack.ToArray();
 }
コード例 #12
0
 public void Initialize(System.IO.TextReader reader, LexicalStates lexicalState)
 {
     Initialize(reader, lexicalState, false);
 }
コード例 #13
0
ファイル: Lexer.cs プロジェクト: dw4dev/Phalanger
		private void yy_push_state(LexicalStates state)
		{
			stateStack.Push(current_lexical_state);
			current_lexical_state = state;
		}
コード例 #14
0
ファイル: Lexer.cs プロジェクト: danieladacruz/Parsers
 /// <summary>
 /// Override of <c>Initialize</c> resetting <see cref="_charOffset"/> so <see cref="TokenPosition"/> is correctly shifted.
 /// </summary>
 public void Initialize(System.IO.TextReader reader, LexicalStates lexicalState, bool atBol, int positionShift)
 {
     Initialize(reader, lexicalState, atBol);
     _charOffset = positionShift;
 }
コード例 #15
0
ファイル: Lexer.cs プロジェクト: dw4dev/Phalanger
		public void Initialize(System.IO.TextReader reader, LexicalStates lexicalState)
		{
			Initialize(reader, lexicalState, false);
		}
コード例 #16
0
ファイル: Lexer.cs プロジェクト: dw4dev/Phalanger
		#pragma warning restore 162
		
		
		#endregion
		private void BEGIN(LexicalStates state)
		{
			current_lexical_state = state;
		}
コード例 #17
0
                #pragma warning restore 162


        #endregion
        private void BEGIN(LexicalStates state)
        {
            current_lexical_state = state;
        }
コード例 #18
0
ファイル: Lexer.cs プロジェクト: dw4dev/Phalanger
		private bool yy_pop_state()
		{
			if (stateStack.Count == 0) return false;
			current_lexical_state = stateStack.Pop();
			return true;
		}
コード例 #19
0
 private void yy_push_state(LexicalStates state)
 {
     stateStack.Push(current_lexical_state);
     current_lexical_state = state;
 }