Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Consume OPTIONS statement #353

Merged
merged 1 commit into from
Aug 21, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/implemented-statements.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ This document tracks the implementation status of Natural statements.
Legend:


:x: - not implemented (47)
:x: - not implemented (46)

:white_check_mark: - implemented or reporting (57)

partial - partially implemented to prevent false positives (13)
partial - partially implemented to prevent false positives (14)


| Statement | Status |
Expand Down Expand Up @@ -71,7 +71,7 @@ partial - partially implemented to prevent false positives (13)
| IF SELECTION | :white_check_mark: |
| IGNORE | :white_check_mark: |
| INCLUDE | :white_check_mark: |
| INPUT | partial |
| INPUT | partial |
| INSERT (SQL) | partial |
| INTERFACE | :x: |
| LIMIT | :white_check_mark: |
Expand All @@ -81,7 +81,7 @@ partial - partially implemented to prevent false positives (13)
| NEWPAGE | :white_check_mark: |
| ON ERROR | :white_check_mark: |
| OPEN CONVERSATION | :x: |
| OPTIONS | :x: |
| OPTIONS | :partial: |
| PARSE XML | :x: |
| PASSW | :x: |
| PERFORM | :white_check_mark: |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.amshove.natparse.natural;

public interface IOptionsStatementNode extends IStatementNode
{}
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.amshove.natparse.parsing;

import org.amshove.natparse.natural.IOptionsStatementNode;

class OptionsStatementNode extends StatementNode implements IOptionsStatementNode
{

}
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,9 @@ private StatementListNode statementList(Set<SyntaxKind> endTokenKinds)
case INPUT:
statementList.addStatement(inputStatement());
break;
case OPTIONS:
statementList.addStatement(options());
break;
case SELECT:
statementList.addStatement(select());
break;
Expand Down Expand Up @@ -468,6 +471,21 @@ private StatementListNode statementList(Set<SyntaxKind> endTokenKinds)
return statementList;
}

private StatementNode options() throws ParseError
{
var options = new OptionsStatementNode();
consumeMandatory(options, SyntaxKind.OPTIONS);
while (peekKind(1, SyntaxKind.EQUALS_SIGN))
{
// Currently consume anything in the form of A = B. There doesn't seem to be a good documentation about possible options
consumeMandatoryIdentifierTokenNode(options);
consumeMandatory(options, SyntaxKind.EQUALS_SIGN);
consume(options);
}

return options;
}

private StatementNode onError() throws ParseError
{
var onError = new OnErrorNode();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3667,6 +3667,18 @@ void reportADiagnosticWhenDecideOnNoneBodyIsEmpty()
""", ParserError.STATEMENT_HAS_EMPTY_BODY);
}

@Test
void parseOptions()
{
assertParsesWithoutDiagnostics("OPTIONS TQMARK=OFF");
}

@Test
void parseMultipleOptions()
{
assertParsesWithoutDiagnostics("OPTIONS TQMARK=OFF TQMARK=ON SOME=THING");
}

@ParameterizedTest
@ValueSource(strings =
{
Expand Down