Class Scanner


  • public class Scanner
    extends ParseBase
    A Scanner for Jasm tokens. Errors are reported to the environment object.

    The scanner keeps track of the current token, the value of the current token (if any), and the start position of the current token.

    The scan() method advances the scanner to the next token in the input.

    The match() method is used to quickly match opening brackets (ie: '(', '{', or '[') with their closing counter part. This is useful during error recovery.

    The compiler treats either "\n", "\r" or "\r\n" as the end of a line.

    • Field Detail

      • ch

        protected int ch
        The current character
      • pos

        protected int pos
        The position of the current token
      • charValue

        protected char charValue
      • intValue

        protected int intValue
      • longValue

        protected long longValue
      • floatValue

        protected float floatValue
      • doubleValue

        protected double doubleValue
      • stringValue

        protected java.lang.String stringValue
      • idValue

        protected java.lang.String idValue
      • radix

        protected int radix
      • docComment

        protected java.lang.String docComment
      • prevPos

        protected int prevPos
        The position of the previous token
      • sign

        protected int sign
      • inBits

        protected boolean inBits
    • Constructor Detail

      • Scanner

        protected Scanner​(Environment env)
                   throws java.io.IOException
        main constructor. Create a scanner to scan an input stream.
        Throws:
        java.io.IOException
    • Method Detail

      • scanModuleStatement

        protected void scanModuleStatement()
                                    throws java.io.IOException
        Throws:
        java.io.IOException
      • scan

        protected void scan()
                     throws java.io.IOException
        scan Scan the next token.
        Throws:
        java.io.IOException
      • checkTokenIdent

        protected final boolean checkTokenIdent()
        Check the token may be identifier
      • isUCDigit

        public static boolean isUCDigit​(int ch)
        Returns true if the character is a unicode digit.
        Parameters:
        ch - the character to be checked
      • isUCLetter

        public static boolean isUCLetter​(int ch)
        Returns true if the character is a Unicode letter.
        Parameters:
        ch - the character to be checked
      • xscan

        protected final void xscan()
                            throws java.io.IOException
        Throws:
        java.io.IOException
      • debugScan

        protected void debugScan​(java.lang.String dbstr)
        Overrides:
        debugScan in class ParseBase