in gogo/runtime/src/main/java/org/apache/felix/gogo/runtime/Tokenizer.java [44:199]
public Token next()
{
if (pushed != null)
{
Token t = pushed;
pushed = null;
return t;
}
skipSpace(last == null || Token.eq(last, "\n"));
int start = index - 1;
Token t, tn;
while (true)
{
switch (ch)
{
case EOT:
return token(start);
case '[':
word = 0;
inArray = true;
return token(start);
case ']':
inArray = false;
word++;
return token(start);
case '{':
if (start == index - 1 && Character.isWhitespace(peek()))
{
word = 0;
return token(start);
}
else
{
if (ch == '{')
{
find('}', '{');
}
else
{
find(')', '(');
}
getch();
break;
}
case '(':
if (start == index - 1)
{
word = 0;
return token(start);
}
else
{
if (ch == '{')
{
find('}', '{');
}
else
{
find(')', '(');
}
getch();
break;
}
case '>':
case '<':
t = text.subSequence(start, index);
if (!eot())
{
tn = text.subSequence(start, index + 1);
if (redir.matcher(tn).matches())
{
getch();
break;
}
}
if (redir.matcher(t).matches() && start < index - 1)
{
getch();
}
word = 0;
return token(start);
case '-':
t = text.subSequence(start, index);
if (redir.matcher(t).matches())
{
getch();
return token(start);
}
else {
getch();
break;
}
case '&':
// beginning of token
if (start == index - 1) {
if (peek() == '&' || peek() == '>')
{
getch();
getch();
}
word = 0;
return token(start);
}
// in the middle of a redirection
else if (redir.matcher(text.subSequence(start, index)).matches())
{
getch();
break;
}
else
{
word = 0;
return token(start);
}
case '|':
if (start == index - 1 && (peek() == '|' || peek() == '&'))
{
getch();
getch();
}
word = 0;
return token(start);
case ';':
word = 0;
return token(start);
case '}':
case ')':
case ' ':
case '\t':
case '\n':
case '\r':
word++;
return token(start);
case '=':
if (inArray || word < 1 || index == start + 1)
{
word++;
return token(start);
}
getch();
break;
case '\\':
escape();
getch();
break;
case '\'':
case '"':
skipQuote();
getch();
break;
default:
getch();
break;
}
}
}