Class RipperLexer

java.lang.Object
org.jruby.lexer.LexingCommon
org.jruby.ext.ripper.RipperLexer

public class RipperLexer extends LexingCommon
  • Field Details

  • Constructor Details

  • Method Details

    • ambiguousOperator

      protected void ambiguousOperator(String op, String syn)
      Specified by:
      ambiguousOperator in class LexingCommon
    • onMagicComment

      protected boolean onMagicComment(String name, ByteList value)
      Overrides:
      onMagicComment in class LexingCommon
    • getFloatToken

      private int getFloatToken(String number, int suffix)
    • considerComplex

      private int considerComplex(int token, int suffix)
    • isVerbose

      public boolean isVerbose()
    • warn

      public void warn(String message)
    • warning

      public void warning(String fmt)
    • warning

      public void warning(String fmt, String arg)
    • getKeyword

      public static RipperLexer.Keyword getKeyword(String str)
    • hasStarted

      public boolean hasStarted()
      Has lexing started yet?
    • flush_string_content

      protected void flush_string_content(org.jcodings.Encoding encoding)
    • addDelayedToken

      public void addDelayedToken(int tok, int end)
    • nextLine

      private boolean nextLine()
    • cr

      private int cr(int c)
    • nextc

      public int nextc()
      Specified by:
      nextc in class LexingCommon
    • dispatchHeredocEnd

      public void dispatchHeredocEnd()
    • compile_error

      public void compile_error(String message)
      Specified by:
      compile_error in class LexingCommon
    • tokenize_ident

      public int tokenize_ident(int result)
      Specified by:
      tokenize_ident in class LexingCommon
    • heredoc_restore

      public void heredoc_restore(HeredocTerm here)
    • nextToken

      public int nextToken() throws IOException
      Throws:
      IOException
    • getIdent

      public String getIdent()
    • getRuntime

      public Ruby getRuntime()
    • setParser

      public void setParser(RipperParserBase parserSupport)
      Parse must pass its support object for some check at bottom of yylex(). Ruby does it this way as well (i.e. a little parsing logic in the lexer).
      Parameters:
      parserSupport -
    • setCompileOptionFlag

      protected void setCompileOptionFlag(String name, ByteList value)
      Specified by:
      setCompileOptionFlag in class LexingCommon
    • parseRegexpFlags

      protected RegexpOptions parseRegexpFlags() throws IOException
      Specified by:
      parseRegexpFlags in class LexingCommon
      Throws:
      IOException
    • mismatchedRegexpEncodingError

      protected void mismatchedRegexpEncodingError(org.jcodings.Encoding optionEncoding, org.jcodings.Encoding encoding)
      Specified by:
      mismatchedRegexpEncodingError in class LexingCommon
    • setTokenInfo

      protected void setTokenInfo(String name, ByteList value)
      Specified by:
      setTokenInfo in class LexingCommon
    • setEncoding

      protected void setEncoding(ByteList name)
      Specified by:
      setEncoding in class LexingCommon
    • getStrTerm

      public StrTerm getStrTerm()
    • setStrTerm

      public void setStrTerm(StrTerm strterm)
    • createStr

      public IRubyObject createStr(ByteList buffer, int flags)
    • parseQuote

      private int parseQuote(int c) throws IOException
      What type/kind of quote are we dealing with?
      Parameters:
      c - first character the the quote construct
      Returns:
      a token that specifies the quote type
      Throws:
      IOException
    • hereDocumentIdentifier

      private int hereDocumentIdentifier() throws IOException
      Throws:
      IOException
    • arg_ambiguous

      private boolean arg_ambiguous()
    • printToken

      private void printToken(int token)
    • hasScanEvent

      public boolean hasScanEvent()
    • dispatchDelayedToken

      public void dispatchDelayedToken(int token)
    • dispatchIgnoredScanEvent

      public void dispatchIgnoredScanEvent(int token)
    • dispatchScanEvent

      public void dispatchScanEvent(int token)
    • scanEventValue

      private IRubyObject scanEventValue(int token)
    • tokenToEventId

      private String tokenToEventId(int token)
    • yylex2

      private int yylex2() throws IOException
      Throws:
      IOException
    • yylex

      private int yylex() throws IOException
      Returns the next token. Also sets yyVal as needed.
      Returns:
      the next token
      Throws:
      IOException
    • identifierToken

      private int identifierToken(int last_state, int result, String value)
    • ampersand

      private int ampersand(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • at

      private int at() throws IOException
      Throws:
      IOException
    • backtick

      private int backtick(boolean commandState) throws IOException
      Throws:
      IOException
    • bang

      private int bang() throws IOException
      Throws:
      IOException
    • caret

      private int caret() throws IOException
      Throws:
      IOException
    • colon

      private int colon(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • comma

      private int comma(int c) throws IOException
      Throws:
      IOException
    • doKeyword

      private int doKeyword(int state)
    • dollar

      private int dollar() throws IOException
      Throws:
      IOException
    • dot

      private int dot() throws IOException
      Throws:
      IOException
    • doubleQuote

      private int doubleQuote(boolean commandState) throws IOException
      Throws:
      IOException
    • greaterThan

      private int greaterThan() throws IOException
      Throws:
      IOException
    • identifier

      private int identifier(int c, boolean commandState) throws IOException
      Throws:
      IOException
    • leftBracket

      private int leftBracket(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • leftCurly

      private int leftCurly()
    • leftParen

      private int leftParen(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • lessThan

      private int lessThan(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • minus

      private int minus(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • percent

      private int percent(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • pipe

      private int pipe() throws IOException
      Throws:
      IOException
    • plus

      private int plus(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • questionMark

      private int questionMark() throws IOException
      Throws:
      IOException
    • rightBracket

      private int rightBracket()
    • rightCurly

      private int rightCurly()
    • rightParen

      private int rightParen()
    • singleQuote

      private int singleQuote(boolean commandState) throws IOException
      Throws:
      IOException
    • slash

      private int slash(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • star

      private int star(boolean spaceSeen) throws IOException
      Throws:
      IOException
    • tilde

      private int tilde() throws IOException
      Throws:
      IOException
    • parseNumber

      private int parseNumber(int c) throws IOException
      Parse a number from the input stream.
      Parameters:
      c - The first character of the number.
      Returns:
      A int constant which represents a token.
      Throws:
      IOException
    • getNumberLiteral

      private int getNumberLiteral(String number, boolean seen_e, boolean seen_point, int nondigit) throws IOException
      Throws:
      IOException
    • setNumberLiteral

      private int setNumberLiteral(int type, int suffix)
    • setIntegerLiteral

      private int setIntegerLiteral(int suffix)
    • readUTFEscapeRegexpLiteral

      public void readUTFEscapeRegexpLiteral(ByteList buffer) throws IOException
      Throws:
      IOException
    • tokenAddMBC

      public boolean tokenAddMBC(int first_byte, ByteList buffer)
    • readUTFEscape

      public int readUTFEscape(ByteList buffer, boolean stringLiteral, boolean symbolLiteral) throws IOException
      Throws:
      IOException
    • readUTF8EscapeIntoBuffer

      private void readUTF8EscapeIntoBuffer(int codepoint, ByteList buffer, boolean stringLiteral)
    • readEscape

      public int readEscape() throws IOException
      Throws:
      IOException
    • scanHexLiteral

      private char scanHexLiteral(ByteList buffer, int count, boolean strict, String errorMessage) throws IOException
      Read up to count hexadecimal digits and store those digits in a token buffer. If strict is provided then count number of hex digits must be present. If no digits can be read a syntax exception will be thrown. This will also return the codepoint as a value so codepoint ranges can be checked.
      Throws:
      IOException
    • scanHex

      private int scanHex(int count, boolean strict, String errorMessage) throws IOException
      Read up to count hexadecimal digits. If strict is provided then count number of hex digits must be present. If no digits can be read a syntax exception will be thrown.
      Throws:
      IOException