I'm doing a course on compiler techniques. I have created a g4 format file, and will compile it when I try to do that by using java compiler (javac), then it gives me lots of errors.
Someone who can explain what I am doing wrong?
Below I'm showing what I'm typing and what I'm doing wrong. I tried to check, if I didn't install the antlr4, but I already did, and I am sure I did. Did the every installation through Ubuntu application through Microsoft Store, and I am using Ubuntu terminal on Windows 10.
:~$ cd /mnt/c/Users/myUser/dato
:/mnt/c/Users/myUser/dato$ antlr4 dato.g4
:/mnt/c/Users/myUser/dato$ javac *.java
datoBaseListener.java:3: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.ParserRuleContext;
^
datoBaseListener.java:4: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.ErrorNode;
^
datoBaseListener.java:5: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.TerminalNode;
^
datoListener.java:2: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.ParseTreeListener;
^
datoListener.java:8: error: cannot find symbol
public interface datoListener extends ParseTreeListener {
^
symbol: class ParseTreeListener
datoParser.java:3: error: package org.antlr.v4.runtime.dfa does not exist
import org.antlr.v4.runtime.dfa.DFA;
^
datoParser.java:12: error: cannot find symbol
public class datoParser extends Parser {
^
symbol: class Parser
datoParser.java:92: error: cannot find symbol
public static class StartContext extends ParserRuleContext {
^
symbol: class ParserRuleContext
location: class datoParser
datoBaseListener.java:31: error: cannot find symbol
@Override public void enterEveryRule(ParserRuleContext ctx) { }
^
symbol: class ParserRuleContext
location: class datoBaseListener
datoBaseListener.java:37: error: cannot find symbol
@Override public void exitEveryRule(ParserRuleContext ctx) { }
^
symbol: class ParserRuleContext
location: class datoBaseListener
datoBaseListener.java:43: error: cannot find symbol
@Override public void visitTerminal(TerminalNode node) { }
^
symbol: class TerminalNode
location: class datoBaseListener
datoBaseListener.java:49: error: cannot find symbol
@Override public void visitErrorNode(ErrorNode node) { }
^
symbol: class ErrorNode
location: class datoBaseListener
datoParser.java:93: error: cannot find symbol
public Token d;
^
symbol: class Token
location: class StartContext
datoParser.java:94: error: cannot find symbol
public TerminalNode EOF() { return getToken(datoParser.EOF, 0); }
^
symbol: class TerminalNode
location: class StartContext
datoParser.java:95: error: cannot find symbol
public TerminalNode MYTOKEN() { return getToken(datoParser.MYTOKEN, 0); }
^
symbol: class TerminalNode
location: class StartContext
datoParser.java:96: error: cannot find symbol
public StartContext(ParserRuleContext parent, int invokingState) {
^
symbol: class ParserRuleContext
location: class StartContext
datoParser.java:101: error: cannot find symbol
public void enterRule(ParseTreeListener listener) {
^
symbol: class ParseTreeListener
location: class StartContext
datoParser.java:105: error: cannot find symbol
public void exitRule(ParseTreeListener listener) {
^
symbol: class ParseTreeListener
location: class StartContext
datoParser.java:15: error: cannot find symbol
protected static final DFA[] _decisionToDFA;
^
symbol: class DFA
location: class datoParser
datoParser.java:16: error: cannot find symbol
protected static final PredictionContextCache _sharedContextCache =
^
symbol: class PredictionContextCache
location: class datoParser
datoParser.java:43: error: cannot find symbol
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
^
symbol: class Vocabulary
location: class datoParser
datoParser.java:72: error: cannot find symbol
public Vocabulary getVocabulary() {
^
symbol: class Vocabulary
location: class datoParser
datoParser.java:86: error: cannot find symbol
public ATN getATN() { return _ATN; }
^
symbol: class ATN
location: class datoParser
datoParser.java:88: error: cannot find symbol
public datoParser(TokenStream input) {
^
symbol: class TokenStream
location: class datoParser
datoParser.java:110: error: cannot find symbol
public final StartContext start() throws RecognitionException {
^
symbol: class RecognitionException
location: class datoParser
datoParser.java:137: error: cannot find symbol
public static final ATN _ATN =
^
symbol: class ATN
location: class datoParser
datoParser.java:2: error: package org.antlr.v4.runtime.atn does not exist
import org.antlr.v4.runtime.atn.*;
^
datoParser.java:4: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.*;
^
datoParser.java:5: error: package org.antlr.v4.runtime.misc does not exist
import org.antlr.v4.runtime.misc.*;
^
datoParser.java:6: error: package org.antlr.v4.runtime.tree does not exist
import org.antlr.v4.runtime.tree.*;
^
datoLexer.java:2: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.Lexer;
^
datoLexer.java:3: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.CharStream;
^
datoLexer.java:4: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.Token;
^
datoLexer.java:5: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.TokenStream;
^
datoLexer.java:8: error: package org.antlr.v4.runtime.dfa does not exist
import org.antlr.v4.runtime.dfa.DFA;
^
datoLexer.java:12: error: cannot find symbol
public class datoLexer extends Lexer {
^
symbol: class Lexer
datoLexer.java:15: error: cannot find symbol
protected static final DFA[] _decisionToDFA;
^
symbol: class DFA
location: class datoLexer
datoLexer.java:16: error: cannot find symbol
protected static final PredictionContextCache _sharedContextCache =
^
symbol: class PredictionContextCache
location: class datoLexer
datoLexer.java:50: error: cannot find symbol
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
^
symbol: class Vocabulary
location: class datoLexer
datoLexer.java:79: error: cannot find symbol
public Vocabulary getVocabulary() {
^
symbol: class Vocabulary
location: class datoLexer
datoLexer.java:84: error: cannot find symbol
public datoLexer(CharStream input) {
^
symbol: class CharStream
location: class datoLexer
datoLexer.java:105: error: cannot find symbol
public ATN getATN() { return _ATN; }
^
symbol: class ATN
location: class datoLexer
datoLexer.java:136: error: cannot find symbol
public static final ATN _ATN =
^
symbol: class ATN
location: class datoLexer
datoLexer.java:6: error: package org.antlr.v4.runtime does not exist
import org.antlr.v4.runtime.*;
^
datoLexer.java:7: error: package org.antlr.v4.runtime.atn does not exist
import org.antlr.v4.runtime.atn.*;
^
datoLexer.java:9: error: package org.antlr.v4.runtime.misc does not exist
import org.antlr.v4.runtime.misc.*;
^
datoBaseListener.java:31: error: method does not override or implement a method from a supertype
@Override public void enterEveryRule(ParserRuleContext ctx) { }
^
datoBaseListener.java:37: error: method does not override or implement a method from a supertype
@Override public void exitEveryRule(ParserRuleContext ctx) { }
^
datoBaseListener.java:43: error: method does not override or implement a method from a supertype
@Override public void visitTerminal(TerminalNode node) { }
^
datoBaseListener.java:49: error: method does not override or implement a method from a supertype
@Override public void visitErrorNode(ErrorNode node) { }
^
datoParser.java:13: error: cannot find symbol
static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); }
^
symbol: variable RuntimeMetaData
location: class datoParser
datoParser.java:13: error: cannot find symbol
static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); }
^
symbol: variable RuntimeMetaData
location: class datoParser
datoParser.java:17: error: cannot find symbol
new PredictionContextCache();
^
symbol: class PredictionContextCache
location: class datoParser
datoParser.java:43: error: cannot find symbol
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
^
symbol: class VocabularyImpl
location: class datoParser
datoParser.java:64: error: method does not override or implement a method from a supertype
@Override
^
datoParser.java:70: error: method does not override or implement a method from a supertype
@Override
^
datoParser.java:76: error: method does not override or implement a method from a supertype
@Override
^
datoParser.java:79: error: method does not override or implement a method from a supertype
@Override
^
datoParser.java:82: error: method does not override or implement a method from a supertype
@Override
^
datoParser.java:85: error: method does not override or implement a method from a supertype
@Override
^
datoParser.java:90: error: cannot find symbol
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
^
symbol: variable _interp
location: class datoParser
datoParser.java:90: error: cannot find symbol
_interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
^
symbol: class ParserATNSimulator
location: class datoParser
datoParser.java:94: error: cannot find symbol
public TerminalNode EOF() { return getToken(datoParser.EOF, 0); }
^
symbol: variable EOF
location: class datoParser
datoParser.java:95: error: cannot find symbol
public TerminalNode MYTOKEN() { return getToken(datoParser.MYTOKEN, 0); }
^
symbol: method getToken(int,int)
location: class StartContext
datoParser.java:99: error: method does not override or implement a method from a supertype
@Override public int getRuleIndex() { return RULE_start; }
^
datoParser.java:100: error: method does not override or implement a method from a supertype
@Override
^
datoParser.java:104: error: method does not override or implement a method from a supertype
@Override
^
datoParser.java:111: error: cannot find symbol
StartContext _localctx = new StartContext(_ctx, getState());
^
symbol: variable _ctx
location: class datoParser
datoParser.java:111: error: cannot find symbol
StartContext _localctx = new StartContext(_ctx, getState());
^
symbol: method getState()
location: class datoParser
datoParser.java:112: error: cannot find symbol
enterRule(_localctx, 0, RULE_start);
^
symbol: method enterRule(StartContext,int,int)
location: class datoParser
datoParser.java:114: error: cannot find symbol
enterOuterAlt(_localctx, 1);
^
symbol: method enterOuterAlt(StartContext,int)
location: class datoParser
datoParser.java:116: error: cannot find symbol
setState(2);
^
symbol: method setState(int)
location: class datoParser
datoParser.java:117: error: cannot find symbol
((StartContext)_localctx).d = match(MYTOKEN);
^
symbol: method match(int)
location: class datoParser
datoParser.java:118: error: cannot find symbol
setState(3);
^
symbol: method setState(int)
location: class datoParser
datoParser.java:119: error: cannot find symbol
match(EOF);
^
symbol: variable EOF
location: class datoParser
datoParser.java:122: error: cannot find symbol
catch (RecognitionException re) {
^
symbol: class RecognitionException
location: class datoParser
datoParser.java:123: error: cannot find symbol
_localctx.exception = re;
^
symbol: variable exception
location: variable _localctx of type StartContext
datoParser.java:124: error: cannot find symbol
_errHandler.reportError(this, re);
^
symbol: variable _errHandler
location: class datoParser
datoParser.java:125: error: cannot find symbol
_errHandler.recover(this, re);
^
symbol: variable _errHandler
location: class datoParser
datoParser.java:128: error: cannot find symbol
exitRule();
^
symbol: method exitRule()
location: class datoParser
datoParser.java:138: error: cannot find symbol
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
^
symbol: class ATNDeserializer
location: class datoParser
datoParser.java:140: error: cannot find symbol
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
^
symbol: class DFA
location: class datoParser
datoParser.java:142: error: cannot find symbol
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
^
symbol: class DFA
location: class datoParser
datoLexer.java:13: error: cannot find symbol
static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); }
^
symbol: variable RuntimeMetaData
location: class datoLexer
datoLexer.java:13: error: cannot find symbol
static { RuntimeMetaData.checkVersion("4.7.2", RuntimeMetaData.VERSION); }
^
symbol: variable RuntimeMetaData
location: class datoLexer
datoLexer.java:17: error: cannot find symbol
new PredictionContextCache();
^
symbol: class PredictionContextCache
location: class datoLexer
datoLexer.java:50: error: cannot find symbol
public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
^
symbol: class VocabularyImpl
location: class datoLexer
datoLexer.java:71: error: method does not override or implement a method from a supertype
@Override
^
datoLexer.java:77: error: method does not override or implement a method from a supertype
@Override
^
datoLexer.java:86: error: cannot find symbol
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
^
symbol: variable _interp
location: class datoLexer
datoLexer.java:86: error: cannot find symbol
_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
^
symbol: class LexerATNSimulator
location: class datoLexer
datoLexer.java:89: error: method does not override or implement a method from a supertype
@Override
^
datoLexer.java:92: error: method does not override or implement a method from a supertype
@Override
^
datoLexer.java:95: error: method does not override or implement a method from a supertype
@Override
^
datoLexer.java:98: error: method does not override or implement a method from a supertype
@Override
^
datoLexer.java:101: error: method does not override or implement a method from a supertype
@Override
^
datoLexer.java:104: error: method does not override or implement a method from a supertype
@Override
^
datoLexer.java:137: error: cannot find symbol
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
^
symbol: class ATNDeserializer
location: class datoLexer
datoLexer.java:139: error: cannot find symbol
_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
^
symbol: class DFA
location: class datoLexer
datoLexer.java:141: error: cannot find symbol
_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
^
symbol: class DFA
location: class datoLexer
100 errors
:/mnt/c/Users/myUser/dato$ sudo apt install antlr4
[sudo] password for ACCOUNT:
Reading package lists... Done
Building dependency tree
Reading state information... Done
antlr4 is already the newest version.
0 upgraded, 0 newly installed, 0 to remove and 2 not upgraded.
:/mnt/c/Users/myUser/dato$
Why am I getting these errors? Am I using a wrong command?