boolean isModule = false;
boolean isUses = false;
boolean isExpression = false;
while (beginIndex < tokens.size()) {
Token t = (Token) tokens.get(beginIndex);
if (t.getType() == EsperEPL2GrammarParser.EOF) {
break;
}
if ((t.getType() == EsperEPL2GrammarParser.WS) ||
(t.getType() == EsperEPL2GrammarParser.SL_COMMENT) ||
(t.getType() == EsperEPL2GrammarParser.ML_COMMENT)) {
beginIndex++;
continue;
}
String tokenText = t.getText().trim().toLowerCase();
if (tokenText.equals("module")) {
isModule = true; isMeta = true;
}
else if (tokenText.equals("uses")) {
isUses = true; isMeta = true;
}
else if (tokenText.equals("import")) {
isMeta = true;
}
else {
isExpression = true;
break;
}
beginIndex++;
beginIndex++; // skip space
break;
}
if (isExpression) {
return new ParseNodeExpression(item);
}
if (!isMeta) {
return new ParseNodeComment(item);
}
// check meta tag (module, uses, import)
StringWriter buffer = new StringWriter();
for (int i = beginIndex; i < tokens.size(); i++)
{
Token t = (Token) tokens.get(i);
if (t.getType() == EsperEPL2GrammarParser.EOF) {
break;
}
if ((t.getType() != EsperEPL2GrammarParser.IDENT) &&
(t.getType() != EsperEPL2GrammarParser.DOT) &&
(t.getType() != EsperEPL2GrammarParser.STAR) &&
(!t.getText().matches("[a-zA-Z]*"))) {
throw getMessage(isModule, isUses, resourceName, t.getType());
}
buffer.append(t.getText().trim());
}
String result = buffer.toString().trim();
if (result.length() == 0) {
throw getMessage(isModule, isUses, resourceName, -1);