@Override public void regexpFragmentCheck(RegexpNode end, ByteList value) { setRegexpEncoding(end, value); RubyRegexp.preprocessCheck(configuration.getRuntime(), value); }
@Override public void regexpFragmentCheck(RegexpNode end, ByteList value) { setRegexpEncoding(end, value); RubyRegexp.preprocessCheck(configuration.getRuntime(), value); }
private ByteList createMaster(RegexpOptions options) { Encoding encoding = options.setup(configuration.getRuntime()); return new ByteList(ByteList.NULL_ARRAY, encoding); }
public void compile_error(String message) { // mri: rb_compile_error_with_enc String line = lexer.getCurrentLine(); ISourcePosition position = lexer.getPosition(); String errorMessage = lexer.getFile() + ":" + (position.getLine() + 1) + ": "; if (line != null && line.length() > 5) { boolean addNewline = message != null && ! message.endsWith("\n"); message += (addNewline ? "\n" : "") + line; } throw getConfiguration().getRuntime().newSyntaxError(errorMessage + message); }
public void compile_error(String message) { // mri: rb_compile_error_with_enc String line = lexer.getCurrentLine(); ISourcePosition position = lexer.getPosition(); String errorMessage = lexer.getFile() + ":" + (position.getLine() + 1) + ": "; if (line != null && line.length() > 5) { boolean addNewline = message != null && ! message.endsWith("\n"); message += (addNewline ? "\n" : "") + line; } throw getConfiguration().getRuntime().newSyntaxError(errorMessage + message); }
private ByteList createMaster(RegexpOptions options) { if (lexer.isOneEight()) { return ByteList.create(""); } else { Encoding encoding = options.setup19(configuration.getRuntime()); return new ByteList(new byte[] {}, encoding); } }
private ByteList createMaster(RegexpOptions options) { if (lexer.isOneEight()) { return ByteList.create(""); } else { Encoding encoding = options.setup19(configuration.getRuntime()); return new ByteList(new byte[] {}, encoding); } }
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = new FileNode(lexer.tokline, new ByteList(lexer.getFile().getBytes(), support.getConfiguration().getRuntime().getEncodingService().getLocaleEncoding())); return yyVal; } };
@Override public Object execute(ParserSupport support, RubyLexer lexer, Object yyVal, Object[] yyVals, int yyTop) { yyVal = new FileNode(lexer.tokline, new ByteList(lexer.getFile().getBytes(), support.getConfiguration().getRuntime().getEncodingService().getLocaleEncoding())); return yyVal; } };
private int identifierToken(int result, ByteList value) { Ruby runtime = parserSupport.getConfiguration().getRuntime(); String id = runtime.newSymbol(value).idString(); if (result == RubyParser.tIDENTIFIER && !isLexState(last_state, EXPR_DOT|EXPR_FNAME) && parserSupport.getCurrentScope().isDefined(id) >= 0) { setState(EXPR_END|EXPR_LABEL); } yaccValue = value; return result; }
private int identifierToken(int result, ByteList value) { Ruby runtime = parserSupport.getConfiguration().getRuntime(); String id = runtime.newSymbol(value).idString(); if (result == RubyParser.tIDENTIFIER && !isLexState(last_state, EXPR_DOT|EXPR_FNAME) && parserSupport.getCurrentScope().isDefined(id) >= 0) { setState(EXPR_END|EXPR_LABEL); } yaccValue = value; return result; }
public void pushLocalScope() { currentScope = configuration.getRuntime().getStaticScopeFactory().newLocalScope(currentScope, lexer.getFile()); currentScope.setCommandArgumentStack(lexer.getCmdArgumentState().getStack()); lexer.getCmdArgumentState().reset(0); }
public int tokenize_ident(int result) { // FIXME: Get token from newtok index to lex_p? ByteList value = createTokenByteList(); Ruby runtime = parserSupport.getConfiguration().getRuntime(); String id = runtime.newSymbol(value).idString(); if (isLexState(last_state, EXPR_DOT|EXPR_FNAME) && parserSupport.getCurrentScope().isDefined(id) >= 0) { setState(EXPR_END); } yaccValue = value; return result; }
public void pushLocalScope() { currentScope = configuration.getRuntime().getStaticScopeFactory().newLocalScope(currentScope, lexer.getFile()); currentScope.setCommandArgumentStack(lexer.getCmdArgumentState().getStack()); lexer.getCmdArgumentState().reset(0); }
public int tokenize_ident(int result) { // FIXME: Get token from newtok index to lex_p? ByteList value = createTokenByteList(); Ruby runtime = parserSupport.getConfiguration().getRuntime(); String id = runtime.newSymbol(value).idString(); if (isLexState(last_state, EXPR_DOT|EXPR_FNAME) && parserSupport.getCurrentScope().isDefined(id) >= 0) { setState(EXPR_END); } yaccValue = value; return result; }
protected void setEncoding(ByteList name) { Ruby runtime = parserSupport.getConfiguration().getRuntime(); Encoding newEncoding = runtime.getEncodingService().loadEncoding(name); if (newEncoding == null) throw runtime.newArgumentError("unknown encoding name: " + name.toString()); if (!newEncoding.isAsciiCompatible()) throw runtime.newArgumentError(name.toString() + " is not ASCII compatible"); setEncoding(newEncoding); }
protected void setEncoding(ByteList name) { Ruby runtime = parserSupport.getConfiguration().getRuntime(); Encoding newEncoding = runtime.getEncodingService().loadEncoding(name); if (newEncoding == null) throw runtime.newArgumentError("unknown encoding name: " + name.toString()); if (!newEncoding.isAsciiCompatible()) throw runtime.newArgumentError(name.toString() + " is not ASCII compatible"); setEncoding(newEncoding); }
protected void handleFileEncodingComment(ByteList encodingLine) throws IOException { int realSize = encodingLine.getRealSize(); int begin = encodingLine.getBegin(); Matcher matcher = encodingRegexp.matcher(encodingLine.getUnsafeBytes(), begin, begin + realSize); int result = RubyRegexp.matcherSearch(parserSupport.getConfiguration().getRuntime(), matcher, begin, begin + realSize, Option.IGNORECASE); if (result < 0) return; int begs[] = matcher.getRegion().beg; int ends[] = matcher.getRegion().end; setEncoding(new ByteList(encodingLine.getUnsafeBytes(), begs[1], ends[1] - begs[1])); }
protected void handleFileEncodingComment(ByteList encodingLine) throws IOException { int realSize = encodingLine.getRealSize(); int begin = encodingLine.getBegin(); Matcher matcher = encodingRegexp.matcher(encodingLine.getUnsafeBytes(), begin, begin + realSize); int result = RubyRegexp.matcherSearch(parserSupport.getConfiguration().getRuntime(), matcher, begin, begin + realSize, Option.IGNORECASE); if (result < 0) return; int begs[] = matcher.getRegion().beg; int ends[] = matcher.getRegion().end; setEncoding(new ByteList(encodingLine.getUnsafeBytes(), begs[1], ends[1] - begs[1])); }
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; }