mirror of
https://github.com/AppleCommander/bastools.git
synced 2024-12-22 14:29:22 +00:00
Fixing some directive parsing snafus.
This commit is contained in:
parent
446d06af1d
commit
9dbbfdd663
@ -91,7 +91,8 @@ public abstract class Directive {
|
|||||||
* (probably EOL) to prevent loss of information.
|
* (probably EOL) to prevent loss of information.
|
||||||
*/
|
*/
|
||||||
public void append(Token token) {
|
public void append(Token token) {
|
||||||
if (token.type == Type.EOL || (token.type == Type.SYNTAX && ",".equals(token.text))) {
|
if (token.type == Type.EOL) {
|
||||||
|
while (!paramTokens.isEmpty()) {
|
||||||
String name = requireIdentToken();
|
String name = requireIdentToken();
|
||||||
if (!parameterNames.contains(name)) {
|
if (!parameterNames.contains(name)) {
|
||||||
String message = String.format("Parameter '%s' is invalid for %s directive", name, directiveName);
|
String message = String.format("Parameter '%s' is invalid for %s directive", name, directiveName);
|
||||||
@ -100,6 +101,10 @@ public abstract class Directive {
|
|||||||
requireSyntaxToken("=");
|
requireSyntaxToken("=");
|
||||||
Expression expr = buildExpression();
|
Expression expr = buildExpression();
|
||||||
parameters.put(name, expr);
|
parameters.put(name, expr);
|
||||||
|
if (!paramTokens.isEmpty()) {
|
||||||
|
requireSyntaxToken(",");
|
||||||
|
}
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
paramTokens.add(token);
|
paramTokens.add(token);
|
||||||
}
|
}
|
||||||
@ -166,6 +171,7 @@ public abstract class Directive {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
private boolean checkSyntaxToken(String syntax) {
|
private boolean checkSyntaxToken(String syntax) {
|
||||||
|
if (paramTokens.isEmpty()) return false;
|
||||||
Type tokenType = ApplesoftKeyword.find(syntax).map(t -> Type.KEYWORD).orElse(Type.SYNTAX);
|
Type tokenType = ApplesoftKeyword.find(syntax).map(t -> Type.KEYWORD).orElse(Type.SYNTAX);
|
||||||
Token token = paramTokens.get(0);
|
Token token = paramTokens.get(0);
|
||||||
return tokenType == token.type && syntax.equals(token.text);
|
return tokenType == token.type && syntax.equals(token.text);
|
||||||
|
Loading…
Reference in New Issue
Block a user