Skip to content

Commit

Permalink
refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
fglock committed Oct 21, 2024
1 parent 4f208f6 commit f948e86
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/main/java/org/perlonjava/parser/Parser.java
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ public int getPrecedence(String operator) {
public Node parse() {
if (tokens.get(tokenIndex).text.equals("=")) {
// looks like pod: insert a newline to trigger pod parsing
tokens.add(0, new LexerToken(LexerTokenType.NEWLINE, "\n"));
tokens.addFirst(new LexerToken(LexerTokenType.NEWLINE, "\n"));
}
return parseBlock();
}
Expand Down Expand Up @@ -464,7 +464,7 @@ public Node parseCoreOperator(LexerToken token) {
case "split":
// RuntimeList split(RuntimeScalar quotedRegex, RuntimeScalar string, RuntimeScalar limitArg)
operand = ListParser.parseZeroOrMoreList(this, 1, false, true, false, true);
Node separator = ((ListNode) operand).elements.remove(0);
Node separator = ((ListNode) operand).elements.removeFirst();
if (separator instanceof OperatorNode) {
if (((OperatorNode) separator).operator.equals("matchRegex")) {
((OperatorNode) separator).operator = "quoteRegex";
Expand Down Expand Up @@ -508,7 +508,7 @@ public Node parseCoreOperator(LexerToken token) {
operand = ListParser.parseZeroOrMoreList(this, 0, false, true, false, false);
// Node handle = ((ListNode) operand).handle;
// ((ListNode) operand).handle = null;
Node handle = ((ListNode) operand).elements.remove(0);
Node handle = ((ListNode) operand).elements.removeFirst();
if (handle == null) {
handle = new IdentifierNode("main::STDOUT", currentIndex);
}
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/perlonjava/parser/StatementParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -253,7 +253,7 @@ public static Node parseUseDeclaration(Parser parser, LexerToken token) {
RuntimeList codeList = Universal.can(canArgs, RuntimeContextType.SCALAR);
ctx.logDebug("Use can(" + packageName + ", " + importMethod + "): " + codeList);
if (codeList.size() == 1) {
RuntimeScalar code = (RuntimeScalar) codeList.elements.get(0);
RuntimeScalar code = (RuntimeScalar) codeList.elements.getFirst();
if (code.getBoolean()) {
// call the method
ctx.logDebug("Use call : " + importMethod + "(" + args + ")");
Expand Down Expand Up @@ -319,7 +319,7 @@ public static BlockNode parseOptionalPackageBlock(Parser parser, IdentifierNode
BlockNode block = parser.parseBlock();

// Insert packageNode as first statement in block
block.elements.add(0, packageNode);
block.elements.addFirst(packageNode);

parser.ctx.symbolTable.exitScope();
TokenUtils.consume(parser, LexerTokenType.OPERATOR, "}");
Expand Down
2 changes: 1 addition & 1 deletion src/main/java/org/perlonjava/parser/SubroutineParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ public class SubroutineParser {
/**
* Parses a subroutine call.
*
* @param parser
* @param parser The parser object
* @return A Node representing the parsed subroutine call.
*/
static Node parseSubroutineCall(Parser parser) {
Expand Down

0 comments on commit f948e86

Please sign in to comment.