Class STLexer

  • All Implemented Interfaces:
    org.antlr.runtime.TokenSource

    public class STLexer
    extends Object
    implements org.antlr.runtime.TokenSource
    This class represents the tokenizer for templates. It operates in two modes: inside and outside of expressions. It implements the TokenSource interface so it can be used with ANTLR parsers. Outside of expressions, we can return these token types: TEXT, INDENT, LDELIM (start of expression), RCURLY (end of subtemplate), and NEWLINE. Inside of an expression, this lexer returns all of the tokens needed by STParser. From the parser's point of view, it can treat a template as a simple stream of elements.

    This class defines the token types and communicates these values to STParser.g via STLexer.tokens file (which must remain consistent).

    • Constructor Detail

      • STLexer

        public STLexer​(org.antlr.runtime.CharStream input)
      • STLexer

        public STLexer​(ErrorManager errMgr,
                       org.antlr.runtime.CharStream input,
                       org.antlr.runtime.Token templateToken)
      • STLexer

        public STLexer​(ErrorManager errMgr,
                       org.antlr.runtime.CharStream input,
                       org.antlr.runtime.Token templateToken,
                       char delimiterStartChar,
                       char delimiterStopChar)
    • Method Detail

      • nextToken

        public org.antlr.runtime.Token nextToken()
        Specified by:
        nextToken in interface org.antlr.runtime.TokenSource
      • match

        public void match​(char x)
        Consume if x is next character on the input stream.
      • consume

        protected void consume()
      • emit

        public void emit​(org.antlr.runtime.Token token)
      • _nextToken

        public org.antlr.runtime.Token _nextToken()
      • outside

        protected org.antlr.runtime.Token outside()
      • inside

        protected org.antlr.runtime.Token inside()
      • isIDStartLetter

        public static boolean isIDStartLetter​(char c)
      • isIDLetter

        public static boolean isIDLetter​(char c)
      • isWS

        public static boolean isWS​(char c)
      • isUnicodeLetter

        public static boolean isUnicodeLetter​(char c)
      • newToken

        public org.antlr.runtime.Token newToken​(int ttype)
      • newTokenFromPreviousChar

        public org.antlr.runtime.Token newTokenFromPreviousChar​(int ttype)
      • newToken

        public org.antlr.runtime.Token newToken​(int ttype,
                                                String text,
                                                int pos)
      • newToken

        public org.antlr.runtime.Token newToken​(int ttype,
                                                String text)
      • getSourceName

        public String getSourceName()
        Specified by:
        getSourceName in interface org.antlr.runtime.TokenSource
      • str

        public static String str​(int c)