From 0b190104c62fd78c6f5467cb62cd6265be76585e Mon Sep 17 00:00:00 2001 From: Daniel Date: Tue, 5 Mar 2024 20:03:38 +0200 Subject: [PATCH] includes previously unversioned files --- .../parser/SoftwareRequirements.interp | 48 ++ .../parser/SoftwareRequirements.tokens | 25 + .../SoftwareRequirementsBaseListener.java | 148 ++++ .../SoftwareRequirementsBaseVisitor.java | 77 ++ .../parser/SoftwareRequirementsLexer.interp | 59 ++ .../parser/SoftwareRequirementsLexer.java | 164 ++++ .../parser/SoftwareRequirementsLexer.tokens | 25 + .../parser/SoftwareRequirementsListener.java | 99 +++ .../parser/SoftwareRequirementsParser.java | 703 ++++++++++++++++++ .../parser/SoftwareRequirementsVisitor.java | 66 ++ 10 files changed, 1414 insertions(+) create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirements.interp create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirements.tokens create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirementsBaseListener.java create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirementsBaseVisitor.java create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.interp create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.java create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.tokens create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirementsListener.java create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirementsParser.java create mode 100644 src/main/java/org/lumijiez/parser/SoftwareRequirementsVisitor.java diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirements.interp b/src/main/java/org/lumijiez/parser/SoftwareRequirements.interp new file mode 100644 index 0000000..8f147d9 --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirements.interp @@ -0,0 +1,48 @@ +token literal names: +null +'=>' +'&&' +'||' +'()' +null +null +null +'(' +')' +':' +';' +',' +'{' +'}' + +token symbolic names: +null +null +null +null +null +ID +STRING +WS +LPAREN +RPAREN +COLON +SEMICOLON +COMMA +LBRACE +RBRACE + +rule names: +program +requirement +predicate +expression +term +logical_op +functionSpec +parameter_list +parameter + + +atn: +[4, 1, 14, 72, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 1, 0, 1, 0, 4, 0, 21, 8, 0, 11, 0, 12, 0, 22, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 3, 5, 3, 38, 8, 3, 10, 3, 12, 3, 41, 9, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 3, 4, 48, 8, 4, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 5, 7, 63, 8, 7, 10, 7, 12, 7, 66, 9, 7, 1, 8, 1, 8, 1, 8, 1, 8, 1, 8, 0, 0, 9, 0, 2, 4, 6, 8, 10, 12, 14, 16, 0, 1, 1, 0, 2, 3, 67, 0, 20, 1, 0, 0, 0, 2, 24, 1, 0, 0, 0, 4, 29, 1, 0, 0, 0, 6, 33, 1, 0, 0, 0, 8, 47, 1, 0, 0, 0, 10, 49, 1, 0, 0, 0, 12, 51, 1, 0, 0, 0, 14, 59, 1, 0, 0, 0, 16, 67, 1, 0, 0, 0, 18, 21, 3, 2, 1, 0, 19, 21, 3, 12, 6, 0, 20, 18, 1, 0, 0, 0, 20, 19, 1, 0, 0, 0, 21, 22, 1, 0, 0, 0, 22, 20, 1, 0, 0, 0, 22, 23, 1, 0, 0, 0, 23, 1, 1, 0, 0, 0, 24, 25, 5, 5, 0, 0, 25, 26, 5, 10, 0, 0, 26, 27, 3, 4, 2, 0, 27, 28, 5, 11, 0, 0, 28, 3, 1, 0, 0, 0, 29, 30, 3, 6, 3, 0, 30, 31, 5, 1, 0, 0, 31, 32, 3, 6, 3, 0, 32, 5, 1, 0, 0, 0, 33, 39, 3, 8, 4, 0, 34, 35, 3, 10, 5, 0, 35, 36, 3, 8, 4, 0, 36, 38, 1, 0, 0, 0, 37, 34, 1, 0, 0, 0, 38, 41, 1, 0, 0, 0, 39, 37, 1, 0, 0, 0, 39, 40, 1, 0, 0, 0, 40, 7, 1, 0, 0, 0, 41, 39, 1, 0, 0, 0, 42, 43, 5, 8, 0, 0, 43, 44, 3, 6, 3, 0, 44, 45, 5, 9, 0, 0, 45, 48, 1, 0, 0, 0, 46, 48, 5, 6, 0, 0, 47, 42, 1, 0, 0, 0, 47, 46, 1, 0, 0, 0, 48, 9, 1, 0, 0, 0, 49, 50, 7, 0, 0, 0, 50, 11, 1, 0, 0, 0, 51, 52, 5, 5, 0, 0, 52, 53, 5, 4, 0, 0, 53, 54, 5, 10, 0, 0, 54, 55, 5, 8, 0, 0, 55, 56, 3, 14, 7, 0, 56, 57, 5, 9, 0, 0, 57, 58, 5, 11, 0, 0, 58, 13, 1, 0, 0, 0, 59, 64, 3, 16, 8, 0, 60, 61, 5, 12, 0, 0, 61, 63, 3, 16, 8, 0, 62, 60, 1, 0, 0, 0, 63, 66, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 15, 1, 0, 0, 0, 66, 64, 1, 0, 0, 0, 67, 68, 5, 6, 0, 0, 68, 69, 5, 10, 0, 0, 69, 70, 5, 6, 0, 0, 70, 17, 1, 0, 0, 0, 5, 20, 22, 39, 47, 64] \ No newline at end of file diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirements.tokens b/src/main/java/org/lumijiez/parser/SoftwareRequirements.tokens new file mode 100644 index 0000000..5f62f43 --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirements.tokens @@ -0,0 +1,25 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +ID=5 +STRING=6 +WS=7 +LPAREN=8 +RPAREN=9 +COLON=10 +SEMICOLON=11 +COMMA=12 +LBRACE=13 +RBRACE=14 +'=>'=1 +'&&'=2 +'||'=3 +'()'=4 +'('=8 +')'=9 +':'=10 +';'=11 +','=12 +'{'=13 +'}'=14 diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirementsBaseListener.java b/src/main/java/org/lumijiez/parser/SoftwareRequirementsBaseListener.java new file mode 100644 index 0000000..a4feec6 --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirementsBaseListener.java @@ -0,0 +1,148 @@ +// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/SoftwareRequirements.g4 by ANTLR 4.13.1 +package org.lumijiez.parser; + +import org.antlr.v4.runtime.ParserRuleContext; +import org.antlr.v4.runtime.tree.ErrorNode; +import org.antlr.v4.runtime.tree.TerminalNode; + +/** + * This class provides an empty implementation of {@link SoftwareRequirementsListener}, + * which can be extended to create a listener which only needs to handle a subset + * of the available methods. + */ +@SuppressWarnings("CheckReturnValue") +public class SoftwareRequirementsBaseListener implements SoftwareRequirementsListener { + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterProgram(SoftwareRequirementsParser.ProgramContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitProgram(SoftwareRequirementsParser.ProgramContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterRequirement(SoftwareRequirementsParser.RequirementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitRequirement(SoftwareRequirementsParser.RequirementContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterPredicate(SoftwareRequirementsParser.PredicateContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitPredicate(SoftwareRequirementsParser.PredicateContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterExpression(SoftwareRequirementsParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitExpression(SoftwareRequirementsParser.ExpressionContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterTerm(SoftwareRequirementsParser.TermContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitTerm(SoftwareRequirementsParser.TermContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterLogical_op(SoftwareRequirementsParser.Logical_opContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitLogical_op(SoftwareRequirementsParser.Logical_opContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterFunctionSpec(SoftwareRequirementsParser.FunctionSpecContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitFunctionSpec(SoftwareRequirementsParser.FunctionSpecContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParameter_list(SoftwareRequirementsParser.Parameter_listContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParameter_list(SoftwareRequirementsParser.Parameter_listContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterParameter(SoftwareRequirementsParser.ParameterContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitParameter(SoftwareRequirementsParser.ParameterContext ctx) { } + + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void enterEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void exitEveryRule(ParserRuleContext ctx) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitTerminal(TerminalNode node) { } + /** + * {@inheritDoc} + * + *

The default implementation does nothing.

+ */ + @Override public void visitErrorNode(ErrorNode node) { } +} \ No newline at end of file diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirementsBaseVisitor.java b/src/main/java/org/lumijiez/parser/SoftwareRequirementsBaseVisitor.java new file mode 100644 index 0000000..3cf557a --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirementsBaseVisitor.java @@ -0,0 +1,77 @@ +package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/SoftwareRequirements.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor; + +/** + * This class provides an empty implementation of {@link SoftwareRequirementsVisitor}, + * which can be extended to create a visitor which only needs to handle a subset + * of the available methods. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +@SuppressWarnings("CheckReturnValue") +public class SoftwareRequirementsBaseVisitor extends AbstractParseTreeVisitor implements SoftwareRequirementsVisitor { + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitProgram(SoftwareRequirementsParser.ProgramContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitRequirement(SoftwareRequirementsParser.RequirementContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitPredicate(SoftwareRequirementsParser.PredicateContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitExpression(SoftwareRequirementsParser.ExpressionContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitTerm(SoftwareRequirementsParser.TermContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitLogical_op(SoftwareRequirementsParser.Logical_opContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitFunctionSpec(SoftwareRequirementsParser.FunctionSpecContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParameter_list(SoftwareRequirementsParser.Parameter_listContext ctx) { return visitChildren(ctx); } + /** + * {@inheritDoc} + * + *

The default implementation returns the result of calling + * {@link #visitChildren} on {@code ctx}.

+ */ + @Override public T visitParameter(SoftwareRequirementsParser.ParameterContext ctx) { return visitChildren(ctx); } +} \ No newline at end of file diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.interp b/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.interp new file mode 100644 index 0000000..215c4f6 --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.interp @@ -0,0 +1,59 @@ +token literal names: +null +'=>' +'&&' +'||' +'()' +null +null +null +'(' +')' +':' +';' +',' +'{' +'}' + +token symbolic names: +null +null +null +null +null +ID +STRING +WS +LPAREN +RPAREN +COLON +SEMICOLON +COMMA +LBRACE +RBRACE + +rule names: +T__0 +T__1 +T__2 +T__3 +ID +STRING +WS +LPAREN +RPAREN +COLON +SEMICOLON +COMMA +LBRACE +RBRACE + +channel names: +DEFAULT_TOKEN_CHANNEL +HIDDEN + +mode names: +DEFAULT_MODE + +atn: +[4, 0, 14, 76, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 2, 1, 2, 1, 2, 1, 3, 1, 3, 1, 3, 1, 4, 4, 4, 43, 8, 4, 11, 4, 12, 4, 44, 1, 5, 1, 5, 5, 5, 49, 8, 5, 10, 5, 12, 5, 52, 9, 5, 1, 5, 1, 5, 1, 6, 4, 6, 57, 8, 6, 11, 6, 12, 6, 58, 1, 6, 1, 6, 1, 7, 1, 7, 1, 8, 1, 8, 1, 9, 1, 9, 1, 10, 1, 10, 1, 11, 1, 11, 1, 12, 1, 12, 1, 13, 1, 13, 0, 0, 14, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 1, 0, 3, 2, 0, 65, 90, 97, 122, 1, 0, 34, 34, 3, 0, 9, 10, 13, 13, 32, 32, 78, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 1, 29, 1, 0, 0, 0, 3, 32, 1, 0, 0, 0, 5, 35, 1, 0, 0, 0, 7, 38, 1, 0, 0, 0, 9, 42, 1, 0, 0, 0, 11, 46, 1, 0, 0, 0, 13, 56, 1, 0, 0, 0, 15, 62, 1, 0, 0, 0, 17, 64, 1, 0, 0, 0, 19, 66, 1, 0, 0, 0, 21, 68, 1, 0, 0, 0, 23, 70, 1, 0, 0, 0, 25, 72, 1, 0, 0, 0, 27, 74, 1, 0, 0, 0, 29, 30, 5, 61, 0, 0, 30, 31, 5, 62, 0, 0, 31, 2, 1, 0, 0, 0, 32, 33, 5, 38, 0, 0, 33, 34, 5, 38, 0, 0, 34, 4, 1, 0, 0, 0, 35, 36, 5, 124, 0, 0, 36, 37, 5, 124, 0, 0, 37, 6, 1, 0, 0, 0, 38, 39, 5, 40, 0, 0, 39, 40, 5, 41, 0, 0, 40, 8, 1, 0, 0, 0, 41, 43, 7, 0, 0, 0, 42, 41, 1, 0, 0, 0, 43, 44, 1, 0, 0, 0, 44, 42, 1, 0, 0, 0, 44, 45, 1, 0, 0, 0, 45, 10, 1, 0, 0, 0, 46, 50, 5, 34, 0, 0, 47, 49, 8, 1, 0, 0, 48, 47, 1, 0, 0, 0, 49, 52, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 53, 1, 0, 0, 0, 52, 50, 1, 0, 0, 0, 53, 54, 5, 34, 0, 0, 54, 12, 1, 0, 0, 0, 55, 57, 7, 2, 0, 0, 56, 55, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 58, 59, 1, 0, 0, 0, 59, 60, 1, 0, 0, 0, 60, 61, 6, 6, 0, 0, 61, 14, 1, 0, 0, 0, 62, 63, 5, 40, 0, 0, 63, 16, 1, 0, 0, 0, 64, 65, 5, 41, 0, 0, 65, 18, 1, 0, 0, 0, 66, 67, 5, 58, 0, 0, 67, 20, 1, 0, 0, 0, 68, 69, 5, 59, 0, 0, 69, 22, 1, 0, 0, 0, 70, 71, 5, 44, 0, 0, 71, 24, 1, 0, 0, 0, 72, 73, 5, 123, 0, 0, 73, 26, 1, 0, 0, 0, 74, 75, 5, 125, 0, 0, 75, 28, 1, 0, 0, 0, 4, 0, 44, 50, 58, 1, 6, 0, 0] \ No newline at end of file diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.java b/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.java new file mode 100644 index 0000000..fda4ddc --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.java @@ -0,0 +1,164 @@ +package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/SoftwareRequirements.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.Lexer; +import org.antlr.v4.runtime.CharStream; +import org.antlr.v4.runtime.Token; +import org.antlr.v4.runtime.TokenStream; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.misc.*; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"}) +public class SoftwareRequirementsLexer extends Lexer { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, ID=5, STRING=6, WS=7, LPAREN=8, RPAREN=9, + COLON=10, SEMICOLON=11, COMMA=12, LBRACE=13, RBRACE=14; + public static String[] channelNames = { + "DEFAULT_TOKEN_CHANNEL", "HIDDEN" + }; + + public static String[] modeNames = { + "DEFAULT_MODE" + }; + + private static String[] makeRuleNames() { + return new String[] { + "T__0", "T__1", "T__2", "T__3", "ID", "STRING", "WS", "LPAREN", "RPAREN", + "COLON", "SEMICOLON", "COMMA", "LBRACE", "RBRACE" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'=>'", "'&&'", "'||'", "'()'", null, null, null, "'('", "')'", + "':'", "';'", "','", "'{'", "'}'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, "ID", "STRING", "WS", "LPAREN", "RPAREN", + "COLON", "SEMICOLON", "COMMA", "LBRACE", "RBRACE" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + + public SoftwareRequirementsLexer(CharStream input) { + super(input); + _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @Override + public String getGrammarFileName() { return "SoftwareRequirements.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public String[] getChannelNames() { return channelNames; } + + @Override + public String[] getModeNames() { return modeNames; } + + @Override + public ATN getATN() { return _ATN; } + + public static final String _serializedATN = + "\u0004\u0000\u000eL\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+ + "\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+ + "\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+ + "\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+ + "\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0001\u0000\u0001\u0000\u0001"+ + "\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001"+ + "\u0002\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004\u0004\u0004+\b"+ + "\u0004\u000b\u0004\f\u0004,\u0001\u0005\u0001\u0005\u0005\u00051\b\u0005"+ + "\n\u0005\f\u00054\t\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0004\u0006"+ + "9\b\u0006\u000b\u0006\f\u0006:\u0001\u0006\u0001\u0006\u0001\u0007\u0001"+ + "\u0007\u0001\b\u0001\b\u0001\t\u0001\t\u0001\n\u0001\n\u0001\u000b\u0001"+ + "\u000b\u0001\f\u0001\f\u0001\r\u0001\r\u0000\u0000\u000e\u0001\u0001\u0003"+ + "\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f\b\u0011"+ + "\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u0001\u0000\u0003\u0002"+ + "\u0000AZaz\u0001\u0000\"\"\u0003\u0000\t\n\r\r N\u0000\u0001\u0001\u0000"+ + "\u0000\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000"+ + "\u0000\u0000\u0000\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000"+ + "\u0000\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000"+ + "\u0000\u000f\u0001\u0000\u0000\u0000\u0000\u0011\u0001\u0000\u0000\u0000"+ + "\u0000\u0013\u0001\u0000\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000"+ + "\u0000\u0017\u0001\u0000\u0000\u0000\u0000\u0019\u0001\u0000\u0000\u0000"+ + "\u0000\u001b\u0001\u0000\u0000\u0000\u0001\u001d\u0001\u0000\u0000\u0000"+ + "\u0003 \u0001\u0000\u0000\u0000\u0005#\u0001\u0000\u0000\u0000\u0007&"+ + "\u0001\u0000\u0000\u0000\t*\u0001\u0000\u0000\u0000\u000b.\u0001\u0000"+ + "\u0000\u0000\r8\u0001\u0000\u0000\u0000\u000f>\u0001\u0000\u0000\u0000"+ + "\u0011@\u0001\u0000\u0000\u0000\u0013B\u0001\u0000\u0000\u0000\u0015D"+ + "\u0001\u0000\u0000\u0000\u0017F\u0001\u0000\u0000\u0000\u0019H\u0001\u0000"+ + "\u0000\u0000\u001bJ\u0001\u0000\u0000\u0000\u001d\u001e\u0005=\u0000\u0000"+ + "\u001e\u001f\u0005>\u0000\u0000\u001f\u0002\u0001\u0000\u0000\u0000 !"+ + "\u0005&\u0000\u0000!\"\u0005&\u0000\u0000\"\u0004\u0001\u0000\u0000\u0000"+ + "#$\u0005|\u0000\u0000$%\u0005|\u0000\u0000%\u0006\u0001\u0000\u0000\u0000"+ + "&\'\u0005(\u0000\u0000\'(\u0005)\u0000\u0000(\b\u0001\u0000\u0000\u0000"+ + ")+\u0007\u0000\u0000\u0000*)\u0001\u0000\u0000\u0000+,\u0001\u0000\u0000"+ + "\u0000,*\u0001\u0000\u0000\u0000,-\u0001\u0000\u0000\u0000-\n\u0001\u0000"+ + "\u0000\u0000.2\u0005\"\u0000\u0000/1\b\u0001\u0000\u00000/\u0001\u0000"+ + "\u0000\u000014\u0001\u0000\u0000\u000020\u0001\u0000\u0000\u000023\u0001"+ + "\u0000\u0000\u000035\u0001\u0000\u0000\u000042\u0001\u0000\u0000\u0000"+ + "56\u0005\"\u0000\u00006\f\u0001\u0000\u0000\u000079\u0007\u0002\u0000"+ + "\u000087\u0001\u0000\u0000\u00009:\u0001\u0000\u0000\u0000:8\u0001\u0000"+ + "\u0000\u0000:;\u0001\u0000\u0000\u0000;<\u0001\u0000\u0000\u0000<=\u0006"+ + "\u0006\u0000\u0000=\u000e\u0001\u0000\u0000\u0000>?\u0005(\u0000\u0000"+ + "?\u0010\u0001\u0000\u0000\u0000@A\u0005)\u0000\u0000A\u0012\u0001\u0000"+ + "\u0000\u0000BC\u0005:\u0000\u0000C\u0014\u0001\u0000\u0000\u0000DE\u0005"+ + ";\u0000\u0000E\u0016\u0001\u0000\u0000\u0000FG\u0005,\u0000\u0000G\u0018"+ + "\u0001\u0000\u0000\u0000HI\u0005{\u0000\u0000I\u001a\u0001\u0000\u0000"+ + "\u0000JK\u0005}\u0000\u0000K\u001c\u0001\u0000\u0000\u0000\u0004\u0000"+ + ",2:\u0001\u0006\u0000\u0000"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.tokens b/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.tokens new file mode 100644 index 0000000..5f62f43 --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirementsLexer.tokens @@ -0,0 +1,25 @@ +T__0=1 +T__1=2 +T__2=3 +T__3=4 +ID=5 +STRING=6 +WS=7 +LPAREN=8 +RPAREN=9 +COLON=10 +SEMICOLON=11 +COMMA=12 +LBRACE=13 +RBRACE=14 +'=>'=1 +'&&'=2 +'||'=3 +'()'=4 +'('=8 +')'=9 +':'=10 +';'=11 +','=12 +'{'=13 +'}'=14 diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirementsListener.java b/src/main/java/org/lumijiez/parser/SoftwareRequirementsListener.java new file mode 100644 index 0000000..89c7218 --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirementsListener.java @@ -0,0 +1,99 @@ +package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/SoftwareRequirements.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.tree.ParseTreeListener; + +/** + * This interface defines a complete listener for a parse tree produced by + * {@link SoftwareRequirementsParser}. + */ +public interface SoftwareRequirementsListener extends ParseTreeListener { + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#program}. + * @param ctx the parse tree + */ + void enterProgram(SoftwareRequirementsParser.ProgramContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#program}. + * @param ctx the parse tree + */ + void exitProgram(SoftwareRequirementsParser.ProgramContext ctx); + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#requirement}. + * @param ctx the parse tree + */ + void enterRequirement(SoftwareRequirementsParser.RequirementContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#requirement}. + * @param ctx the parse tree + */ + void exitRequirement(SoftwareRequirementsParser.RequirementContext ctx); + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#predicate}. + * @param ctx the parse tree + */ + void enterPredicate(SoftwareRequirementsParser.PredicateContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#predicate}. + * @param ctx the parse tree + */ + void exitPredicate(SoftwareRequirementsParser.PredicateContext ctx); + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#expression}. + * @param ctx the parse tree + */ + void enterExpression(SoftwareRequirementsParser.ExpressionContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#expression}. + * @param ctx the parse tree + */ + void exitExpression(SoftwareRequirementsParser.ExpressionContext ctx); + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#term}. + * @param ctx the parse tree + */ + void enterTerm(SoftwareRequirementsParser.TermContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#term}. + * @param ctx the parse tree + */ + void exitTerm(SoftwareRequirementsParser.TermContext ctx); + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#logical_op}. + * @param ctx the parse tree + */ + void enterLogical_op(SoftwareRequirementsParser.Logical_opContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#logical_op}. + * @param ctx the parse tree + */ + void exitLogical_op(SoftwareRequirementsParser.Logical_opContext ctx); + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#functionSpec}. + * @param ctx the parse tree + */ + void enterFunctionSpec(SoftwareRequirementsParser.FunctionSpecContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#functionSpec}. + * @param ctx the parse tree + */ + void exitFunctionSpec(SoftwareRequirementsParser.FunctionSpecContext ctx); + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#parameter_list}. + * @param ctx the parse tree + */ + void enterParameter_list(SoftwareRequirementsParser.Parameter_listContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#parameter_list}. + * @param ctx the parse tree + */ + void exitParameter_list(SoftwareRequirementsParser.Parameter_listContext ctx); + /** + * Enter a parse tree produced by {@link SoftwareRequirementsParser#parameter}. + * @param ctx the parse tree + */ + void enterParameter(SoftwareRequirementsParser.ParameterContext ctx); + /** + * Exit a parse tree produced by {@link SoftwareRequirementsParser#parameter}. + * @param ctx the parse tree + */ + void exitParameter(SoftwareRequirementsParser.ParameterContext ctx); +} \ No newline at end of file diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirementsParser.java b/src/main/java/org/lumijiez/parser/SoftwareRequirementsParser.java new file mode 100644 index 0000000..26628b3 --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirementsParser.java @@ -0,0 +1,703 @@ +package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/SoftwareRequirements.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.atn.*; +import org.antlr.v4.runtime.dfa.DFA; +import org.antlr.v4.runtime.*; +import org.antlr.v4.runtime.misc.*; +import org.antlr.v4.runtime.tree.*; +import java.util.List; +import java.util.Iterator; +import java.util.ArrayList; + +@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"}) +public class SoftwareRequirementsParser extends Parser { + static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); } + + protected static final DFA[] _decisionToDFA; + protected static final PredictionContextCache _sharedContextCache = + new PredictionContextCache(); + public static final int + T__0=1, T__1=2, T__2=3, T__3=4, ID=5, STRING=6, WS=7, LPAREN=8, RPAREN=9, + COLON=10, SEMICOLON=11, COMMA=12, LBRACE=13, RBRACE=14; + public static final int + RULE_program = 0, RULE_requirement = 1, RULE_predicate = 2, RULE_expression = 3, + RULE_term = 4, RULE_logical_op = 5, RULE_functionSpec = 6, RULE_parameter_list = 7, + RULE_parameter = 8; + private static String[] makeRuleNames() { + return new String[] { + "program", "requirement", "predicate", "expression", "term", "logical_op", + "functionSpec", "parameter_list", "parameter" + }; + } + public static final String[] ruleNames = makeRuleNames(); + + private static String[] makeLiteralNames() { + return new String[] { + null, "'=>'", "'&&'", "'||'", "'()'", null, null, null, "'('", "')'", + "':'", "';'", "','", "'{'", "'}'" + }; + } + private static final String[] _LITERAL_NAMES = makeLiteralNames(); + private static String[] makeSymbolicNames() { + return new String[] { + null, null, null, null, null, "ID", "STRING", "WS", "LPAREN", "RPAREN", + "COLON", "SEMICOLON", "COMMA", "LBRACE", "RBRACE" + }; + } + private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames(); + public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES); + + /** + * @deprecated Use {@link #VOCABULARY} instead. + */ + @Deprecated + public static final String[] tokenNames; + static { + tokenNames = new String[_SYMBOLIC_NAMES.length]; + for (int i = 0; i < tokenNames.length; i++) { + tokenNames[i] = VOCABULARY.getLiteralName(i); + if (tokenNames[i] == null) { + tokenNames[i] = VOCABULARY.getSymbolicName(i); + } + + if (tokenNames[i] == null) { + tokenNames[i] = ""; + } + } + } + + @Override + @Deprecated + public String[] getTokenNames() { + return tokenNames; + } + + @Override + + public Vocabulary getVocabulary() { + return VOCABULARY; + } + + @Override + public String getGrammarFileName() { return "SoftwareRequirements.g4"; } + + @Override + public String[] getRuleNames() { return ruleNames; } + + @Override + public String getSerializedATN() { return _serializedATN; } + + @Override + public ATN getATN() { return _ATN; } + + public SoftwareRequirementsParser(TokenStream input) { + super(input); + _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache); + } + + @SuppressWarnings("CheckReturnValue") + public static class ProgramContext extends ParserRuleContext { + public List requirement() { + return getRuleContexts(RequirementContext.class); + } + public RequirementContext requirement(int i) { + return getRuleContext(RequirementContext.class,i); + } + public List functionSpec() { + return getRuleContexts(FunctionSpecContext.class); + } + public FunctionSpecContext functionSpec(int i) { + return getRuleContext(FunctionSpecContext.class,i); + } + public ProgramContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_program; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterProgram(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitProgram(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitProgram(this); + else return visitor.visitChildren(this); + } + } + + public final ProgramContext program() throws RecognitionException { + ProgramContext _localctx = new ProgramContext(_ctx, getState()); + enterRule(_localctx, 0, RULE_program); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(20); + _errHandler.sync(this); + _la = _input.LA(1); + do { + { + setState(20); + _errHandler.sync(this); + switch ( getInterpreter().adaptivePredict(_input,0,_ctx) ) { + case 1: + { + setState(18); + requirement(); + } + break; + case 2: + { + setState(19); + functionSpec(); + } + break; + } + } + setState(22); + _errHandler.sync(this); + _la = _input.LA(1); + } while ( _la==ID ); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class RequirementContext extends ParserRuleContext { + public TerminalNode ID() { return getToken(SoftwareRequirementsParser.ID, 0); } + public TerminalNode COLON() { return getToken(SoftwareRequirementsParser.COLON, 0); } + public PredicateContext predicate() { + return getRuleContext(PredicateContext.class,0); + } + public TerminalNode SEMICOLON() { return getToken(SoftwareRequirementsParser.SEMICOLON, 0); } + public RequirementContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_requirement; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterRequirement(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitRequirement(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitRequirement(this); + else return visitor.visitChildren(this); + } + } + + public final RequirementContext requirement() throws RecognitionException { + RequirementContext _localctx = new RequirementContext(_ctx, getState()); + enterRule(_localctx, 2, RULE_requirement); + try { + enterOuterAlt(_localctx, 1); + { + setState(24); + match(ID); + setState(25); + match(COLON); + setState(26); + predicate(); + setState(27); + match(SEMICOLON); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class PredicateContext extends ParserRuleContext { + public List expression() { + return getRuleContexts(ExpressionContext.class); + } + public ExpressionContext expression(int i) { + return getRuleContext(ExpressionContext.class,i); + } + public PredicateContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_predicate; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterPredicate(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitPredicate(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitPredicate(this); + else return visitor.visitChildren(this); + } + } + + public final PredicateContext predicate() throws RecognitionException { + PredicateContext _localctx = new PredicateContext(_ctx, getState()); + enterRule(_localctx, 4, RULE_predicate); + try { + enterOuterAlt(_localctx, 1); + { + setState(29); + expression(); + setState(30); + match(T__0); + setState(31); + expression(); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ExpressionContext extends ParserRuleContext { + public List term() { + return getRuleContexts(TermContext.class); + } + public TermContext term(int i) { + return getRuleContext(TermContext.class,i); + } + public List logical_op() { + return getRuleContexts(Logical_opContext.class); + } + public Logical_opContext logical_op(int i) { + return getRuleContext(Logical_opContext.class,i); + } + public ExpressionContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_expression; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterExpression(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitExpression(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitExpression(this); + else return visitor.visitChildren(this); + } + } + + public final ExpressionContext expression() throws RecognitionException { + ExpressionContext _localctx = new ExpressionContext(_ctx, getState()); + enterRule(_localctx, 6, RULE_expression); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(33); + term(); + setState(39); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==T__1 || _la==T__2) { + { + { + setState(34); + logical_op(); + setState(35); + term(); + } + } + setState(41); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class TermContext extends ParserRuleContext { + public TerminalNode LPAREN() { return getToken(SoftwareRequirementsParser.LPAREN, 0); } + public ExpressionContext expression() { + return getRuleContext(ExpressionContext.class,0); + } + public TerminalNode RPAREN() { return getToken(SoftwareRequirementsParser.RPAREN, 0); } + public TerminalNode STRING() { return getToken(SoftwareRequirementsParser.STRING, 0); } + public TermContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_term; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterTerm(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitTerm(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitTerm(this); + else return visitor.visitChildren(this); + } + } + + public final TermContext term() throws RecognitionException { + TermContext _localctx = new TermContext(_ctx, getState()); + enterRule(_localctx, 8, RULE_term); + try { + setState(47); + _errHandler.sync(this); + switch (_input.LA(1)) { + case LPAREN: + enterOuterAlt(_localctx, 1); + { + setState(42); + match(LPAREN); + setState(43); + expression(); + setState(44); + match(RPAREN); + } + break; + case STRING: + enterOuterAlt(_localctx, 2); + { + setState(46); + match(STRING); + } + break; + default: + throw new NoViableAltException(this); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Logical_opContext extends ParserRuleContext { + public Logical_opContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_logical_op; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterLogical_op(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitLogical_op(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitLogical_op(this); + else return visitor.visitChildren(this); + } + } + + public final Logical_opContext logical_op() throws RecognitionException { + Logical_opContext _localctx = new Logical_opContext(_ctx, getState()); + enterRule(_localctx, 10, RULE_logical_op); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(49); + _la = _input.LA(1); + if ( !(_la==T__1 || _la==T__2) ) { + _errHandler.recoverInline(this); + } + else { + if ( _input.LA(1)==Token.EOF ) matchedEOF = true; + _errHandler.reportMatch(this); + consume(); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class FunctionSpecContext extends ParserRuleContext { + public TerminalNode ID() { return getToken(SoftwareRequirementsParser.ID, 0); } + public TerminalNode COLON() { return getToken(SoftwareRequirementsParser.COLON, 0); } + public TerminalNode LPAREN() { return getToken(SoftwareRequirementsParser.LPAREN, 0); } + public Parameter_listContext parameter_list() { + return getRuleContext(Parameter_listContext.class,0); + } + public TerminalNode RPAREN() { return getToken(SoftwareRequirementsParser.RPAREN, 0); } + public TerminalNode SEMICOLON() { return getToken(SoftwareRequirementsParser.SEMICOLON, 0); } + public FunctionSpecContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_functionSpec; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterFunctionSpec(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitFunctionSpec(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitFunctionSpec(this); + else return visitor.visitChildren(this); + } + } + + public final FunctionSpecContext functionSpec() throws RecognitionException { + FunctionSpecContext _localctx = new FunctionSpecContext(_ctx, getState()); + enterRule(_localctx, 12, RULE_functionSpec); + try { + enterOuterAlt(_localctx, 1); + { + setState(51); + match(ID); + setState(52); + match(T__3); + setState(53); + match(COLON); + setState(54); + match(LPAREN); + setState(55); + parameter_list(); + setState(56); + match(RPAREN); + setState(57); + match(SEMICOLON); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class Parameter_listContext extends ParserRuleContext { + public List parameter() { + return getRuleContexts(ParameterContext.class); + } + public ParameterContext parameter(int i) { + return getRuleContext(ParameterContext.class,i); + } + public List COMMA() { return getTokens(SoftwareRequirementsParser.COMMA); } + public TerminalNode COMMA(int i) { + return getToken(SoftwareRequirementsParser.COMMA, i); + } + public Parameter_listContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_parameter_list; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterParameter_list(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitParameter_list(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitParameter_list(this); + else return visitor.visitChildren(this); + } + } + + public final Parameter_listContext parameter_list() throws RecognitionException { + Parameter_listContext _localctx = new Parameter_listContext(_ctx, getState()); + enterRule(_localctx, 14, RULE_parameter_list); + int _la; + try { + enterOuterAlt(_localctx, 1); + { + setState(59); + parameter(); + setState(64); + _errHandler.sync(this); + _la = _input.LA(1); + while (_la==COMMA) { + { + { + setState(60); + match(COMMA); + setState(61); + parameter(); + } + } + setState(66); + _errHandler.sync(this); + _la = _input.LA(1); + } + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + @SuppressWarnings("CheckReturnValue") + public static class ParameterContext extends ParserRuleContext { + public List STRING() { return getTokens(SoftwareRequirementsParser.STRING); } + public TerminalNode STRING(int i) { + return getToken(SoftwareRequirementsParser.STRING, i); + } + public TerminalNode COLON() { return getToken(SoftwareRequirementsParser.COLON, 0); } + public ParameterContext(ParserRuleContext parent, int invokingState) { + super(parent, invokingState); + } + @Override public int getRuleIndex() { return RULE_parameter; } + @Override + public void enterRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).enterParameter(this); + } + @Override + public void exitRule(ParseTreeListener listener) { + if ( listener instanceof SoftwareRequirementsListener ) ((SoftwareRequirementsListener)listener).exitParameter(this); + } + @Override + public T accept(ParseTreeVisitor visitor) { + if ( visitor instanceof SoftwareRequirementsVisitor ) return ((SoftwareRequirementsVisitor)visitor).visitParameter(this); + else return visitor.visitChildren(this); + } + } + + public final ParameterContext parameter() throws RecognitionException { + ParameterContext _localctx = new ParameterContext(_ctx, getState()); + enterRule(_localctx, 16, RULE_parameter); + try { + enterOuterAlt(_localctx, 1); + { + setState(67); + match(STRING); + setState(68); + match(COLON); + setState(69); + match(STRING); + } + } + catch (RecognitionException re) { + _localctx.exception = re; + _errHandler.reportError(this, re); + _errHandler.recover(this, re); + } + finally { + exitRule(); + } + return _localctx; + } + + public static final String _serializedATN = + "\u0004\u0001\u000eH\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+ + "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0002"+ + "\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007\u0007\u0007\u0002"+ + "\b\u0007\b\u0001\u0000\u0001\u0000\u0004\u0000\u0015\b\u0000\u000b\u0000"+ + "\f\u0000\u0016\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+ + "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003"+ + "\u0001\u0003\u0001\u0003\u0005\u0003&\b\u0003\n\u0003\f\u0003)\t\u0003"+ + "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0003\u0004"+ + "0\b\u0004\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+ + "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0007"+ + "\u0001\u0007\u0001\u0007\u0005\u0007?\b\u0007\n\u0007\f\u0007B\t\u0007"+ + "\u0001\b\u0001\b\u0001\b\u0001\b\u0001\b\u0000\u0000\t\u0000\u0002\u0004"+ + "\u0006\b\n\f\u000e\u0010\u0000\u0001\u0001\u0000\u0002\u0003C\u0000\u0014"+ + "\u0001\u0000\u0000\u0000\u0002\u0018\u0001\u0000\u0000\u0000\u0004\u001d"+ + "\u0001\u0000\u0000\u0000\u0006!\u0001\u0000\u0000\u0000\b/\u0001\u0000"+ + "\u0000\u0000\n1\u0001\u0000\u0000\u0000\f3\u0001\u0000\u0000\u0000\u000e"+ + ";\u0001\u0000\u0000\u0000\u0010C\u0001\u0000\u0000\u0000\u0012\u0015\u0003"+ + "\u0002\u0001\u0000\u0013\u0015\u0003\f\u0006\u0000\u0014\u0012\u0001\u0000"+ + "\u0000\u0000\u0014\u0013\u0001\u0000\u0000\u0000\u0015\u0016\u0001\u0000"+ + "\u0000\u0000\u0016\u0014\u0001\u0000\u0000\u0000\u0016\u0017\u0001\u0000"+ + "\u0000\u0000\u0017\u0001\u0001\u0000\u0000\u0000\u0018\u0019\u0005\u0005"+ + "\u0000\u0000\u0019\u001a\u0005\n\u0000\u0000\u001a\u001b\u0003\u0004\u0002"+ + "\u0000\u001b\u001c\u0005\u000b\u0000\u0000\u001c\u0003\u0001\u0000\u0000"+ + "\u0000\u001d\u001e\u0003\u0006\u0003\u0000\u001e\u001f\u0005\u0001\u0000"+ + "\u0000\u001f \u0003\u0006\u0003\u0000 \u0005\u0001\u0000\u0000\u0000!"+ + "\'\u0003\b\u0004\u0000\"#\u0003\n\u0005\u0000#$\u0003\b\u0004\u0000$&"+ + "\u0001\u0000\u0000\u0000%\"\u0001\u0000\u0000\u0000&)\u0001\u0000\u0000"+ + "\u0000\'%\u0001\u0000\u0000\u0000\'(\u0001\u0000\u0000\u0000(\u0007\u0001"+ + "\u0000\u0000\u0000)\'\u0001\u0000\u0000\u0000*+\u0005\b\u0000\u0000+,"+ + "\u0003\u0006\u0003\u0000,-\u0005\t\u0000\u0000-0\u0001\u0000\u0000\u0000"+ + ".0\u0005\u0006\u0000\u0000/*\u0001\u0000\u0000\u0000/.\u0001\u0000\u0000"+ + "\u00000\t\u0001\u0000\u0000\u000012\u0007\u0000\u0000\u00002\u000b\u0001"+ + "\u0000\u0000\u000034\u0005\u0005\u0000\u000045\u0005\u0004\u0000\u0000"+ + "56\u0005\n\u0000\u000067\u0005\b\u0000\u000078\u0003\u000e\u0007\u0000"+ + "89\u0005\t\u0000\u00009:\u0005\u000b\u0000\u0000:\r\u0001\u0000\u0000"+ + "\u0000;@\u0003\u0010\b\u0000<=\u0005\f\u0000\u0000=?\u0003\u0010\b\u0000"+ + "><\u0001\u0000\u0000\u0000?B\u0001\u0000\u0000\u0000@>\u0001\u0000\u0000"+ + "\u0000@A\u0001\u0000\u0000\u0000A\u000f\u0001\u0000\u0000\u0000B@\u0001"+ + "\u0000\u0000\u0000CD\u0005\u0006\u0000\u0000DE\u0005\n\u0000\u0000EF\u0005"+ + "\u0006\u0000\u0000F\u0011\u0001\u0000\u0000\u0000\u0005\u0014\u0016\'"+ + "/@"; + public static final ATN _ATN = + new ATNDeserializer().deserialize(_serializedATN.toCharArray()); + static { + _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()]; + for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) { + _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i); + } + } +} \ No newline at end of file diff --git a/src/main/java/org/lumijiez/parser/SoftwareRequirementsVisitor.java b/src/main/java/org/lumijiez/parser/SoftwareRequirementsVisitor.java new file mode 100644 index 0000000..d547400 --- /dev/null +++ b/src/main/java/org/lumijiez/parser/SoftwareRequirementsVisitor.java @@ -0,0 +1,66 @@ +package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/SoftwareRequirements.g4 by ANTLR 4.13.1 +import org.antlr.v4.runtime.tree.ParseTreeVisitor; + +/** + * This interface defines a complete generic visitor for a parse tree produced + * by {@link SoftwareRequirementsParser}. + * + * @param The return type of the visit operation. Use {@link Void} for + * operations with no return type. + */ +public interface SoftwareRequirementsVisitor extends ParseTreeVisitor { + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#program}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitProgram(SoftwareRequirementsParser.ProgramContext ctx); + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#requirement}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitRequirement(SoftwareRequirementsParser.RequirementContext ctx); + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#predicate}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitPredicate(SoftwareRequirementsParser.PredicateContext ctx); + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#expression}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitExpression(SoftwareRequirementsParser.ExpressionContext ctx); + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#term}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitTerm(SoftwareRequirementsParser.TermContext ctx); + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#logical_op}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitLogical_op(SoftwareRequirementsParser.Logical_opContext ctx); + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#functionSpec}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitFunctionSpec(SoftwareRequirementsParser.FunctionSpecContext ctx); + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#parameter_list}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameter_list(SoftwareRequirementsParser.Parameter_listContext ctx); + /** + * Visit a parse tree produced by {@link SoftwareRequirementsParser#parameter}. + * @param ctx the parse tree + * @return the visitor result + */ + T visitParameter(SoftwareRequirementsParser.ParameterContext ctx); +} \ No newline at end of file