Working grammar + Compiled Parser
This commit is contained in:
@@ -1,3 +0,0 @@
|
|||||||
grammar HelloWorld;
|
|
||||||
|
|
||||||
start: 'Hello, World!' EOF;
|
|
||||||
36
src/grammars/SoftwareRequirements.g4
Normal file
36
src/grammars/SoftwareRequirements.g4
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
grammar SoftwareRequirements;
|
||||||
|
|
||||||
|
// Lexer rules
|
||||||
|
ID : [a-zA-Z]+ ;
|
||||||
|
STRING : '"' ~'"'* '"' ;
|
||||||
|
WS : [ \t\r\n]+ -> skip ;
|
||||||
|
|
||||||
|
// Parser rules
|
||||||
|
program : (requirement | functionSpec)+ ;
|
||||||
|
|
||||||
|
requirement : ID ':' predicate ';' ;
|
||||||
|
|
||||||
|
predicate : expression '=>' expression ;
|
||||||
|
|
||||||
|
expression : term (logical_op term)* ;
|
||||||
|
|
||||||
|
term : '(' expression ')'
|
||||||
|
| STRING
|
||||||
|
;
|
||||||
|
|
||||||
|
logical_op : '&&' | '||' ;
|
||||||
|
|
||||||
|
functionSpec : ID'()' ':' '(' parameter_list ')' ';' ;
|
||||||
|
|
||||||
|
parameter_list : parameter (',' parameter)* ;
|
||||||
|
|
||||||
|
parameter : STRING ':' STRING ;
|
||||||
|
|
||||||
|
// Define symbols
|
||||||
|
LPAREN : '(' ;
|
||||||
|
RPAREN : ')' ;
|
||||||
|
COLON : ':' ;
|
||||||
|
SEMICOLON : ';' ;
|
||||||
|
COMMA : ',' ;
|
||||||
|
LBRACE : '{' ;
|
||||||
|
RBRACE : '}' ;
|
||||||
@@ -4,26 +4,32 @@ import org.antlr.v4.runtime.CharStream;
|
|||||||
import org.antlr.v4.runtime.CharStreams;
|
import org.antlr.v4.runtime.CharStreams;
|
||||||
import org.antlr.v4.runtime.CommonTokenStream;
|
import org.antlr.v4.runtime.CommonTokenStream;
|
||||||
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
import org.antlr.v4.runtime.tree.ParseTreeWalker;
|
||||||
import org.lumijiez.parser.HelloWorldBaseListener;
|
import org.lumijiez.parser.SoftwareRequirementsBaseListener;
|
||||||
import org.lumijiez.parser.HelloWorldLexer;
|
import org.lumijiez.parser.SoftwareRequirementsLexer;
|
||||||
import org.lumijiez.parser.HelloWorldParser;
|
import org.lumijiez.parser.SoftwareRequirementsParser;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.file.Files;
|
||||||
|
import java.nio.file.Path;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
public class Main {
|
public class Main {
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) throws IOException, URISyntaxException {
|
||||||
String input = "Hello, World!";
|
String input = new String(Files.readAllBytes(Path.of(Objects.requireNonNull(Main.class.getResource("/TestProgram.txt")).toURI())));
|
||||||
|
|
||||||
CharStream inputStream = CharStreams.fromString(input);
|
CharStream inputStream = CharStreams.fromString(input);
|
||||||
HelloWorldLexer lexer = new HelloWorldLexer(inputStream);
|
SoftwareRequirementsLexer lexer = new SoftwareRequirementsLexer(inputStream);
|
||||||
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
CommonTokenStream tokenStream = new CommonTokenStream(lexer);
|
||||||
HelloWorldParser parser = new HelloWorldParser(tokenStream);
|
SoftwareRequirementsParser parser = new SoftwareRequirementsParser(tokenStream);
|
||||||
|
|
||||||
ParseTreeWalker walker = new ParseTreeWalker();
|
ParseTreeWalker walker = new ParseTreeWalker();
|
||||||
MyListener listener = new MyListener();
|
SoftwareReqParseTree listener = new SoftwareReqParseTree();
|
||||||
walker.walk(listener, parser.start());
|
walker.walk(listener, parser.program());
|
||||||
}
|
}
|
||||||
|
|
||||||
static class MyListener extends HelloWorldBaseListener {
|
static class SoftwareReqParseTree extends SoftwareRequirementsBaseListener {
|
||||||
@Override
|
@Override
|
||||||
public void enterStart(HelloWorldParser.StartContext ctx) {
|
public void enterProgram(SoftwareRequirementsParser.ProgramContext ctx) {
|
||||||
System.out.println("Parsed: " + ctx.getText());
|
System.out.println("Parsed: " + ctx.getText());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,14 +0,0 @@
|
|||||||
token literal names:
|
|
||||||
null
|
|
||||||
'Hello, World!'
|
|
||||||
|
|
||||||
token symbolic names:
|
|
||||||
null
|
|
||||||
null
|
|
||||||
|
|
||||||
rule names:
|
|
||||||
start
|
|
||||||
|
|
||||||
|
|
||||||
atn:
|
|
||||||
[4, 1, 1, 6, 2, 0, 7, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 0, 0, 0, 4, 0, 2, 1, 0, 0, 0, 2, 3, 5, 1, 0, 0, 3, 4, 5, 0, 0, 1, 4, 1, 1, 0, 0, 0, 0]
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
T__0=1
|
|
||||||
'Hello, World!'=1
|
|
||||||
@@ -1,51 +0,0 @@
|
|||||||
package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/HelloWorld.g4 by ANTLR 4.13.1
|
|
||||||
|
|
||||||
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 HelloWorldListener},
|
|
||||||
* which can be extended to create a listener which only needs to handle a subset
|
|
||||||
* of the available methods.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public class HelloWorldBaseListener implements HelloWorldListener {
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterStart(HelloWorldParser.StartContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitStart(HelloWorldParser.StartContext ctx) { }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void enterEveryRule(ParserRuleContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void exitEveryRule(ParserRuleContext ctx) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void visitTerminal(TerminalNode node) { }
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation does nothing.</p>
|
|
||||||
*/
|
|
||||||
@Override public void visitErrorNode(ErrorNode node) { }
|
|
||||||
}
|
|
||||||
@@ -1,21 +0,0 @@
|
|||||||
package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/HelloWorld.g4 by ANTLR 4.13.1
|
|
||||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This class provides an empty implementation of {@link HelloWorldVisitor},
|
|
||||||
* which can be extended to create a visitor which only needs to handle a subset
|
|
||||||
* of the available methods.
|
|
||||||
*
|
|
||||||
* @param <T> The return type of the visit operation. Use {@link Void} for
|
|
||||||
* operations with no return type.
|
|
||||||
*/
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public class HelloWorldBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements HelloWorldVisitor<T> {
|
|
||||||
/**
|
|
||||||
* {@inheritDoc}
|
|
||||||
*
|
|
||||||
* <p>The default implementation returns the result of calling
|
|
||||||
* {@link #visitChildren} on {@code ctx}.</p>
|
|
||||||
*/
|
|
||||||
@Override public T visitStart(HelloWorldParser.StartContext ctx) { return visitChildren(ctx); }
|
|
||||||
}
|
|
||||||
@@ -1,20 +0,0 @@
|
|||||||
token literal names:
|
|
||||||
null
|
|
||||||
'Hello, World!'
|
|
||||||
|
|
||||||
token symbolic names:
|
|
||||||
null
|
|
||||||
null
|
|
||||||
|
|
||||||
rule names:
|
|
||||||
T__0
|
|
||||||
|
|
||||||
channel names:
|
|
||||||
DEFAULT_TOKEN_CHANNEL
|
|
||||||
HIDDEN
|
|
||||||
|
|
||||||
mode names:
|
|
||||||
DEFAULT_MODE
|
|
||||||
|
|
||||||
atn:
|
|
||||||
[4, 0, 1, 17, 6, -1, 2, 0, 7, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 0, 0, 1, 1, 1, 1, 0, 0, 16, 0, 1, 1, 0, 0, 0, 1, 3, 1, 0, 0, 0, 3, 4, 5, 72, 0, 0, 4, 5, 5, 101, 0, 0, 5, 6, 5, 108, 0, 0, 6, 7, 5, 108, 0, 0, 7, 8, 5, 111, 0, 0, 8, 9, 5, 44, 0, 0, 9, 10, 5, 32, 0, 0, 10, 11, 5, 87, 0, 0, 11, 12, 5, 111, 0, 0, 12, 13, 5, 114, 0, 0, 13, 14, 5, 108, 0, 0, 14, 15, 5, 100, 0, 0, 15, 16, 5, 33, 0, 0, 16, 2, 1, 0, 0, 0, 1, 0, 0]
|
|
||||||
@@ -1,123 +0,0 @@
|
|||||||
package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/HelloWorld.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 HelloWorldLexer 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;
|
|
||||||
public static String[] channelNames = {
|
|
||||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
|
||||||
};
|
|
||||||
|
|
||||||
public static String[] modeNames = {
|
|
||||||
"DEFAULT_MODE"
|
|
||||||
};
|
|
||||||
|
|
||||||
private static String[] makeRuleNames() {
|
|
||||||
return new String[] {
|
|
||||||
"T__0"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static final String[] ruleNames = makeRuleNames();
|
|
||||||
|
|
||||||
private static String[] makeLiteralNames() {
|
|
||||||
return new String[] {
|
|
||||||
null, "'Hello, World!'"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
|
||||||
private static String[] makeSymbolicNames() {
|
|
||||||
return new String[] {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
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] = "<INVALID>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public String[] getTokenNames() {
|
|
||||||
return tokenNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
|
|
||||||
public Vocabulary getVocabulary() {
|
|
||||||
return VOCABULARY;
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
public HelloWorldLexer(CharStream input) {
|
|
||||||
super(input);
|
|
||||||
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGrammarFileName() { return "HelloWorld.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\u0001\u0011\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0001"+
|
|
||||||
"\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001"+
|
|
||||||
"\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001\u0000\u0001"+
|
|
||||||
"\u0000\u0001\u0000\u0000\u0000\u0001\u0001\u0001\u0001\u0000\u0000\u0010"+
|
|
||||||
"\u0000\u0001\u0001\u0000\u0000\u0000\u0001\u0003\u0001\u0000\u0000\u0000"+
|
|
||||||
"\u0003\u0004\u0005H\u0000\u0000\u0004\u0005\u0005e\u0000\u0000\u0005\u0006"+
|
|
||||||
"\u0005l\u0000\u0000\u0006\u0007\u0005l\u0000\u0000\u0007\b\u0005o\u0000"+
|
|
||||||
"\u0000\b\t\u0005,\u0000\u0000\t\n\u0005 \u0000\u0000\n\u000b\u0005W\u0000"+
|
|
||||||
"\u0000\u000b\f\u0005o\u0000\u0000\f\r\u0005r\u0000\u0000\r\u000e\u0005"+
|
|
||||||
"l\u0000\u0000\u000e\u000f\u0005d\u0000\u0000\u000f\u0010\u0005!\u0000"+
|
|
||||||
"\u0000\u0010\u0002\u0001\u0000\u0000\u0000\u0001\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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,2 +0,0 @@
|
|||||||
T__0=1
|
|
||||||
'Hello, World!'=1
|
|
||||||
@@ -1,19 +0,0 @@
|
|||||||
package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/HelloWorld.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 HelloWorldParser}.
|
|
||||||
*/
|
|
||||||
public interface HelloWorldListener extends ParseTreeListener {
|
|
||||||
/**
|
|
||||||
* Enter a parse tree produced by {@link HelloWorldParser#start}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void enterStart(HelloWorldParser.StartContext ctx);
|
|
||||||
/**
|
|
||||||
* Exit a parse tree produced by {@link HelloWorldParser#start}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
*/
|
|
||||||
void exitStart(HelloWorldParser.StartContext ctx);
|
|
||||||
}
|
|
||||||
@@ -1,149 +0,0 @@
|
|||||||
// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/HelloWorld.g4 by ANTLR 4.13.1
|
|
||||||
package org.lumijiez.parser;
|
|
||||||
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 HelloWorldParser 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;
|
|
||||||
public static final int
|
|
||||||
RULE_start = 0;
|
|
||||||
private static String[] makeRuleNames() {
|
|
||||||
return new String[] {
|
|
||||||
"start"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
public static final String[] ruleNames = makeRuleNames();
|
|
||||||
|
|
||||||
private static String[] makeLiteralNames() {
|
|
||||||
return new String[] {
|
|
||||||
null, "'Hello, World!'"
|
|
||||||
};
|
|
||||||
}
|
|
||||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
|
||||||
private static String[] makeSymbolicNames() {
|
|
||||||
return new String[] {
|
|
||||||
};
|
|
||||||
}
|
|
||||||
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] = "<INVALID>";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
@Deprecated
|
|
||||||
public String[] getTokenNames() {
|
|
||||||
return tokenNames;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
|
|
||||||
public Vocabulary getVocabulary() {
|
|
||||||
return VOCABULARY;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getGrammarFileName() { return "HelloWorld.g4"; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String[] getRuleNames() { return ruleNames; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getSerializedATN() { return _serializedATN; }
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public ATN getATN() { return _ATN; }
|
|
||||||
|
|
||||||
public HelloWorldParser(TokenStream input) {
|
|
||||||
super(input);
|
|
||||||
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
|
|
||||||
}
|
|
||||||
|
|
||||||
@SuppressWarnings("CheckReturnValue")
|
|
||||||
public static class StartContext extends ParserRuleContext {
|
|
||||||
public TerminalNode EOF() { return getToken(HelloWorldParser.EOF, 0); }
|
|
||||||
public StartContext(ParserRuleContext parent, int invokingState) {
|
|
||||||
super(parent, invokingState);
|
|
||||||
}
|
|
||||||
@Override public int getRuleIndex() { return RULE_start; }
|
|
||||||
@Override
|
|
||||||
public void enterRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof HelloWorldListener ) ((HelloWorldListener)listener).enterStart(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public void exitRule(ParseTreeListener listener) {
|
|
||||||
if ( listener instanceof HelloWorldListener ) ((HelloWorldListener)listener).exitStart(this);
|
|
||||||
}
|
|
||||||
@Override
|
|
||||||
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
|
|
||||||
if ( visitor instanceof HelloWorldVisitor ) return ((HelloWorldVisitor<? extends T>)visitor).visitStart(this);
|
|
||||||
else return visitor.visitChildren(this);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public final StartContext start() throws RecognitionException {
|
|
||||||
StartContext _localctx = new StartContext(_ctx, getState());
|
|
||||||
enterRule(_localctx, 0, RULE_start);
|
|
||||||
try {
|
|
||||||
enterOuterAlt(_localctx, 1);
|
|
||||||
{
|
|
||||||
setState(2);
|
|
||||||
match(T__0);
|
|
||||||
setState(3);
|
|
||||||
match(EOF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
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\u0001\u0006\u0002\u0000\u0007\u0000\u0001\u0000\u0001\u0000"+
|
|
||||||
"\u0001\u0000\u0001\u0000\u0000\u0000\u0001\u0000\u0000\u0000\u0004\u0000"+
|
|
||||||
"\u0002\u0001\u0000\u0000\u0000\u0002\u0003\u0005\u0001\u0000\u0000\u0003"+
|
|
||||||
"\u0004\u0005\u0000\u0000\u0001\u0004\u0001\u0001\u0000\u0000\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);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,18 +0,0 @@
|
|||||||
package org.lumijiez.parser;// Generated from D:/Source/JavaProjects/dsl-formal-requirements/src/grammars/HelloWorld.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 HelloWorldParser}.
|
|
||||||
*
|
|
||||||
* @param <T> The return type of the visit operation. Use {@link Void} for
|
|
||||||
* operations with no return type.
|
|
||||||
*/
|
|
||||||
public interface HelloWorldVisitor<T> extends ParseTreeVisitor<T> {
|
|
||||||
/**
|
|
||||||
* Visit a parse tree produced by {@link HelloWorldParser#start}.
|
|
||||||
* @param ctx the parse tree
|
|
||||||
* @return the visitor result
|
|
||||||
*/
|
|
||||||
T visitStart(HelloWorldParser.StartContext ctx);
|
|
||||||
}
|
|
||||||
5
src/main/resources/TestProgram.txt
Normal file
5
src/main/resources/TestProgram.txt
Normal file
@@ -0,0 +1,5 @@
|
|||||||
|
DatabaseAccess:
|
||||||
|
("UserIsAuthenticated" && "UserHasPermission") => ("AccessToAdminPanel" || "AccessToModeratorPanel");
|
||||||
|
|
||||||
|
GetUserList():
|
||||||
|
("Return" : "int x, float y", "Execution Time" : "<1s");
|
||||||
Reference in New Issue
Block a user