private int magicCommentMarker(ByteList str, int begin) { int i = begin; int len = str.length(); while (i < len) { switch (str.charAt(i)) { case '-': if (i >= 2 && str.charAt(i - 1) == '*' && str.charAt(i - 2) == '-') return i + 1; i += 2; break; case '*': if (i + 1 >= len) return -1; if (str.charAt(i + 1) != '-') { i += 4; } else if (str.charAt(i - 1) != '-') { i += 2; } else { return i + 2; } break; default: i += 3; break; } } return -1; }
public static int magicCommentMarker(ByteList str, int begin) { int i = begin; int len = str.length(); while (i < len) { switch (str.charAt(i)) { case '-': if (i >= 2 && str.charAt(i - 1) == '*' && str.charAt(i - 2) == '-') return i + 1; i += 2; break; case '*': if (i + 1 >= len) return -1; if (str.charAt(i + 1) != '-') { i += 4; } else if (str.charAt(i - 1) != '-') { i += 2; } else { return i + 2; } break; default: i += 3; break; } } return -1; }
public static int magicCommentMarker(ByteList str, int begin) { int i = begin; int len = str.length(); while (i < len) { switch (str.charAt(i)) { case '-': if (i >= 2 && str.charAt(i - 1) == '*' && str.charAt(i - 2) == '-') return i + 1; i += 2; break; case '*': if (i + 1 >= len) return -1; if (str.charAt(i + 1) != '-') { i += 4; } else if (str.charAt(i - 1) != '-') { i += 2; } else { return i + 2; } break; default: i += 3; break; } } return -1; }
private int magicCommentMarker(ByteList str, int begin) { int i = begin; int len = str.length(); while (i < len) { switch (str.charAt(i)) { case '-': if (i >= 2 && str.charAt(i - 1) == '*' && str.charAt(i - 2) == '-') return i + 1; i += 2; break; case '*': if (i + 1 >= len) return -1; if (str.charAt(i + 1) != '-') { i += 4; } else if (str.charAt(i - 1) != '-') { i += 2; } else { return i + 2; } break; default: i += 3; break; } } return -1; }
public boolean is_local_id(ByteList name) { return lexer.isIdentifierChar(name.charAt(0)); }
public boolean is_local_id(ByteList name) { return lexer.isIdentifierChar(name.charAt(0)); }
public void validateFormalIdentifier(ByteList identifier) { char first = identifier.charAt(0); if (Character.isUpperCase(first)) { compile_error("formal argument cannot be a constant"); } switch(first) { case '@': if (identifier.charAt(1) == '@') { compile_error("formal argument cannot be a class variable"); } else { compile_error("formal argument cannot be an instance variable"); } break; case '$': compile_error("formal argument cannot be a global variable"); break; default: // This mechanism feels a tad dicey but at this point we are dealing with a valid // method name at least so we should not need to check the entire string... char last = identifier.charAt(identifier.length() - 1); if (last == '=' || last == '?' || last == '!') { compile_error("formal argument must be local variable"); } } }
public void validateFormalIdentifier(ByteList identifier) { char first = identifier.charAt(0); if (Character.isUpperCase(first)) { compile_error("formal argument cannot be a constant"); } switch(first) { case '@': if (identifier.charAt(1) == '@') { compile_error("formal argument cannot be a class variable"); } else { compile_error("formal argument cannot be an instance variable"); } break; case '$': compile_error("formal argument cannot be a global variable"); break; default: // This mechanism feels a tad dicey but at this point we are dealing with a valid // method name at least so we should not need to check the entire string... char last = identifier.charAt(identifier.length() - 1); if (last == '=' || last == '?' || last == '!') { compile_error("formal argument must be local variable"); } } }
private boolean matches(ByteList match, ByteList buffer, int length) throws IOException { int c; for (int i = 0; i < length; i++) { c = read(); buffer.append(c); if (match.charAt(i) != c) { unreadMany(buffer); return false; } } return true; }
private boolean matches(ByteList match, ByteList buffer, int length) throws IOException { int c; for (int i = 0; i < length; i++) { c = read(); buffer.append(c); if (match.charAt(i) != c) { unreadMany(buffer); return false; } } return true; }
private boolean matches(ByteList match, ByteList buffer, int length) throws IOException { int c; for (int i = 0; i < length; i++) { c = read(); buffer.append(c); if (match.charAt(i) != c) { unreadMany(buffer); return false; } } return true; }
if (marker.charAt(i) != read()) { index = start; return false;
private Variable argumentResult(RubySymbol name) { boolean isUnderscore = name.getBytes().realSize() == 1 && name.getBytes().charAt(0) == '_'; if (isUnderscore && underscoreVariableSeen) { return createTemporaryVariable(); } else { if (isUnderscore) underscoreVariableSeen = true; return getNewLocalVariable(name, 0); } }
private Variable argumentResult(RubySymbol name) { boolean isUnderscore = name.getBytes().realSize() == 1 && name.getBytes().charAt(0) == '_'; if (isUnderscore && underscoreVariableSeen) { return createTemporaryVariable(); } else { if (isUnderscore) underscoreVariableSeen = true; return getNewLocalVariable(name, 0); } }
public static IRubyObject valid_constant_name_p(IRubyObject recv, IRubyObject name) { RubyString sname = name.convertToString(); if (sname.getByteList().length() == 0) { return recv.getRuntime().getFalse(); } return Character.isUpperCase(sname.getByteList().charAt(0)) ? recv.getRuntime().getTrue() : recv.getRuntime().getFalse(); }
public String toString() { try { ByteList buffer = new ByteList(20); buffer.append(twoAgo); buffer.append(oneAgo); buffer.append(new byte[] {'-', '>'}); int i = 0; for (; i < 20; i++) { int c = read(); if (c == 0) { i--; break; } buffer.append(c); } for (; i >= 0; i++) { unread(buffer.charAt(i)); } buffer.append(new byte[] {' ', '.', '.', '.'}); return buffer.toString(); } catch(Exception e) { return null; } }
public ByteList shadowing_lvar(ByteList nameBytes) { if (nameBytes.realSize() == 1 && nameBytes.charAt(0) == '_') return nameBytes; RubySymbol name = symbolID(nameBytes); String id = name.idString(); StaticScope current = getCurrentScope(); if (current.exists(id) >= 0) yyerror("duplicated argument name"); if (current.isBlockScope() && warnings.isVerbose() && current.isDefined(id) >= 0 && Options.PARSER_WARN_LOCAL_SHADOWING.load()) { Ruby runtime = getConfiguration().getRuntime(); warnings.warning(ID.STATEMENT_NOT_REACHED, lexer.getFile(), lexer.getPosition().getLine(), str(runtime, "shadowing outer local variable - ", ids(runtime, name))); } return nameBytes; }
public ByteList shadowing_lvar(ByteList nameBytes) { if (nameBytes.realSize() == 1 && nameBytes.charAt(0) == '_') return nameBytes; RubySymbol name = symbolID(nameBytes); String id = name.idString(); StaticScope current = getCurrentScope(); if (current.exists(id) >= 0) yyerror("duplicated argument name"); if (current.isBlockScope() && warnings.isVerbose() && current.isDefined(id) >= 0 && Options.PARSER_WARN_LOCAL_SHADOWING.load()) { Ruby runtime = getConfiguration().getRuntime(); warnings.warning(ID.STATEMENT_NOT_REACHED, lexer.getFile(), lexer.getPosition().getLine(), str(runtime, "shadowing outer local variable - ", ids(runtime, name))); } return nameBytes; }
char first = kcodeBytes.length() > 0 ? kcodeBytes.charAt(0) : 0; switch (first) { case 'n': case 'N':
char first = kcodeBytes.length() > 0 ? kcodeBytes.charAt(0) : 0; switch (first) { case 'n': case 'N':