use of priv.bajdcc.util.lexer.regex.RegexStringIteratorData in project jMiniLang by bajdcc.
the class LineFilter method filter.
@Override
public RegexStringIteratorData filter(IRegexStringIterator iterator) {
RegexStringIteratorData data = new RegexStringIteratorData();
if (!iterator.available()) {
data.kMeta = MetaType.END;
data.chCurrent = MetaType.END.getChar();
} else {
data.kMeta = iterator.meta();
data.chCurrent = iterator.current();
iterator.next();
if (data.kMeta == MetaType.ESCAPE) {
// 过滤转义换行
iterator.next();
iterator.snapshot();
data.kMeta = iterator.meta();
if (data.kMeta == MetaType.NEW_LINE || data.kMeta == MetaType.CARRIAGE_RETURN) {
// 确认换行
iterator.next();
iterator.cover();
data.kMeta = iterator.meta();
if (data.kMeta == MetaType.NEW_LINE || data.kMeta == MetaType.CARRIAGE_RETURN) {
// 确认换行
iterator.discard();
iterator.next();
} else {
iterator.restore();
}
data.kMeta = MetaType.MUST_SAVE;
data.chCurrent = iterator.current();
iterator.next();
} else {
iterator.restore();
}
}
}
return data;
}
use of priv.bajdcc.util.lexer.regex.RegexStringIteratorData in project jMiniLang by bajdcc.
the class StringFilter method filter.
@Override
public RegexStringIteratorData filter(IRegexStringIterator iterator) {
// 获取解析组件
RegexStringUtility utility = iterator.utility();
RegexStringIteratorData data = new RegexStringIteratorData();
try {
if (!iterator.available()) {
data.kMeta = MetaType.END;
data.chCurrent = MetaType.END.getChar();
} else {
data.kMeta = iterator.meta();
data.chCurrent = iterator.current();
iterator.next();
if (data.kMeta == kMeta) {
// 过滤终结符
data.kMeta = MetaType.NULL;
} else if (data.kMeta == MetaType.ESCAPE) {
// 处理转义
data.chCurrent = iterator.current();
iterator.next();
data.kMeta = MetaType.MUST_SAVE;
data.chCurrent = utility.fromEscape(data.chCurrent, RegexError.ESCAPE);
}
}
} catch (RegexException e) {
System.err.println(e.getPosition() + " : " + e.getMessage());
data.kMeta = MetaType.ERROR;
data.chCurrent = MetaType.ERROR.getChar();
}
return data;
}
use of priv.bajdcc.util.lexer.regex.RegexStringIteratorData in project jMiniLang by bajdcc.
the class StringPairFilter method filter.
@Override
public RegexStringIteratorData filter(IRegexStringIterator iterator) {
// 获取解析组件
RegexStringUtility utility = iterator.utility();
RegexStringIteratorData data = new RegexStringIteratorData();
try {
if (!iterator.available()) {
data.kMeta = MetaType.END;
data.chCurrent = MetaType.END.getChar();
} else {
data.kMeta = iterator.meta();
data.chCurrent = iterator.current();
iterator.next();
if (data.kMeta == kMetaBegin || data.kMeta == kMetaEnd) {
// 过滤终结符
data.kMeta = MetaType.NULL;
} else if (data.kMeta == MetaType.ESCAPE) {
// 处理转义
data.chCurrent = iterator.current();
iterator.next();
data.kMeta = MetaType.MUST_SAVE;
data.chCurrent = utility.fromEscape(data.chCurrent, RegexError.ESCAPE);
}
}
} catch (RegexException e) {
System.err.println(e.getPosition() + " : " + e.getMessage());
data.kMeta = MetaType.ERROR;
data.chCurrent = MetaType.ERROR.getChar();
}
return data;
}
use of priv.bajdcc.util.lexer.regex.RegexStringIteratorData in project jMiniLang by bajdcc.
the class CharacterFilter method filter.
@Override
public RegexStringIteratorData filter(IRegexStringIterator iterator) {
// 获取解析组件
RegexStringUtility utility = iterator.utility();
RegexStringIteratorData data = new RegexStringIteratorData();
try {
if (!iterator.available()) {
data.kMeta = MetaType.END;
data.chCurrent = MetaType.END.getChar();
} else {
data.kMeta = iterator.meta();
data.chCurrent = iterator.current();
iterator.next();
if (data.kMeta == MetaType.SINGLE_QUOTE) {
// 过滤单引号
data.kMeta = MetaType.NULL;
} else if (data.kMeta == MetaType.ESCAPE) {
// 处理转义
data.chCurrent = iterator.current();
iterator.next();
data.kMeta = MetaType.MUST_SAVE;
data.chCurrent = utility.fromEscape(data.chCurrent, RegexError.ESCAPE);
}
}
} catch (RegexException e) {
System.err.println(e.getPosition() + " : " + e.getMessage());
data.kMeta = MetaType.ERROR;
data.chCurrent = MetaType.ERROR.getChar();
}
return data;
}
Aggregations