Skip to content

Commit

Permalink
Merge pull request #204 from MarkusAmshove/natparse/expand-reduce
Browse files Browse the repository at this point in the history
  • Loading branch information
MarkusAmshove authored Apr 29, 2023
2 parents 6fb8b07 + a1edb4b commit 20c6b04
Show file tree
Hide file tree
Showing 16 changed files with 507 additions and 4 deletions.
8 changes: 4 additions & 4 deletions docs/implemented-statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ This document tracks the implementation status of Natural statements.

Legend:

:x: - not implemented (67)
:x: - not implemented (65)

:white_check_mark: - implemented or reporting (49)
:white_check_mark: - implemented or reporting (51)

partial - partially implemented to prevent false positives (6)

Expand Down Expand Up @@ -55,7 +55,7 @@ partial - partially implemented to prevent false positives (6)
| END TRANSACTION | :x: |
| ESCAPE | :white_check_mark: |
| EXAMINE | :white_check_mark: |
| EXPAND | :x: |
| EXPAND | :white_check_mark: |
| FETCH | :white_check_mark: |
| FIND | :white_check_mark: |
| FOR | :white_check_mark: |
Expand Down Expand Up @@ -94,7 +94,7 @@ partial - partially implemented to prevent false positives (6)
| READ RESULT SET (SQL) | :x: |
| READ WORK FILE | :x: |
| READLOB | :x: |
| REDUCE | :x: |
| REDUCE | :white_check_mark: |
| REINPUT | :x: |
| REJECT | :x: |
| RELEASE | :x: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.amshove.natparse.natural;

import javax.annotation.Nullable;

public interface IExpandArrayNode extends IStatementNode
{
IVariableReferenceNode arrayToExpand();

@Nullable
IVariableReferenceNode errorVariable();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.amshove.natparse.natural;

import javax.annotation.Nullable;

public interface IExpandDynamicNode extends IStatementNode
{
IVariableReferenceNode variableToExpand();

int sizeToExpandTo();

@Nullable
IVariableReferenceNode errorVariable();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.amshove.natparse.natural;

import javax.annotation.Nullable;

public interface IReduceArrayNode extends IStatementNode
{
IVariableReferenceNode arrayToReduce();

@Nullable
IVariableReferenceNode errorVariable();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package org.amshove.natparse.natural;

import javax.annotation.Nullable;

public interface IReduceDynamicNode extends IStatementNode
{
IVariableReferenceNode variableToReduce();

int sizeToReduceTo();

@Nullable
IVariableReferenceNode errorVariable();
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
package org.amshove.natparse.natural;

import javax.annotation.Nullable;

public interface IResizeArrayNode extends IStatementNode
{
IVariableReferenceNode arrayToResize();

@Nullable
IVariableReferenceNode errorVariable();
}
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
package org.amshove.natparse.natural;

import javax.annotation.Nullable;

public interface IResizeDynamicNode extends IStatementNode
{
IVariableReferenceNode variableToResize();

int sizeToResizeTo();

@Nullable
IVariableReferenceNode errorVariable();
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.amshove.natparse.parsing;

import org.amshove.natparse.natural.IExpandArrayNode;
import org.amshove.natparse.natural.IVariableReferenceNode;

class ExpandArrayNode extends StatementNode implements IExpandArrayNode
{
private IVariableReferenceNode arrayToExpand;
private IVariableReferenceNode errorVariable;

@Override
public IVariableReferenceNode arrayToExpand()
{
return arrayToExpand;
}

@Override
public IVariableReferenceNode errorVariable()
{
return errorVariable;
}

void setArrayToExpand(IVariableReferenceNode array)
{
arrayToExpand = array;
}

void setErrorVariable(IVariableReferenceNode errorVariable)
{
this.errorVariable = errorVariable;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.amshove.natparse.parsing;

import org.amshove.natparse.natural.IExpandDynamicNode;
import org.amshove.natparse.natural.IVariableReferenceNode;

class ExpandDynamicNode extends StatementNode implements IExpandDynamicNode
{
private IVariableReferenceNode variableToExpand;
private IVariableReferenceNode errorVariable;
private int sizeToExpandTo;

@Override
public IVariableReferenceNode variableToExpand()
{
return variableToExpand;
}

@Override
public int sizeToExpandTo()
{
return sizeToExpandTo;
}

@Override
public IVariableReferenceNode errorVariable()
{
return errorVariable;
}

void setVariableToResize(IVariableReferenceNode variableToExpand)
{
this.variableToExpand = variableToExpand;
}

void setSizeToResizeTo(int sizeToExpandTo)
{
this.sizeToExpandTo = sizeToExpandTo;
}

void setErrorVariable(IVariableReferenceNode errorVariable)
{
this.errorVariable = errorVariable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -421,6 +421,15 @@ public static IDiagnostic invalidLiteralType(ILiteralNode literal, SyntaxKind al
);
}

public static IDiagnostic invalidNumericValue(ILiteralNode node, int actualValue, int allowedValue)
{
return ParserDiagnostic.create(
"Value %d is not allowed here, only %d can be used".formatted(actualValue, allowedValue),
node,
ParserError.INVALID_LITERAL_VALUE
);
}

public static IDiagnostic invalidNumericRange(ILiteralNode node, int actualValue, int lowestValue, int highestValue)
{
return ParserDiagnostic.create(
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
package org.amshove.natparse.parsing;

import org.amshove.natparse.natural.IReduceArrayNode;
import org.amshove.natparse.natural.IVariableReferenceNode;

class ReduceArrayNode extends StatementNode implements IReduceArrayNode
{
private IVariableReferenceNode arrayToReduce;
private IVariableReferenceNode errorVariable;

@Override
public IVariableReferenceNode arrayToReduce()
{
return arrayToReduce;
}

@Override
public IVariableReferenceNode errorVariable()
{
return errorVariable;
}

void setArrayToReduce(IVariableReferenceNode array)
{
arrayToReduce = array;
}

void setErrorVariable(IVariableReferenceNode errorVariable)
{
this.errorVariable = errorVariable;
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package org.amshove.natparse.parsing;

import org.amshove.natparse.natural.IReduceDynamicNode;
import org.amshove.natparse.natural.IVariableReferenceNode;

class ReduceDynamicNode extends StatementNode implements IReduceDynamicNode
{
private IVariableReferenceNode variableToReduce;
private IVariableReferenceNode errorVariable;
private int sizeToReduceTo;

@Override
public IVariableReferenceNode variableToReduce()
{
return variableToReduce;
}

@Override
public IVariableReferenceNode errorVariable()
{
return errorVariable;
}

@Override
public int sizeToReduceTo()
{
return sizeToReduceTo;
}

void setVariableToResize(IVariableReferenceNode variableToReduce)
{
this.variableToReduce = variableToReduce;
}

void setSizeToResizeTo(int sizeToReduceTo)
{
this.sizeToReduceTo = sizeToReduceTo;
}

void setErrorVariable(IVariableReferenceNode errorVariable)
{
this.errorVariable = errorVariable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,27 @@
class ResizeArrayNode extends StatementNode implements IResizeArrayNode
{
private IVariableReferenceNode arrayToResize;
private IVariableReferenceNode errorVariable;

@Override
public IVariableReferenceNode arrayToResize()
{
return arrayToResize;
}

@Override
public IVariableReferenceNode errorVariable()
{
return errorVariable;
}

void setArrayToResize(IVariableReferenceNode array)
{
arrayToResize = array;
}

void setErrorVariable(IVariableReferenceNode errorVariable)
{
this.errorVariable = errorVariable;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@
class ResizeDynamicNode extends StatementNode implements IResizeDynamicNode
{
private IVariableReferenceNode variableToResize;
private IVariableReferenceNode errorVariable;

private int sizeToResizeTo;

@Override
Expand All @@ -20,6 +22,12 @@ public int sizeToResizeTo()
return sizeToResizeTo;
}

@Override
public IVariableReferenceNode errorVariable()
{
return errorVariable;
}

void setVariableToResize(IVariableReferenceNode variableToResize)
{
this.variableToResize = variableToResize;
Expand All @@ -29,4 +37,9 @@ void setSizeToResizeTo(int sizeToResizeTo)
{
this.sizeToResizeTo = sizeToResizeTo;
}

void setErrorVariable(IVariableReferenceNode errorVariable)
{
this.errorVariable = errorVariable;
}
}
Loading

0 comments on commit 20c6b04

Please sign in to comment.