Search in sources :

Example 1 with MetaType

use of priv.bajdcc.util.lexer.token.MetaType in project jMiniLang by bajdcc.

the class OperatorTokenizer method getRegexString.

public static String getRegexString() {
    String exp = "->|\\||(|)|[|]|{|}|<|>";
    MetaType[] metaTypes = new MetaType[] { MetaType.LPARAN, MetaType.RPARAN, MetaType.STAR, MetaType.PLUS, MetaType.LSQUARE, MetaType.RSQUARE, MetaType.LBRACE, MetaType.RBRACE, MetaType.DOT };
    for (MetaType meta : metaTypes) {
        exp = exp.replace(meta.getChar() + "", "\\" + meta.getChar());
    }
    return exp;
}
Also used : MetaType(priv.bajdcc.util.lexer.token.MetaType)

Example 2 with MetaType

use of priv.bajdcc.util.lexer.token.MetaType in project jMiniLang by bajdcc.

the class OperatorTokenizer method getRegexString.

public static String getRegexString() {
    MetaType[] metaTypes = new MetaType[] { MetaType.LPARAN, MetaType.RPARAN, MetaType.STAR, MetaType.PLUS, MetaType.LSQUARE, MetaType.RSQUARE, MetaType.LBRACE, MetaType.RBRACE, MetaType.DOT, MetaType.BAR, MetaType.QUERY };
    StringBuilder sb = new StringBuilder();
    for (OperatorType type : OperatorType.values()) {
        String op = type.getName();
        for (MetaType meta : metaTypes) {
            op = op.replace(meta.getChar() + "", "\\" + meta.getChar());
        }
        if (type == OperatorType.ESCAPE)
            op += op;
        sb.append(op).append("|");
    }
    if (sb.length() > 0) {
        sb.deleteCharAt(sb.length() - 1);
    }
    return sb.toString();
}
Also used : OperatorType(priv.bajdcc.util.lexer.token.OperatorType) MetaType(priv.bajdcc.util.lexer.token.MetaType)

Aggregations

MetaType (priv.bajdcc.util.lexer.token.MetaType)2 OperatorType (priv.bajdcc.util.lexer.token.OperatorType)1