Exemplo n.º 1
0
        private void EndDqsIfEofOrWsa()
        {
            if (this._input.La(1) == -1 || InWsaMode)
            {
                //Report Lexer Error - missing closing Double Quote.
                ErrorListenerDispatch.SyntaxError(this, 0, this._tokenStartLine, this._tokenStartCharPositionInLine,
                                                  "Missing closing Double Quote",
                                                  new MalinaException(this, InputStream as ICharStream)
                {
                    Code  = MalinaErrorCode.ClosingDqMissing,
                    Start =
                        new DOM.SourceLocation(_currentToken.Line, _currentToken.Column, _currentToken.StartIndex),
                    Stop = new DOM.SourceLocation(Line, Column, CharIndex)
                }
                                                  );

                _currentToken.StopIndex  = this.CharIndex;
                _currentToken.StopLine   = Line;
                _currentToken.StopColumn = Column;
                Emit(_currentToken);
                ExitInValueMode();
                //Emitting NEWLINE if not in WSA
                if (!InWsaMode)
                {
                    EmitIndentationToken(NEWLINE, CharIndex, CharIndex);
                }
            }
            else
            {
                _currentToken.Type = DQS_ML;
                Skip();
            }
        }
Exemplo n.º 2
0
 private void ReportMissingSq()
 {
     ErrorListenerDispatch.SyntaxError(this, 0, this._tokenStartLine, this._tokenStartCharPositionInLine,
                                       "Missing closing Single Quote",
                                       new MalinaException(this, InputStream as ICharStream)
     {
         Code  = MalinaErrorCode.ClosingSqMissing,
         Start = new DOM.SourceLocation(_tokenStartLine, _tokenStartCharPositionInLine, _tokenStartCharIndex),
         Stop  = new DOM.SourceLocation(_tokenStartLine, _tokenStartCharPositionInLine, _tokenStartCharIndex)
     }
                                       );
 }
Exemplo n.º 3
0
        private void DqIndentDedent()
        {
            var currentIndent = InWsaMode ? 0 : _indents.Peek();
            var indent        = CalcIndent();

            //If dedent found check if this is comment and ignore it
            if (!(indent > currentIndent) && CurrentLineEndsWithComment())
            {
                return;
            }


            if (indent <= currentIndent || _input.La(1) == Eof)
            {
                //DQS is ended by indentation

                //Report Lexer Error - missing closing Double Quote.
                ErrorListenerDispatch.SyntaxError(this, 0, this._tokenStartLine, this._tokenStartCharPositionInLine, "Missing closing Double Quote",
                                                  new MalinaException(this, InputStream as ICharStream)
                {
                    Code  = MalinaErrorCode.ClosingDqMissing,
                    Start = new DOM.SourceLocation(_currentToken.Line, _currentToken.Column, _currentToken.StartIndex),
                    Stop  = new DOM.SourceLocation(_tokenStartLine, _tokenStartCharPositionInLine, _tokenStartCharIndex)
                }
                                                  );

                //END Multiline DQS
                _currentToken.StopIndex  = this._tokenStartCharIndex;
                _currentToken.StopLine   = this._tokenStartLine;
                _currentToken.StopColumn = this._tokenStartCharPositionInLine;
                Emit(_currentToken);
                ExitInValueMode();

                //Emitting NEWLINE
                EmitIndentationToken(NEWLINE, CharIndex - indent - 1, CharIndex - indent - 1);
                //Emitting 1 or more DEDENTS
                while (_indents.Count > 1 && _indents.Peek() > indent)
                {
                    EmitIndentationToken(DEDENT, CharIndex - indent, CharIndex - 1);
                    _indents.Pop();
                }
            }
            else //Continue Multine DQS
            {
                Skip();
            }
        }