public static int captureToEOS(char[] expression, int cursor) { int length = expression.length; while (cursor != length) { switch (expression[cursor]) { case '(': case '[': case '{': cursor = balancedCapture(expression, cursor, expression[cursor]); break; case ';': case '}': return cursor; } cursor++; } return cursor; }
public void skipToEOS() { while ((cursor < length) && (expr[cursor] != ';')) { switch (expr[cursor]) { case '{': case '(': case '"': case '\'': cursor = ParseTools.balancedCapture(expr, cursor, expr[cursor]); break; } cursor++; } }
public static int captureToEOS(char[] expression, int cursor) { int length = expression.length; while (cursor != length) { switch (expression[cursor]) { case '(': case '[': case '{': cursor = balancedCapture(expression, cursor, expression[cursor]); break; case ';': case '}': return cursor; } cursor++; } return cursor; }
public static int captureToEOS(char[] expression, int cursor) { int length = expression.length; while (cursor != length) { switch (expression[cursor]) { case '(': case '[': case '{': cursor = balancedCapture(expression, cursor, expression[cursor]); break; case ';': case '}': return cursor; } cursor++; } return cursor; }
/** * This is an important aspect of the core parser tools. This method is used throughout the core parser * and sub-lexical parsers to capture a balanced capture between opening and terminating tokens such as: * <em>( [ { ' " </em> * <br> * <br> * For example: ((foo + bar + (bar - foo)) * 20;<br> * <br> * <p/> * If a balanced capture is performed from position 2, we get "(foo + bar + (bar - foo))" back.<br> * If a balanced capture is performed from position 15, we get "(bar - foo)" back.<br> * Etc. * * @param chars - * @param start - * @param type - * @return - */ public static int balancedCapture(char[] chars, int start, char type) { return balancedCapture(chars, start, chars.length, type); }
/** * This is an important aspect of the core parser tools. This method is used throughout the core parser * and sub-lexical parsers to capture a balanced capture between opening and terminating tokens such as: * <em>( [ { ' " </em> * <br> * <br> * For example: ((foo + bar + (bar - foo)) * 20;<br> * <br> * <p/> * If a balanced capture is performed from position 2, we get "(foo + bar + (bar - foo))" back.<br> * If a balanced capture is performed from position 15, we get "(bar - foo)" back.<br> * Etc. * * @param chars - * @param start - * @param type - * @return - */ public static int balancedCapture(char[] chars, int start, char type) { return balancedCapture(chars, start, chars.length, type); }
public static List<char[]> parseMethodOrConstructor(char[] parm) { int start = -1; for (int i = 0; i < parm.length; i++) { if (parm[i] == '(') { start = ++i; break; } } if (start != -1) { return parseParameterList(parm, --start + 1, balancedCapture(parm, start, '(') - start - 1); } return Collections.emptyList(); }
public static String[] parseMethodOrConstructor(char[] parm) { int start = -1; for (int i = 0; i < parm.length; i++) { if (parm[i] == '(') { start = ++i; break; } } if (start != -1) { return parseParameterList(parm, --start + 1, balancedCapture(parm, start, '(') - start - 1); } return EMPTY_STR_ARR; }
public static List<char[]> parseMethodOrConstructor(char[] parm) { int start = -1; for (int i = 0; i < parm.length; i++) { if (parm[i] == '(') { start = ++i; break; } } if (start != -1) { return parseParameterList(parm, --start + 1, balancedCapture(parm, start, '(') - start - 1); } return Collections.emptyList(); }
private static String compactinate(final String str) { final char[] expr = str.toCharArray(); final StringBuilder buf = new StringBuilder(expr.length); boolean newLine = false; for (int i = 0; i < expr.length; i++) { switch (expr[i]) { case '"': case '\'': final int start = i; buf.append(expr, start, (i = ParseTools.balancedCapture(expr, i, expr[i])) - start + 1); break; case '\n': newLine = true; buf.append('\n'); break; default: if (Character.isWhitespace(expr[i])) { buf.append(" "); if (!newLine) { i = skipWhitespace(expr, i) - 1; } } else { newLine = false; buf.append(expr[i]); } } } return buf.toString().trim(); }
private static String compactinate(final String str) { final char[] expr = str.toCharArray(); final StringBuilder buf = new StringBuilder(expr.length); boolean newLine = false; for (int i = 0; i < expr.length; i++) { switch (expr[i]) { case '"': case '\'': final int start = i; buf.append(expr, start, (i = ParseTools.balancedCapture(expr, i, expr[i])) - start + 1); break; case '\n': newLine = true; buf.append('\n'); break; default: if (Character.isWhitespace(expr[i])) { buf.append(" "); if (!newLine) { i = skipWhitespace(expr, i) - 1; } } else { newLine = false; buf.append(expr[i]); } } } return buf.toString().trim(); }
case '"': case '\'': i = ParseTools.balancedCapture(contents, i, contents[i]); break;
case '{' : if ( insideCurly ) { i = ParseTools.balancedCapture( input, i, '{' );
case '"': case '\'': i = ParseTools.balancedCapture(contents, i, contents[i]); break;
throw new CompileException("unexpected token in constructor", name, endRange); to = balancedCapture(name, endRange, start + offset, '['); sizes.add(subset(name, ++endRange, to - endRange)); endRange = to + 1;
throw new CompileException("unexpected token in constructor", name, endRange); to = balancedCapture(name, endRange, start + offset, '['); sizes.add(subset(name, ++endRange, to - endRange)); endRange = to + 1;
throw new CompileException("unexpected token in contstructor", name, endRange); to = balancedCapture(name, endRange, '['); sizes.add(subset(name, ++endRange, to - endRange)); endRange = to + 1;
case '[': case '{': i = balancedCapture(parm, i, parm[i]); continue;
case '[': case '{': i = balancedCapture(parm, i, parm[i]); continue;
protected boolean ifThenElseBlockContinues() { skipWhitespace(); if ((cursor + 4) < length) { if (expr[cursor] != ';') { cursor--; } skipWhitespace(); if ((expr[cursor] == 'e') && (expr[cursor + 1] == 'l') && (expr[cursor + 2] == 's') && (expr[cursor + 3] == 'e') && (isWhitespace(expr[cursor + 4]) || (expr[cursor + 4] == '{'))) { cursor += 4; skipWhitespace(); if (((cursor + 1) < length) && (expr[cursor] == 'i') && (expr[cursor + 1] == 'f')) { cursor += 2; expectNext('('); cursor = balancedCapture(expr, cursor, '(') + 1; } skipWhitespace(); return true; } } return false; }