-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fully support DISPLAY statement (#488)
Co-authored-by: Markus Amshove <scm@amshove.org>
- Loading branch information
1 parent
2d592db
commit 9debe20
Showing
16 changed files
with
201 additions
and
132 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
libs/natparse/src/main/java/org/amshove/natparse/natural/IDisplayNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.amshove.natparse.natural; | ||
|
||
public interface IDisplayNode extends IStatementNode, ICanHaveReportSpecification | ||
public interface IDisplayNode extends IOutputStatementNode, ICanHaveReportSpecification | ||
{} |
11 changes: 2 additions & 9 deletions
11
libs/natparse/src/main/java/org/amshove/natparse/natural/IInputStatementNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
package org.amshove.natparse.natural; | ||
|
||
import org.amshove.natparse.ReadOnlyList; | ||
import org.amshove.natparse.natural.output.IOutputElementNode; | ||
|
||
public interface IInputStatementNode extends IStatementNode | ||
{ | ||
ReadOnlyList<IOutputElementNode> operands(); | ||
|
||
ReadOnlyList<IAttributeNode> statementAttributes(); | ||
} | ||
public interface IInputStatementNode extends IOutputStatementNode | ||
{} |
11 changes: 11 additions & 0 deletions
11
libs/natparse/src/main/java/org/amshove/natparse/natural/IOutputStatementNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package org.amshove.natparse.natural; | ||
|
||
import org.amshove.natparse.ReadOnlyList; | ||
import org.amshove.natparse.natural.output.IOutputElementNode; | ||
|
||
public interface IOutputStatementNode extends IStatementNode | ||
{ | ||
ReadOnlyList<IAttributeNode> statementAttributes(); | ||
|
||
ReadOnlyList<IOutputElementNode> operands(); | ||
} |
2 changes: 1 addition & 1 deletion
2
libs/natparse/src/main/java/org/amshove/natparse/natural/IPrintNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
package org.amshove.natparse.natural; | ||
|
||
public interface IPrintNode extends IStatementNode, ICanHaveReportSpecification | ||
public interface IPrintNode extends IOutputStatementNode, ICanHaveReportSpecification | ||
{} |
11 changes: 2 additions & 9 deletions
11
libs/natparse/src/main/java/org/amshove/natparse/natural/IWriteNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,4 @@ | ||
package org.amshove.natparse.natural; | ||
|
||
import org.amshove.natparse.ReadOnlyList; | ||
import org.amshove.natparse.natural.output.IOutputElementNode; | ||
|
||
public interface IWriteNode extends IStatementNode, ICanHaveReportSpecification | ||
{ | ||
ReadOnlyList<IAttributeNode> statementAttributes(); | ||
|
||
ReadOnlyList<IOutputElementNode> operands(); | ||
} | ||
public interface IWriteNode extends IOutputStatementNode, ICanHaveReportSpecification | ||
{} |
21 changes: 2 additions & 19 deletions
21
libs/natparse/src/main/java/org/amshove/natparse/parsing/DisplayNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,6 @@ | ||
package org.amshove.natparse.parsing; | ||
|
||
import org.amshove.natparse.lexing.SyntaxToken; | ||
import org.amshove.natparse.natural.IDisplayNode; | ||
|
||
import java.util.Optional; | ||
|
||
class DisplayNode extends StatementNode implements IDisplayNode, ICanSetReportSpecification | ||
{ | ||
private SyntaxToken reportSpecification; | ||
|
||
@Override | ||
public Optional<SyntaxToken> reportSpecification() | ||
{ | ||
return Optional.ofNullable(reportSpecification); | ||
} | ||
|
||
@Override | ||
public void setReportSpecification(SyntaxToken token) | ||
{ | ||
reportSpecification = token; | ||
} | ||
} | ||
class DisplayNode extends OutputStatementNode implements IDisplayNode | ||
{} |
58 changes: 58 additions & 0 deletions
58
libs/natparse/src/main/java/org/amshove/natparse/parsing/OutputStatementNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
package org.amshove.natparse.parsing; | ||
|
||
import org.amshove.natparse.ReadOnlyList; | ||
import org.amshove.natparse.lexing.SyntaxToken; | ||
import org.amshove.natparse.natural.*; | ||
import org.amshove.natparse.natural.output.IOutputElementNode; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
class OutputStatementNode extends StatementNode implements IOutputStatementNode, ICanSetReportSpecification, ICanHaveReportSpecification | ||
{ | ||
private SyntaxToken reportSpecification; | ||
private final List<IOutputElementNode> operands = new ArrayList<>(); | ||
private IAttributeListNode statementAttributes; | ||
|
||
@Override | ||
public Optional<SyntaxToken> reportSpecification() | ||
{ | ||
return Optional.ofNullable(reportSpecification); | ||
} | ||
|
||
@Override | ||
public void setReportSpecification(SyntaxToken token) | ||
{ | ||
reportSpecification = token; | ||
} | ||
|
||
@Override | ||
public ReadOnlyList<IOutputElementNode> operands() | ||
{ | ||
return ReadOnlyList.from(operands); | ||
} | ||
|
||
@Override | ||
public ReadOnlyList<IAttributeNode> statementAttributes() | ||
{ | ||
return statementAttributes != null ? statementAttributes.attributes() : ReadOnlyList.empty(); | ||
} | ||
|
||
void addOperand(IOutputElementNode operand) | ||
{ | ||
if (operand == null) | ||
{ | ||
// stuff like tab setting, line skip etc. | ||
return; | ||
} | ||
|
||
addNode((BaseSyntaxNode) operand); | ||
operands.add(operand); | ||
} | ||
|
||
void setAttributes(IAttributeListNode attributes) | ||
{ | ||
statementAttributes = attributes; | ||
} | ||
} |
6 changes: 6 additions & 0 deletions
6
libs/natparse/src/main/java/org/amshove/natparse/parsing/PrintNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
package org.amshove.natparse.parsing; | ||
|
||
import org.amshove.natparse.natural.IPrintNode; | ||
|
||
public class PrintNode extends OutputStatementNode implements IPrintNode | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 3 additions & 55 deletions
58
libs/natparse/src/main/java/org/amshove/natparse/parsing/WriteNode.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,58 +1,6 @@ | ||
package org.amshove.natparse.parsing; | ||
|
||
import org.amshove.natparse.ReadOnlyList; | ||
import org.amshove.natparse.lexing.SyntaxToken; | ||
import org.amshove.natparse.natural.*; | ||
import org.amshove.natparse.natural.output.IOutputElementNode; | ||
import org.amshove.natparse.natural.IWriteNode; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
import java.util.Optional; | ||
|
||
class WriteNode extends StatementNode implements IWriteNode, IPrintNode, ICanSetReportSpecification | ||
{ | ||
private SyntaxToken reportSpecification; | ||
private final List<IOutputElementNode> operands = new ArrayList<>(); | ||
private IAttributeListNode statementAttributes; | ||
|
||
@Override | ||
public Optional<SyntaxToken> reportSpecification() | ||
{ | ||
return Optional.ofNullable(reportSpecification); | ||
} | ||
|
||
@Override | ||
public void setReportSpecification(SyntaxToken token) | ||
{ | ||
reportSpecification = token; | ||
} | ||
|
||
@Override | ||
public ReadOnlyList<IOutputElementNode> operands() | ||
{ | ||
return ReadOnlyList.from(operands); | ||
} | ||
|
||
@Override | ||
public ReadOnlyList<IAttributeNode> statementAttributes() | ||
{ | ||
return statementAttributes != null ? statementAttributes.attributes() : ReadOnlyList.empty(); | ||
} | ||
|
||
void addOperand(IOutputElementNode operand) | ||
{ | ||
if (operand == null) | ||
{ | ||
// stuff like tab setting, line skip etc. | ||
return; | ||
} | ||
|
||
addNode((BaseSyntaxNode) operand); | ||
operands.add(operand); | ||
} | ||
|
||
void setAttributes(IAttributeListNode attributes) | ||
{ | ||
statementAttributes = attributes; | ||
} | ||
} | ||
class WriteNode extends OutputStatementNode implements IWriteNode | ||
{} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.