Class Scanner


  • public class Scanner
    extends java.lang.Object
    A Scanner for Jcoder 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.

    • Constructor Summary

      Constructors 
      Modifier Constructor Description
      protected Scanner​(SourceFile sf)
      for use in jcfront.
      protected Scanner​(SourceFile sf, java.util.HashMap<java.lang.String,​java.lang.String> macros)
      Create a scanner to scan an input stream.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      protected void match​(JcodTokens.Token open, JcodTokens.Token close)
      Scan to a matching '}', ']' or ')'.
      protected int scan()
      Scan the next token.
      protected int scanMacro()
      Scan the next token.
      protected void skipTill​(int sym)  
      protected int xscan()  
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • env

        protected SourceFile env
        Where errors are reported
      • ch

        protected int ch
        The current character
      • prevCh

        protected int prevCh
        The current character
      • macro

        protected java.lang.String macro
      • indexMacro

        protected int indexMacro
      • pos

        protected int pos
        The position of the current token
      • prevPos

        protected int prevPos
        The position of the previous token
      • longValue

        protected long longValue
      • intValue

        protected int intValue
      • intSize

        protected int intSize
      • stringValue

        protected java.lang.String stringValue
      • longStringValue

        protected org.openjdk.asmtools.jcoder.ByteBuffer longStringValue
      • sign

        protected int sign
      • docComment

        protected java.lang.String docComment
    • Constructor Detail

      • Scanner

        protected Scanner​(SourceFile sf,
                          java.util.HashMap<java.lang.String,​java.lang.String> macros)
                   throws java.io.IOException
        Create a scanner to scan an input stream.
        Throws:
        java.io.IOException
      • Scanner

        protected Scanner​(SourceFile sf)
                   throws java.io.IOException
        for use in jcfront.
        Throws:
        java.io.IOException
    • Method Detail

      • skipTill

        protected void skipTill​(int sym)
                         throws java.io.IOException
        Throws:
        java.io.IOException
      • xscan

        protected int xscan()
                     throws java.io.IOException
        Throws:
        java.io.IOException
      • match

        protected void match​(JcodTokens.Token open,
                             JcodTokens.Token close)
                      throws java.io.IOException
        Scan to a matching '}', ']' or ')'. The current token must be a '{', '[' or '(';
        Throws:
        java.io.IOException
      • scan

        protected int scan()
                    throws java.io.IOException
        Scan the next token.
        Returns:
        the position of the previous token.
        Throws:
        java.io.IOException
      • scanMacro

        protected int scanMacro()
                         throws java.io.IOException
        Scan the next token.
        Returns:
        the position of the previous token.
        Throws:
        java.io.IOException