Package org.jruby.ext.ripper
Class RipperLexer
java.lang.Object
org.jruby.lexer.LexingCommon
org.jruby.ext.ripper.RipperLexer
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate booleanprotected ByteListprivate intprivate int(package private) Stringprivate StrTermprivate static final HashMap<String,RipperLexer.Keyword> private ByteListprivate RipperParserBase(package private) static final intFields inherited from class org.jruby.lexer.LexingCommon
__end__seen, AMPERSAND, AMPERSAND_AMPERSAND, AMPERSAND_DOT, ASCII8BIT_ENCODING, BACKSLASH, BACKTICK, BANG, BANG_EQ, BANG_TILDE, BEGIN_DOC_MARKER, braceNest, CALL, CARET, cmdArgumentState, CODING, COLON, COLON_COLON, COMMA, commandStart, conditionState, DOLLAR_BANG, DOLLAR_DOT, DOLLAR_UNDERSCORE, DOT, DOT_DOT, DOT_DOT_DOT, END_DOC_MARKER, END_MARKER, EOF, eofp, EQ, EQ_EQ, EQ_EQ_EQ, EQ_GT, EQ_TILDE, EXPR_ARG, EXPR_ARG_ANY, EXPR_BEG, EXPR_BEG_ANY, EXPR_CLASS, EXPR_CMDARG, EXPR_DOT, EXPR_END, EXPR_END_ANY, EXPR_ENDARG, EXPR_ENDFN, EXPR_FITEM, EXPR_FNAME, EXPR_LABEL, EXPR_LABELED, EXPR_MID, EXPR_VALUE, GT, GT_EQ, GT_GT, has_shebang, heredoc_end, heredoc_indent, heredoc_line_indent, inKwarg, last_cr_line, last_state, LBRACKET, LBRACKET_RBRACKET, LBRACKET_RBRACKET_EQ, LCURLY, lex_lastline, lex_nextline, lex_p, lex_pbeg, lex_pend, lex_state, lexb, line_count, line_offset, LT, LT_EQ, LT_EQ_RT, LT_LT, MINUS, MINUS_AT, MINUS_GT, OR, OR_OR, parenNest, PERCENT, PLUS, PLUS_AT, Q, QQ, QUESTION, RBRACKET, RCURLY, RPAREN, ruby_sourceline, SEMICOLON, SLASH, src, STAR, STAR_STAR, str_dquote, str_dsym, str_dword, STR_FUNC_ESCAPE, STR_FUNC_EXPAND, STR_FUNC_LABEL, STR_FUNC_LIST, STR_FUNC_QWORDS, STR_FUNC_REGEXP, STR_FUNC_SYMBOL, STR_FUNC_TERM, str_label, str_regexp, str_squote, str_ssym, str_sword, str_xquote, SUFFIX_ALL, SUFFIX_I, SUFFIX_R, TAB_WIDTH, TILDE, token, tokenSeen, tokline, tokp, USASCII_ENCODING, UTF8_ENCODING, yaccValue -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDelayedToken(int tok, int end) protected voidambiguousOperator(String op, String syn) private intampersand(boolean spaceSeen) private booleanprivate intat()private intbacktick(boolean commandState) private intbang()private intcaret()private intcolon(boolean spaceSeen) private intcomma(int c) voidcompile_error(String message) private intconsiderComplex(int token, int suffix) private intcr(int c) voiddispatchDelayedToken(int token) voidvoiddispatchIgnoredScanEvent(int token) voiddispatchScanEvent(int token) private intdoKeyword(int state) private intdollar()private intdot()private intdoubleQuote(boolean commandState) protected voidflush_string_content(org.jcodings.Encoding encoding) private intgetFloatToken(String number, int suffix) getIdent()static RipperLexer.KeywordgetKeyword(String str) private intgetNumberLiteral(String number, boolean seen_e, boolean seen_point, int nondigit) private intbooleanbooleanHas lexing started yet?voidheredoc_restore(HeredocTerm here) private intprivate intidentifier(int c, boolean commandState) private intidentifierToken(int last_state, int result, String value) booleanprivate intleftBracket(boolean spaceSeen) private intprivate intleftParen(boolean spaceSeen) private intlessThan(boolean spaceSeen) private intminus(boolean spaceSeen) protected voidmismatchedRegexpEncodingError(org.jcodings.Encoding optionEncoding, org.jcodings.Encoding encoding) intnextc()private booleannextLine()intprotected booleanonMagicComment(String name, ByteList value) private intparseNumber(int c) Parse a number from the input stream.private intparseQuote(int c) What type/kind of quote are we dealing with?protected RegexpOptionsprivate intpercent(boolean spaceSeen) private intpipe()private intplus(boolean spaceSeen) private voidprintToken(int token) private intintprivate voidreadUTF8EscapeIntoBuffer(int codepoint, ByteList buffer, boolean stringLiteral) intreadUTFEscape(ByteList buffer, boolean stringLiteral, boolean symbolLiteral) voidreadUTFEscapeRegexpLiteral(ByteList buffer) private intprivate intprivate intprivate IRubyObjectscanEventValue(int token) private intRead up to count hexadecimal digits.private charscanHexLiteral(ByteList buffer, int count, boolean strict, String errorMessage) Read up to count hexadecimal digits and store those digits in a token buffer.protected voidsetCompileOptionFlag(String name, ByteList value) protected voidsetEncoding(ByteList name) private intsetIntegerLiteral(int suffix) private intsetNumberLiteral(int type, int suffix) voidsetParser(RipperParserBase parserSupport) Parse must pass its support object for some check at bottom of yylex().voidsetStrTerm(StrTerm strterm) protected voidsetTokenInfo(String name, ByteList value) private intsingleQuote(boolean commandState) private intslash(boolean spaceSeen) private intstar(boolean spaceSeen) private inttilde()booleantokenAddMBC(int first_byte, ByteList buffer) inttokenize_ident(int result) private StringtokenToEventId(int token) voidvoidvoidprivate intyylex()Returns the next token.private intyylex2()Methods inherited from class org.jruby.lexer.LexingCommon
checkRegexpFragment, checkRegexpSyntax, column, comment_at_top, createAsEncodedString, createTokenByteList, createTokenByteList, createTokenString, createTokenString, dedent_string, flush, getBraceNest, getCmdArgumentState, getConditionState, getCurrentArg, getCurrentLine, getEncoding, getFile, getHeredocIndent, getHeredocLineIndent, getLeftParenBegin, getLineOffset, getRubySourceline, getState, getTokenCR, incrementParenNest, isAfterOperator, isARG, isASCII, isASCII, isBEG, isEND, isEndSeen, isGlobalCharPunct, isHexChar, isIdentifierChar, isLabelPossible, isLabelSuffix, isLexState, isLexStateAll, isNext_identchar, isOctChar, isSpace, isSpaceArg, lex_goto_eol, lineno, magicCommentEncoding, magicCommentMarker, newtok, numberLiteralSuffix, optionsEncodingChar, p, parser_magic_comment, parser_prepare, parseRegexpFlags, peek, peek, peekVariableName, precise_mbclen, printState, pushback, reset, resetStacks, scanOct, set_file_encoding, setBraceNest, setCurrentArg, setCurrentEncoding, setEncoding, setHeredocIndent, setHeredocLineIndent, setLeftParenBegin, setRegexpEncoding, setRubySourceline, setSource, setState, setValue, strncmp, tokAdd, tokadd_ident, tokadd_mbchar, tokadd_mbchar, tokaddmbc, tokCopy, token, update_heredoc_indent, validateFormalIdentifier, validateFormalIdentifier, value, warn_balanced, was_bol, whole_match_p
-
Field Details
-
map
-
identValue
String identValue -
parser
-
lex_strterm
-
STR_FUNC_INDENT
static final int STR_FUNC_INDENT- See Also:
-
delayed
-
delayed_line
private int delayed_line -
delayed_col
private int delayed_col -
cr_seen
private boolean cr_seen -
numberBuffer
-
-
Constructor Details
-
RipperLexer
-
-
Method Details
-
ambiguousOperator
- Specified by:
ambiguousOperatorin classLexingCommon
-
onMagicComment
- Overrides:
onMagicCommentin classLexingCommon
-
getFloatToken
-
considerComplex
private int considerComplex(int token, int suffix) -
isVerbose
public boolean isVerbose() -
warn
-
warning
-
warning
-
getKeyword
-
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:
nextcin classLexingCommon
-
dispatchHeredocEnd
public void dispatchHeredocEnd() -
compile_error
- Specified by:
compile_errorin classLexingCommon
-
tokenize_ident
public int tokenize_ident(int result) - Specified by:
tokenize_identin classLexingCommon
-
heredoc_restore
-
nextToken
- Throws:
IOException
-
getIdent
-
getRuntime
-
setParser
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
- Specified by:
setCompileOptionFlagin classLexingCommon
-
parseRegexpFlags
- Specified by:
parseRegexpFlagsin classLexingCommon- Throws:
IOException
-
mismatchedRegexpEncodingError
protected void mismatchedRegexpEncodingError(org.jcodings.Encoding optionEncoding, org.jcodings.Encoding encoding) - Specified by:
mismatchedRegexpEncodingErrorin classLexingCommon
-
setTokenInfo
- Specified by:
setTokenInfoin classLexingCommon
-
setEncoding
- Specified by:
setEncodingin classLexingCommon
-
getStrTerm
-
setStrTerm
-
createStr
-
parseQuote
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
- 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
-
tokenToEventId
-
yylex2
- Throws:
IOException
-
yylex
Returns the next token. Also sets yyVal as needed.- Returns:
- the next token
- Throws:
IOException
-
identifierToken
-
ampersand
- Throws:
IOException
-
at
- Throws:
IOException
-
backtick
- Throws:
IOException
-
bang
- Throws:
IOException
-
caret
- Throws:
IOException
-
colon
- Throws:
IOException
-
comma
- Throws:
IOException
-
doKeyword
private int doKeyword(int state) -
dollar
- Throws:
IOException
-
dot
- Throws:
IOException
-
doubleQuote
- Throws:
IOException
-
greaterThan
- Throws:
IOException
-
identifier
- Throws:
IOException
-
leftBracket
- Throws:
IOException
-
leftCurly
private int leftCurly() -
leftParen
- Throws:
IOException
-
lessThan
- Throws:
IOException
-
minus
- Throws:
IOException
-
percent
- Throws:
IOException
-
pipe
- Throws:
IOException
-
plus
- Throws:
IOException
-
questionMark
- Throws:
IOException
-
rightBracket
private int rightBracket() -
rightCurly
private int rightCurly() -
rightParen
private int rightParen() -
singleQuote
- Throws:
IOException
-
slash
- Throws:
IOException
-
star
- Throws:
IOException
-
tilde
- Throws:
IOException
-
parseNumber
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
- Throws:
IOException
-
tokenAddMBC
-
readUTFEscape
public int readUTFEscape(ByteList buffer, boolean stringLiteral, boolean symbolLiteral) throws IOException - Throws:
IOException
-
readUTF8EscapeIntoBuffer
-
readEscape
- 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
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
-