cmds = valores.pegue(ctx.seqComando());
95 | valores.insira(ctx, new Bloco(cmds));
96 | }
97 |
98 | @Override
99 | public void exitOpBin(OpBinContext ctx) {
100 | final Expressao esq = valores.pegue(ctx.expressao(0));
101 | final Expressao dir = valores.pegue(ctx.expressao(1));
102 | final String op = ctx.getChild(1).getText();
103 | final Expressao exp = switch (op) {
104 | case "*" -> new ExpMult(esq, dir);
105 | case "-" -> new ExpSub(esq, dir);
106 | default -> new ExpSoma(esq, dir);
107 | };
108 | valores.insira(ctx, exp);
109 | }
110 |
111 | @Override
112 | public void exitEnquanto(EnquantoContext ctx) {
113 | final Bool condicao = valores.pegue(ctx.booleano());
114 | final Comando comando = valores.pegue(ctx.comando());
115 | valores.insira(ctx, new Enquanto(condicao, comando));
116 | }
117 |
118 | @Override
119 | public void exitELogico(ELogicoContext ctx) {
120 | final Bool esq = valores.pegue(ctx.booleano(0));
121 | final Bool dir = valores.pegue(ctx.booleano(1));
122 | valores.insira(ctx, new ELogico(esq, dir));
123 | }
124 |
125 | @Override
126 | public void exitBoolPar(BoolParContext ctx) {
127 | final Bool booleano = valores.pegue(ctx.booleano());
128 | valores.insira(ctx, booleano);
129 | }
130 |
131 | @Override
132 | public void exitNaoLogico(NaoLogicoContext ctx) {
133 | final Bool b = valores.pegue(ctx.booleano());
134 | valores.insira(ctx, new NaoLogico(b));
135 | }
136 |
137 | @Override
138 | public void exitExpPar(ExpParContext ctx) {
139 | final Expressao exp = valores.pegue(ctx.expressao());
140 | valores.insira(ctx, exp);
141 | }
142 |
143 | @Override
144 | public void exitExiba(ExibaContext ctx) {
145 | final String t = ctx.TEXTO().getText();
146 | final String texto = t.substring(1, t.length() - 1);
147 | valores.insira(ctx, new Exiba(texto));
148 | }
149 |
150 | @Override
151 | public void exitOpRel(OpRelContext ctx) {
152 | final Expressao esq = valores.pegue(ctx.expressao(0));
153 | final Expressao dir = valores.pegue(ctx.expressao(1));
154 | final String op = ctx.getChild(1).getText();
155 | final Bool exp = switch (op) {
156 | case "=" -> new ExpIgual(esq, dir);
157 | case "<=" -> new ExpMenorIgual(esq, dir);
158 | default -> new ExpIgual(esq, esq);
159 | };
160 | valores.insira(ctx, exp);
161 | }
162 | }
163 |
--------------------------------------------------------------------------------
/src/plp/enquanto/parser/Enquanto.g4:
--------------------------------------------------------------------------------
1 | grammar Enquanto;
2 |
3 | programa : seqComando; // sequência de comandos
4 |
5 | seqComando: comando (';' comando)* ;
6 |
7 | comando: ID ':=' expressao # atribuicao
8 | | 'skip' # skip
9 | | 'se' booleano 'entao' comando 'senao' comando # se
10 | | 'enquanto' booleano 'faca' comando # enquanto
11 | | 'exiba' TEXTO # exiba
12 | | 'escreva' expressao # escreva
13 | | '{' seqComando '}' # bloco
14 | ;
15 |
16 | expressao: INT # inteiro
17 | | 'leia' # leia
18 | | ID # id
19 | | expressao '*' expressao # opBin
20 | | expressao ('+' | '-') expressao # opBin
21 | | '(' expressao ')' # expPar
22 | ;
23 |
24 | booleano: BOOLEANO # bool
25 | | expressao '=' expressao # opRel
26 | | expressao '<=' expressao # opRel
27 | | 'nao' booleano # naoLogico
28 | | booleano 'e' booleano # eLogico
29 | | '(' booleano ')' # boolPar
30 | ;
31 |
32 |
33 | BOOLEANO: 'verdadeiro' | 'falso';
34 | INT: ('0'..'9')+ ;
35 | ID: ('a'..'z')+;
36 | TEXTO: '"' .*? '"';
37 |
38 | Comentario: '#' .*? '\n' -> skip;
39 | Espaco: [ \t\n\r] -> skip;
--------------------------------------------------------------------------------
/src/plp/enquanto/parser/EnquantoBaseListener.java:
--------------------------------------------------------------------------------
1 | // Generated from ./src/plp/enquanto/parser/Enquanto.g4 by ANTLR 4.13.1
2 | package plp.enquanto.parser;
3 |
4 | import org.antlr.v4.runtime.ParserRuleContext;
5 | import org.antlr.v4.runtime.tree.ErrorNode;
6 | import org.antlr.v4.runtime.tree.TerminalNode;
7 |
8 | /**
9 | * This class provides an empty implementation of {@link EnquantoListener},
10 | * which can be extended to create a listener which only needs to handle a subset
11 | * of the available methods.
12 | */
13 | @SuppressWarnings("CheckReturnValue")
14 | public class EnquantoBaseListener implements EnquantoListener {
15 | /**
16 | * {@inheritDoc}
17 | *
18 | * The default implementation does nothing.
19 | */
20 | @Override public void enterPrograma(EnquantoParser.ProgramaContext ctx) { }
21 | /**
22 | * {@inheritDoc}
23 | *
24 | * The default implementation does nothing.
25 | */
26 | @Override public void exitPrograma(EnquantoParser.ProgramaContext ctx) { }
27 | /**
28 | * {@inheritDoc}
29 | *
30 | * The default implementation does nothing.
31 | */
32 | @Override public void enterSeqComando(EnquantoParser.SeqComandoContext ctx) { }
33 | /**
34 | * {@inheritDoc}
35 | *
36 | * The default implementation does nothing.
37 | */
38 | @Override public void exitSeqComando(EnquantoParser.SeqComandoContext ctx) { }
39 | /**
40 | * {@inheritDoc}
41 | *
42 | * The default implementation does nothing.
43 | */
44 | @Override public void enterAtribuicao(EnquantoParser.AtribuicaoContext ctx) { }
45 | /**
46 | * {@inheritDoc}
47 | *
48 | * The default implementation does nothing.
49 | */
50 | @Override public void exitAtribuicao(EnquantoParser.AtribuicaoContext ctx) { }
51 | /**
52 | * {@inheritDoc}
53 | *
54 | * The default implementation does nothing.
55 | */
56 | @Override public void enterSkip(EnquantoParser.SkipContext ctx) { }
57 | /**
58 | * {@inheritDoc}
59 | *
60 | * The default implementation does nothing.
61 | */
62 | @Override public void exitSkip(EnquantoParser.SkipContext ctx) { }
63 | /**
64 | * {@inheritDoc}
65 | *
66 | * The default implementation does nothing.
67 | */
68 | @Override public void enterSe(EnquantoParser.SeContext ctx) { }
69 | /**
70 | * {@inheritDoc}
71 | *
72 | * The default implementation does nothing.
73 | */
74 | @Override public void exitSe(EnquantoParser.SeContext ctx) { }
75 | /**
76 | * {@inheritDoc}
77 | *
78 | * The default implementation does nothing.
79 | */
80 | @Override public void enterEnquanto(EnquantoParser.EnquantoContext ctx) { }
81 | /**
82 | * {@inheritDoc}
83 | *
84 | * The default implementation does nothing.
85 | */
86 | @Override public void exitEnquanto(EnquantoParser.EnquantoContext ctx) { }
87 | /**
88 | * {@inheritDoc}
89 | *
90 | * The default implementation does nothing.
91 | */
92 | @Override public void enterExiba(EnquantoParser.ExibaContext ctx) { }
93 | /**
94 | * {@inheritDoc}
95 | *
96 | * The default implementation does nothing.
97 | */
98 | @Override public void exitExiba(EnquantoParser.ExibaContext ctx) { }
99 | /**
100 | * {@inheritDoc}
101 | *
102 | * The default implementation does nothing.
103 | */
104 | @Override public void enterEscreva(EnquantoParser.EscrevaContext ctx) { }
105 | /**
106 | * {@inheritDoc}
107 | *
108 | * The default implementation does nothing.
109 | */
110 | @Override public void exitEscreva(EnquantoParser.EscrevaContext ctx) { }
111 | /**
112 | * {@inheritDoc}
113 | *
114 | * The default implementation does nothing.
115 | */
116 | @Override public void enterBloco(EnquantoParser.BlocoContext ctx) { }
117 | /**
118 | * {@inheritDoc}
119 | *
120 | * The default implementation does nothing.
121 | */
122 | @Override public void exitBloco(EnquantoParser.BlocoContext ctx) { }
123 | /**
124 | * {@inheritDoc}
125 | *
126 | * The default implementation does nothing.
127 | */
128 | @Override public void enterLeia(EnquantoParser.LeiaContext ctx) { }
129 | /**
130 | * {@inheritDoc}
131 | *
132 | * The default implementation does nothing.
133 | */
134 | @Override public void exitLeia(EnquantoParser.LeiaContext ctx) { }
135 | /**
136 | * {@inheritDoc}
137 | *
138 | * The default implementation does nothing.
139 | */
140 | @Override public void enterInteiro(EnquantoParser.InteiroContext ctx) { }
141 | /**
142 | * {@inheritDoc}
143 | *
144 | * The default implementation does nothing.
145 | */
146 | @Override public void exitInteiro(EnquantoParser.InteiroContext ctx) { }
147 | /**
148 | * {@inheritDoc}
149 | *
150 | * The default implementation does nothing.
151 | */
152 | @Override public void enterOpBin(EnquantoParser.OpBinContext ctx) { }
153 | /**
154 | * {@inheritDoc}
155 | *
156 | * The default implementation does nothing.
157 | */
158 | @Override public void exitOpBin(EnquantoParser.OpBinContext ctx) { }
159 | /**
160 | * {@inheritDoc}
161 | *
162 | * The default implementation does nothing.
163 | */
164 | @Override public void enterId(EnquantoParser.IdContext ctx) { }
165 | /**
166 | * {@inheritDoc}
167 | *
168 | * The default implementation does nothing.
169 | */
170 | @Override public void exitId(EnquantoParser.IdContext ctx) { }
171 | /**
172 | * {@inheritDoc}
173 | *
174 | * The default implementation does nothing.
175 | */
176 | @Override public void enterExpPar(EnquantoParser.ExpParContext ctx) { }
177 | /**
178 | * {@inheritDoc}
179 | *
180 | * The default implementation does nothing.
181 | */
182 | @Override public void exitExpPar(EnquantoParser.ExpParContext ctx) { }
183 | /**
184 | * {@inheritDoc}
185 | *
186 | * The default implementation does nothing.
187 | */
188 | @Override public void enterBool(EnquantoParser.BoolContext ctx) { }
189 | /**
190 | * {@inheritDoc}
191 | *
192 | * The default implementation does nothing.
193 | */
194 | @Override public void exitBool(EnquantoParser.BoolContext ctx) { }
195 | /**
196 | * {@inheritDoc}
197 | *
198 | * The default implementation does nothing.
199 | */
200 | @Override public void enterELogico(EnquantoParser.ELogicoContext ctx) { }
201 | /**
202 | * {@inheritDoc}
203 | *
204 | * The default implementation does nothing.
205 | */
206 | @Override public void exitELogico(EnquantoParser.ELogicoContext ctx) { }
207 | /**
208 | * {@inheritDoc}
209 | *
210 | * The default implementation does nothing.
211 | */
212 | @Override public void enterNaoLogico(EnquantoParser.NaoLogicoContext ctx) { }
213 | /**
214 | * {@inheritDoc}
215 | *
216 | * The default implementation does nothing.
217 | */
218 | @Override public void exitNaoLogico(EnquantoParser.NaoLogicoContext ctx) { }
219 | /**
220 | * {@inheritDoc}
221 | *
222 | * The default implementation does nothing.
223 | */
224 | @Override public void enterOpRel(EnquantoParser.OpRelContext ctx) { }
225 | /**
226 | * {@inheritDoc}
227 | *
228 | * The default implementation does nothing.
229 | */
230 | @Override public void exitOpRel(EnquantoParser.OpRelContext ctx) { }
231 | /**
232 | * {@inheritDoc}
233 | *
234 | * The default implementation does nothing.
235 | */
236 | @Override public void enterBoolPar(EnquantoParser.BoolParContext ctx) { }
237 | /**
238 | * {@inheritDoc}
239 | *
240 | * The default implementation does nothing.
241 | */
242 | @Override public void exitBoolPar(EnquantoParser.BoolParContext ctx) { }
243 |
244 | /**
245 | * {@inheritDoc}
246 | *
247 | * The default implementation does nothing.
248 | */
249 | @Override public void enterEveryRule(ParserRuleContext ctx) { }
250 | /**
251 | * {@inheritDoc}
252 | *
253 | * The default implementation does nothing.
254 | */
255 | @Override public void exitEveryRule(ParserRuleContext ctx) { }
256 | /**
257 | * {@inheritDoc}
258 | *
259 | * The default implementation does nothing.
260 | */
261 | @Override public void visitTerminal(TerminalNode node) { }
262 | /**
263 | * {@inheritDoc}
264 | *
265 | * The default implementation does nothing.
266 | */
267 | @Override public void visitErrorNode(ErrorNode node) { }
268 | }
--------------------------------------------------------------------------------
/src/plp/enquanto/parser/EnquantoLexer.java:
--------------------------------------------------------------------------------
1 | // Generated from ./src/plp/enquanto/parser/Enquanto.g4 by ANTLR 4.13.1
2 | package plp.enquanto.parser;
3 | import org.antlr.v4.runtime.Lexer;
4 | import org.antlr.v4.runtime.CharStream;
5 | import org.antlr.v4.runtime.Token;
6 | import org.antlr.v4.runtime.TokenStream;
7 | import org.antlr.v4.runtime.*;
8 | import org.antlr.v4.runtime.atn.*;
9 | import org.antlr.v4.runtime.dfa.DFA;
10 | import org.antlr.v4.runtime.misc.*;
11 |
12 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue", "this-escape"})
13 | public class EnquantoLexer extends Lexer {
14 | static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }
15 |
16 | protected static final DFA[] _decisionToDFA;
17 | protected static final PredictionContextCache _sharedContextCache =
18 | new PredictionContextCache();
19 | public static final int
20 | T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
21 | T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
22 | T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, BOOLEANO=23, INT=24,
23 | ID=25, TEXTO=26, Comentario=27, Espaco=28;
24 | public static String[] channelNames = {
25 | "DEFAULT_TOKEN_CHANNEL", "HIDDEN"
26 | };
27 |
28 | public static String[] modeNames = {
29 | "DEFAULT_MODE"
30 | };
31 |
32 | private static String[] makeRuleNames() {
33 | return new String[] {
34 | "T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
35 | "T__9", "T__10", "T__11", "T__12", "T__13", "T__14", "T__15", "T__16",
36 | "T__17", "T__18", "T__19", "T__20", "T__21", "BOOLEANO", "INT", "ID",
37 | "TEXTO", "Comentario", "Espaco"
38 | };
39 | }
40 | public static final String[] ruleNames = makeRuleNames();
41 |
42 | private static String[] makeLiteralNames() {
43 | return new String[] {
44 | null, "';'", "':='", "'skip'", "'se'", "'entao'", "'senao'", "'enquanto'",
45 | "'faca'", "'exiba'", "'escreva'", "'{'", "'}'", "'leia'", "'*'", "'+'",
46 | "'-'", "'('", "')'", "'='", "'<='", "'nao'", "'e'"
47 | };
48 | }
49 | private static final String[] _LITERAL_NAMES = makeLiteralNames();
50 | private static String[] makeSymbolicNames() {
51 | return new String[] {
52 | null, null, null, null, null, null, null, null, null, null, null, null,
53 | null, null, null, null, null, null, null, null, null, null, null, "BOOLEANO",
54 | "INT", "ID", "TEXTO", "Comentario", "Espaco"
55 | };
56 | }
57 | private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
58 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
59 |
60 | /**
61 | * @deprecated Use {@link #VOCABULARY} instead.
62 | */
63 | @Deprecated
64 | public static final String[] tokenNames;
65 | static {
66 | tokenNames = new String[_SYMBOLIC_NAMES.length];
67 | for (int i = 0; i < tokenNames.length; i++) {
68 | tokenNames[i] = VOCABULARY.getLiteralName(i);
69 | if (tokenNames[i] == null) {
70 | tokenNames[i] = VOCABULARY.getSymbolicName(i);
71 | }
72 |
73 | if (tokenNames[i] == null) {
74 | tokenNames[i] = "";
75 | }
76 | }
77 | }
78 |
79 | @Override
80 | @Deprecated
81 | public String[] getTokenNames() {
82 | return tokenNames;
83 | }
84 |
85 | @Override
86 |
87 | public Vocabulary getVocabulary() {
88 | return VOCABULARY;
89 | }
90 |
91 |
92 | public EnquantoLexer(CharStream input) {
93 | super(input);
94 | _interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
95 | }
96 |
97 | @Override
98 | public String getGrammarFileName() { return "Enquanto.g4"; }
99 |
100 | @Override
101 | public String[] getRuleNames() { return ruleNames; }
102 |
103 | @Override
104 | public String getSerializedATN() { return _serializedATN; }
105 |
106 | @Override
107 | public String[] getChannelNames() { return channelNames; }
108 |
109 | @Override
110 | public String[] getModeNames() { return modeNames; }
111 |
112 | @Override
113 | public ATN getATN() { return _ATN; }
114 |
115 | public static final String _serializedATN =
116 | "\u0004\u0000\u001c\u00bf\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002"+
117 | "\u0001\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002"+
118 | "\u0004\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002"+
119 | "\u0007\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002"+
120 | "\u000b\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0002\u000e\u0007\u000e"+
121 | "\u0002\u000f\u0007\u000f\u0002\u0010\u0007\u0010\u0002\u0011\u0007\u0011"+
122 | "\u0002\u0012\u0007\u0012\u0002\u0013\u0007\u0013\u0002\u0014\u0007\u0014"+
123 | "\u0002\u0015\u0007\u0015\u0002\u0016\u0007\u0016\u0002\u0017\u0007\u0017"+
124 | "\u0002\u0018\u0007\u0018\u0002\u0019\u0007\u0019\u0002\u001a\u0007\u001a"+
125 | "\u0002\u001b\u0007\u001b\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001"+
126 | "\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002"+
127 | "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004"+
128 | "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005"+
129 | "\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006"+
130 | "\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006"+
131 | "\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\b\u0001"+
132 | "\b\u0001\b\u0001\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001\t\u0001"+
133 | "\t\u0001\t\u0001\t\u0001\t\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001"+
134 | "\f\u0001\f\u0001\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001\u000e\u0001\u000e"+
135 | "\u0001\u000f\u0001\u000f\u0001\u0010\u0001\u0010\u0001\u0011\u0001\u0011"+
136 | "\u0001\u0012\u0001\u0012\u0001\u0013\u0001\u0013\u0001\u0013\u0001\u0014"+
137 | "\u0001\u0014\u0001\u0014\u0001\u0014\u0001\u0015\u0001\u0015\u0001\u0016"+
138 | "\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016"+
139 | "\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016\u0001\u0016"+
140 | "\u0001\u0016\u0001\u0016\u0003\u0016\u009c\b\u0016\u0001\u0017\u0004\u0017"+
141 | "\u009f\b\u0017\u000b\u0017\f\u0017\u00a0\u0001\u0018\u0004\u0018\u00a4"+
142 | "\b\u0018\u000b\u0018\f\u0018\u00a5\u0001\u0019\u0001\u0019\u0005\u0019"+
143 | "\u00aa\b\u0019\n\u0019\f\u0019\u00ad\t\u0019\u0001\u0019\u0001\u0019\u0001"+
144 | "\u001a\u0001\u001a\u0005\u001a\u00b3\b\u001a\n\u001a\f\u001a\u00b6\t\u001a"+
145 | "\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001a\u0001\u001b\u0001\u001b"+
146 | "\u0001\u001b\u0001\u001b\u0002\u00ab\u00b4\u0000\u001c\u0001\u0001\u0003"+
147 | "\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f\b\u0011"+
148 | "\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u001d\u000f\u001f\u0010"+
149 | "!\u0011#\u0012%\u0013\'\u0014)\u0015+\u0016-\u0017/\u00181\u00193\u001a"+
150 | "5\u001b7\u001c\u0001\u0000\u0001\u0003\u0000\t\n\r\r \u00c3\u0000\u0001"+
151 | "\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0005"+
152 | "\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001"+
153 | "\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000"+
154 | "\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000\u0000\u0011\u0001\u0000"+
155 | "\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000\u0000\u0015\u0001\u0000"+
156 | "\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000\u0000\u0019\u0001\u0000"+
157 | "\u0000\u0000\u0000\u001b\u0001\u0000\u0000\u0000\u0000\u001d\u0001\u0000"+
158 | "\u0000\u0000\u0000\u001f\u0001\u0000\u0000\u0000\u0000!\u0001\u0000\u0000"+
159 | "\u0000\u0000#\u0001\u0000\u0000\u0000\u0000%\u0001\u0000\u0000\u0000\u0000"+
160 | "\'\u0001\u0000\u0000\u0000\u0000)\u0001\u0000\u0000\u0000\u0000+\u0001"+
161 | "\u0000\u0000\u0000\u0000-\u0001\u0000\u0000\u0000\u0000/\u0001\u0000\u0000"+
162 | "\u0000\u00001\u0001\u0000\u0000\u0000\u00003\u0001\u0000\u0000\u0000\u0000"+
163 | "5\u0001\u0000\u0000\u0000\u00007\u0001\u0000\u0000\u0000\u00019\u0001"+
164 | "\u0000\u0000\u0000\u0003;\u0001\u0000\u0000\u0000\u0005>\u0001\u0000\u0000"+
165 | "\u0000\u0007C\u0001\u0000\u0000\u0000\tF\u0001\u0000\u0000\u0000\u000b"+
166 | "L\u0001\u0000\u0000\u0000\rR\u0001\u0000\u0000\u0000\u000f[\u0001\u0000"+
167 | "\u0000\u0000\u0011`\u0001\u0000\u0000\u0000\u0013f\u0001\u0000\u0000\u0000"+
168 | "\u0015n\u0001\u0000\u0000\u0000\u0017p\u0001\u0000\u0000\u0000\u0019r"+
169 | "\u0001\u0000\u0000\u0000\u001bw\u0001\u0000\u0000\u0000\u001dy\u0001\u0000"+
170 | "\u0000\u0000\u001f{\u0001\u0000\u0000\u0000!}\u0001\u0000\u0000\u0000"+
171 | "#\u007f\u0001\u0000\u0000\u0000%\u0081\u0001\u0000\u0000\u0000\'\u0083"+
172 | "\u0001\u0000\u0000\u0000)\u0086\u0001\u0000\u0000\u0000+\u008a\u0001\u0000"+
173 | "\u0000\u0000-\u009b\u0001\u0000\u0000\u0000/\u009e\u0001\u0000\u0000\u0000"+
174 | "1\u00a3\u0001\u0000\u0000\u00003\u00a7\u0001\u0000\u0000\u00005\u00b0"+
175 | "\u0001\u0000\u0000\u00007\u00bb\u0001\u0000\u0000\u00009:\u0005;\u0000"+
176 | "\u0000:\u0002\u0001\u0000\u0000\u0000;<\u0005:\u0000\u0000<=\u0005=\u0000"+
177 | "\u0000=\u0004\u0001\u0000\u0000\u0000>?\u0005s\u0000\u0000?@\u0005k\u0000"+
178 | "\u0000@A\u0005i\u0000\u0000AB\u0005p\u0000\u0000B\u0006\u0001\u0000\u0000"+
179 | "\u0000CD\u0005s\u0000\u0000DE\u0005e\u0000\u0000E\b\u0001\u0000\u0000"+
180 | "\u0000FG\u0005e\u0000\u0000GH\u0005n\u0000\u0000HI\u0005t\u0000\u0000"+
181 | "IJ\u0005a\u0000\u0000JK\u0005o\u0000\u0000K\n\u0001\u0000\u0000\u0000"+
182 | "LM\u0005s\u0000\u0000MN\u0005e\u0000\u0000NO\u0005n\u0000\u0000OP\u0005"+
183 | "a\u0000\u0000PQ\u0005o\u0000\u0000Q\f\u0001\u0000\u0000\u0000RS\u0005"+
184 | "e\u0000\u0000ST\u0005n\u0000\u0000TU\u0005q\u0000\u0000UV\u0005u\u0000"+
185 | "\u0000VW\u0005a\u0000\u0000WX\u0005n\u0000\u0000XY\u0005t\u0000\u0000"+
186 | "YZ\u0005o\u0000\u0000Z\u000e\u0001\u0000\u0000\u0000[\\\u0005f\u0000\u0000"+
187 | "\\]\u0005a\u0000\u0000]^\u0005c\u0000\u0000^_\u0005a\u0000\u0000_\u0010"+
188 | "\u0001\u0000\u0000\u0000`a\u0005e\u0000\u0000ab\u0005x\u0000\u0000bc\u0005"+
189 | "i\u0000\u0000cd\u0005b\u0000\u0000de\u0005a\u0000\u0000e\u0012\u0001\u0000"+
190 | "\u0000\u0000fg\u0005e\u0000\u0000gh\u0005s\u0000\u0000hi\u0005c\u0000"+
191 | "\u0000ij\u0005r\u0000\u0000jk\u0005e\u0000\u0000kl\u0005v\u0000\u0000"+
192 | "lm\u0005a\u0000\u0000m\u0014\u0001\u0000\u0000\u0000no\u0005{\u0000\u0000"+
193 | "o\u0016\u0001\u0000\u0000\u0000pq\u0005}\u0000\u0000q\u0018\u0001\u0000"+
194 | "\u0000\u0000rs\u0005l\u0000\u0000st\u0005e\u0000\u0000tu\u0005i\u0000"+
195 | "\u0000uv\u0005a\u0000\u0000v\u001a\u0001\u0000\u0000\u0000wx\u0005*\u0000"+
196 | "\u0000x\u001c\u0001\u0000\u0000\u0000yz\u0005+\u0000\u0000z\u001e\u0001"+
197 | "\u0000\u0000\u0000{|\u0005-\u0000\u0000| \u0001\u0000\u0000\u0000}~\u0005"+
198 | "(\u0000\u0000~\"\u0001\u0000\u0000\u0000\u007f\u0080\u0005)\u0000\u0000"+
199 | "\u0080$\u0001\u0000\u0000\u0000\u0081\u0082\u0005=\u0000\u0000\u0082&"+
200 | "\u0001\u0000\u0000\u0000\u0083\u0084\u0005<\u0000\u0000\u0084\u0085\u0005"+
201 | "=\u0000\u0000\u0085(\u0001\u0000\u0000\u0000\u0086\u0087\u0005n\u0000"+
202 | "\u0000\u0087\u0088\u0005a\u0000\u0000\u0088\u0089\u0005o\u0000\u0000\u0089"+
203 | "*\u0001\u0000\u0000\u0000\u008a\u008b\u0005e\u0000\u0000\u008b,\u0001"+
204 | "\u0000\u0000\u0000\u008c\u008d\u0005v\u0000\u0000\u008d\u008e\u0005e\u0000"+
205 | "\u0000\u008e\u008f\u0005r\u0000\u0000\u008f\u0090\u0005d\u0000\u0000\u0090"+
206 | "\u0091\u0005a\u0000\u0000\u0091\u0092\u0005d\u0000\u0000\u0092\u0093\u0005"+
207 | "e\u0000\u0000\u0093\u0094\u0005i\u0000\u0000\u0094\u0095\u0005r\u0000"+
208 | "\u0000\u0095\u009c\u0005o\u0000\u0000\u0096\u0097\u0005f\u0000\u0000\u0097"+
209 | "\u0098\u0005a\u0000\u0000\u0098\u0099\u0005l\u0000\u0000\u0099\u009a\u0005"+
210 | "s\u0000\u0000\u009a\u009c\u0005o\u0000\u0000\u009b\u008c\u0001\u0000\u0000"+
211 | "\u0000\u009b\u0096\u0001\u0000\u0000\u0000\u009c.\u0001\u0000\u0000\u0000"+
212 | "\u009d\u009f\u000209\u0000\u009e\u009d\u0001\u0000\u0000\u0000\u009f\u00a0"+
213 | "\u0001\u0000\u0000\u0000\u00a0\u009e\u0001\u0000\u0000\u0000\u00a0\u00a1"+
214 | "\u0001\u0000\u0000\u0000\u00a10\u0001\u0000\u0000\u0000\u00a2\u00a4\u0002"+
215 | "az\u0000\u00a3\u00a2\u0001\u0000\u0000\u0000\u00a4\u00a5\u0001\u0000\u0000"+
216 | "\u0000\u00a5\u00a3\u0001\u0000\u0000\u0000\u00a5\u00a6\u0001\u0000\u0000"+
217 | "\u0000\u00a62\u0001\u0000\u0000\u0000\u00a7\u00ab\u0005\"\u0000\u0000"+
218 | "\u00a8\u00aa\t\u0000\u0000\u0000\u00a9\u00a8\u0001\u0000\u0000\u0000\u00aa"+
219 | "\u00ad\u0001\u0000\u0000\u0000\u00ab\u00ac\u0001\u0000\u0000\u0000\u00ab"+
220 | "\u00a9\u0001\u0000\u0000\u0000\u00ac\u00ae\u0001\u0000\u0000\u0000\u00ad"+
221 | "\u00ab\u0001\u0000\u0000\u0000\u00ae\u00af\u0005\"\u0000\u0000\u00af4"+
222 | "\u0001\u0000\u0000\u0000\u00b0\u00b4\u0005#\u0000\u0000\u00b1\u00b3\t"+
223 | "\u0000\u0000\u0000\u00b2\u00b1\u0001\u0000\u0000\u0000\u00b3\u00b6\u0001"+
224 | "\u0000\u0000\u0000\u00b4\u00b5\u0001\u0000\u0000\u0000\u00b4\u00b2\u0001"+
225 | "\u0000\u0000\u0000\u00b5\u00b7\u0001\u0000\u0000\u0000\u00b6\u00b4\u0001"+
226 | "\u0000\u0000\u0000\u00b7\u00b8\u0005\n\u0000\u0000\u00b8\u00b9\u0001\u0000"+
227 | "\u0000\u0000\u00b9\u00ba\u0006\u001a\u0000\u0000\u00ba6\u0001\u0000\u0000"+
228 | "\u0000\u00bb\u00bc\u0007\u0000\u0000\u0000\u00bc\u00bd\u0001\u0000\u0000"+
229 | "\u0000\u00bd\u00be\u0006\u001b\u0000\u0000\u00be8\u0001\u0000\u0000\u0000"+
230 | "\u0006\u0000\u009b\u00a0\u00a5\u00ab\u00b4\u0001\u0006\u0000\u0000";
231 | public static final ATN _ATN =
232 | new ATNDeserializer().deserialize(_serializedATN.toCharArray());
233 | static {
234 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
235 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
236 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
237 | }
238 | }
239 | }
--------------------------------------------------------------------------------
/src/plp/enquanto/parser/EnquantoListener.java:
--------------------------------------------------------------------------------
1 | // Generated from ./src/plp/enquanto/parser/Enquanto.g4 by ANTLR 4.13.1
2 | package plp.enquanto.parser;
3 | import org.antlr.v4.runtime.tree.ParseTreeListener;
4 |
5 | /**
6 | * This interface defines a complete listener for a parse tree produced by
7 | * {@link EnquantoParser}.
8 | */
9 | public interface EnquantoListener extends ParseTreeListener {
10 | /**
11 | * Enter a parse tree produced by {@link EnquantoParser#programa}.
12 | * @param ctx the parse tree
13 | */
14 | void enterPrograma(EnquantoParser.ProgramaContext ctx);
15 | /**
16 | * Exit a parse tree produced by {@link EnquantoParser#programa}.
17 | * @param ctx the parse tree
18 | */
19 | void exitPrograma(EnquantoParser.ProgramaContext ctx);
20 | /**
21 | * Enter a parse tree produced by {@link EnquantoParser#seqComando}.
22 | * @param ctx the parse tree
23 | */
24 | void enterSeqComando(EnquantoParser.SeqComandoContext ctx);
25 | /**
26 | * Exit a parse tree produced by {@link EnquantoParser#seqComando}.
27 | * @param ctx the parse tree
28 | */
29 | void exitSeqComando(EnquantoParser.SeqComandoContext ctx);
30 | /**
31 | * Enter a parse tree produced by the {@code atribuicao}
32 | * labeled alternative in {@link EnquantoParser#comando}.
33 | * @param ctx the parse tree
34 | */
35 | void enterAtribuicao(EnquantoParser.AtribuicaoContext ctx);
36 | /**
37 | * Exit a parse tree produced by the {@code atribuicao}
38 | * labeled alternative in {@link EnquantoParser#comando}.
39 | * @param ctx the parse tree
40 | */
41 | void exitAtribuicao(EnquantoParser.AtribuicaoContext ctx);
42 | /**
43 | * Enter a parse tree produced by the {@code skip}
44 | * labeled alternative in {@link EnquantoParser#comando}.
45 | * @param ctx the parse tree
46 | */
47 | void enterSkip(EnquantoParser.SkipContext ctx);
48 | /**
49 | * Exit a parse tree produced by the {@code skip}
50 | * labeled alternative in {@link EnquantoParser#comando}.
51 | * @param ctx the parse tree
52 | */
53 | void exitSkip(EnquantoParser.SkipContext ctx);
54 | /**
55 | * Enter a parse tree produced by the {@code se}
56 | * labeled alternative in {@link EnquantoParser#comando}.
57 | * @param ctx the parse tree
58 | */
59 | void enterSe(EnquantoParser.SeContext ctx);
60 | /**
61 | * Exit a parse tree produced by the {@code se}
62 | * labeled alternative in {@link EnquantoParser#comando}.
63 | * @param ctx the parse tree
64 | */
65 | void exitSe(EnquantoParser.SeContext ctx);
66 | /**
67 | * Enter a parse tree produced by the {@code enquanto}
68 | * labeled alternative in {@link EnquantoParser#comando}.
69 | * @param ctx the parse tree
70 | */
71 | void enterEnquanto(EnquantoParser.EnquantoContext ctx);
72 | /**
73 | * Exit a parse tree produced by the {@code enquanto}
74 | * labeled alternative in {@link EnquantoParser#comando}.
75 | * @param ctx the parse tree
76 | */
77 | void exitEnquanto(EnquantoParser.EnquantoContext ctx);
78 | /**
79 | * Enter a parse tree produced by the {@code exiba}
80 | * labeled alternative in {@link EnquantoParser#comando}.
81 | * @param ctx the parse tree
82 | */
83 | void enterExiba(EnquantoParser.ExibaContext ctx);
84 | /**
85 | * Exit a parse tree produced by the {@code exiba}
86 | * labeled alternative in {@link EnquantoParser#comando}.
87 | * @param ctx the parse tree
88 | */
89 | void exitExiba(EnquantoParser.ExibaContext ctx);
90 | /**
91 | * Enter a parse tree produced by the {@code escreva}
92 | * labeled alternative in {@link EnquantoParser#comando}.
93 | * @param ctx the parse tree
94 | */
95 | void enterEscreva(EnquantoParser.EscrevaContext ctx);
96 | /**
97 | * Exit a parse tree produced by the {@code escreva}
98 | * labeled alternative in {@link EnquantoParser#comando}.
99 | * @param ctx the parse tree
100 | */
101 | void exitEscreva(EnquantoParser.EscrevaContext ctx);
102 | /**
103 | * Enter a parse tree produced by the {@code bloco}
104 | * labeled alternative in {@link EnquantoParser#comando}.
105 | * @param ctx the parse tree
106 | */
107 | void enterBloco(EnquantoParser.BlocoContext ctx);
108 | /**
109 | * Exit a parse tree produced by the {@code bloco}
110 | * labeled alternative in {@link EnquantoParser#comando}.
111 | * @param ctx the parse tree
112 | */
113 | void exitBloco(EnquantoParser.BlocoContext ctx);
114 | /**
115 | * Enter a parse tree produced by the {@code leia}
116 | * labeled alternative in {@link EnquantoParser#expressao}.
117 | * @param ctx the parse tree
118 | */
119 | void enterLeia(EnquantoParser.LeiaContext ctx);
120 | /**
121 | * Exit a parse tree produced by the {@code leia}
122 | * labeled alternative in {@link EnquantoParser#expressao}.
123 | * @param ctx the parse tree
124 | */
125 | void exitLeia(EnquantoParser.LeiaContext ctx);
126 | /**
127 | * Enter a parse tree produced by the {@code inteiro}
128 | * labeled alternative in {@link EnquantoParser#expressao}.
129 | * @param ctx the parse tree
130 | */
131 | void enterInteiro(EnquantoParser.InteiroContext ctx);
132 | /**
133 | * Exit a parse tree produced by the {@code inteiro}
134 | * labeled alternative in {@link EnquantoParser#expressao}.
135 | * @param ctx the parse tree
136 | */
137 | void exitInteiro(EnquantoParser.InteiroContext ctx);
138 | /**
139 | * Enter a parse tree produced by the {@code opBin}
140 | * labeled alternative in {@link EnquantoParser#expressao}.
141 | * @param ctx the parse tree
142 | */
143 | void enterOpBin(EnquantoParser.OpBinContext ctx);
144 | /**
145 | * Exit a parse tree produced by the {@code opBin}
146 | * labeled alternative in {@link EnquantoParser#expressao}.
147 | * @param ctx the parse tree
148 | */
149 | void exitOpBin(EnquantoParser.OpBinContext ctx);
150 | /**
151 | * Enter a parse tree produced by the {@code id}
152 | * labeled alternative in {@link EnquantoParser#expressao}.
153 | * @param ctx the parse tree
154 | */
155 | void enterId(EnquantoParser.IdContext ctx);
156 | /**
157 | * Exit a parse tree produced by the {@code id}
158 | * labeled alternative in {@link EnquantoParser#expressao}.
159 | * @param ctx the parse tree
160 | */
161 | void exitId(EnquantoParser.IdContext ctx);
162 | /**
163 | * Enter a parse tree produced by the {@code expPar}
164 | * labeled alternative in {@link EnquantoParser#expressao}.
165 | * @param ctx the parse tree
166 | */
167 | void enterExpPar(EnquantoParser.ExpParContext ctx);
168 | /**
169 | * Exit a parse tree produced by the {@code expPar}
170 | * labeled alternative in {@link EnquantoParser#expressao}.
171 | * @param ctx the parse tree
172 | */
173 | void exitExpPar(EnquantoParser.ExpParContext ctx);
174 | /**
175 | * Enter a parse tree produced by the {@code bool}
176 | * labeled alternative in {@link EnquantoParser#booleano}.
177 | * @param ctx the parse tree
178 | */
179 | void enterBool(EnquantoParser.BoolContext ctx);
180 | /**
181 | * Exit a parse tree produced by the {@code bool}
182 | * labeled alternative in {@link EnquantoParser#booleano}.
183 | * @param ctx the parse tree
184 | */
185 | void exitBool(EnquantoParser.BoolContext ctx);
186 | /**
187 | * Enter a parse tree produced by the {@code eLogico}
188 | * labeled alternative in {@link EnquantoParser#booleano}.
189 | * @param ctx the parse tree
190 | */
191 | void enterELogico(EnquantoParser.ELogicoContext ctx);
192 | /**
193 | * Exit a parse tree produced by the {@code eLogico}
194 | * labeled alternative in {@link EnquantoParser#booleano}.
195 | * @param ctx the parse tree
196 | */
197 | void exitELogico(EnquantoParser.ELogicoContext ctx);
198 | /**
199 | * Enter a parse tree produced by the {@code naoLogico}
200 | * labeled alternative in {@link EnquantoParser#booleano}.
201 | * @param ctx the parse tree
202 | */
203 | void enterNaoLogico(EnquantoParser.NaoLogicoContext ctx);
204 | /**
205 | * Exit a parse tree produced by the {@code naoLogico}
206 | * labeled alternative in {@link EnquantoParser#booleano}.
207 | * @param ctx the parse tree
208 | */
209 | void exitNaoLogico(EnquantoParser.NaoLogicoContext ctx);
210 | /**
211 | * Enter a parse tree produced by the {@code opRel}
212 | * labeled alternative in {@link EnquantoParser#booleano}.
213 | * @param ctx the parse tree
214 | */
215 | void enterOpRel(EnquantoParser.OpRelContext ctx);
216 | /**
217 | * Exit a parse tree produced by the {@code opRel}
218 | * labeled alternative in {@link EnquantoParser#booleano}.
219 | * @param ctx the parse tree
220 | */
221 | void exitOpRel(EnquantoParser.OpRelContext ctx);
222 | /**
223 | * Enter a parse tree produced by the {@code boolPar}
224 | * labeled alternative in {@link EnquantoParser#booleano}.
225 | * @param ctx the parse tree
226 | */
227 | void enterBoolPar(EnquantoParser.BoolParContext ctx);
228 | /**
229 | * Exit a parse tree produced by the {@code boolPar}
230 | * labeled alternative in {@link EnquantoParser#booleano}.
231 | * @param ctx the parse tree
232 | */
233 | void exitBoolPar(EnquantoParser.BoolParContext ctx);
234 | }
--------------------------------------------------------------------------------
/src/plp/enquanto/parser/EnquantoParser.java:
--------------------------------------------------------------------------------
1 | // Generated from ./src/plp/enquanto/parser/Enquanto.g4 by ANTLR 4.13.1
2 | package plp.enquanto.parser;
3 | import org.antlr.v4.runtime.atn.*;
4 | import org.antlr.v4.runtime.dfa.DFA;
5 | import org.antlr.v4.runtime.*;
6 | import org.antlr.v4.runtime.misc.*;
7 | import org.antlr.v4.runtime.tree.*;
8 | import java.util.List;
9 | import java.util.Iterator;
10 | import java.util.ArrayList;
11 |
12 | @SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast", "CheckReturnValue"})
13 | public class EnquantoParser extends Parser {
14 | static { RuntimeMetaData.checkVersion("4.13.1", RuntimeMetaData.VERSION); }
15 |
16 | protected static final DFA[] _decisionToDFA;
17 | protected static final PredictionContextCache _sharedContextCache =
18 | new PredictionContextCache();
19 | public static final int
20 | T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, T__7=8, T__8=9,
21 | T__9=10, T__10=11, T__11=12, T__12=13, T__13=14, T__14=15, T__15=16, T__16=17,
22 | T__17=18, T__18=19, T__19=20, T__20=21, T__21=22, BOOLEANO=23, INT=24,
23 | ID=25, TEXTO=26, Comentario=27, Espaco=28;
24 | public static final int
25 | RULE_programa = 0, RULE_seqComando = 1, RULE_comando = 2, RULE_expressao = 3,
26 | RULE_booleano = 4;
27 | private static String[] makeRuleNames() {
28 | return new String[] {
29 | "programa", "seqComando", "comando", "expressao", "booleano"
30 | };
31 | }
32 | public static final String[] ruleNames = makeRuleNames();
33 |
34 | private static String[] makeLiteralNames() {
35 | return new String[] {
36 | null, "';'", "':='", "'skip'", "'se'", "'entao'", "'senao'", "'enquanto'",
37 | "'faca'", "'exiba'", "'escreva'", "'{'", "'}'", "'leia'", "'*'", "'+'",
38 | "'-'", "'('", "')'", "'='", "'<='", "'nao'", "'e'"
39 | };
40 | }
41 | private static final String[] _LITERAL_NAMES = makeLiteralNames();
42 | private static String[] makeSymbolicNames() {
43 | return new String[] {
44 | null, null, null, null, null, null, null, null, null, null, null, null,
45 | null, null, null, null, null, null, null, null, null, null, null, "BOOLEANO",
46 | "INT", "ID", "TEXTO", "Comentario", "Espaco"
47 | };
48 | }
49 | private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
50 | public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
51 |
52 | /**
53 | * @deprecated Use {@link #VOCABULARY} instead.
54 | */
55 | @Deprecated
56 | public static final String[] tokenNames;
57 | static {
58 | tokenNames = new String[_SYMBOLIC_NAMES.length];
59 | for (int i = 0; i < tokenNames.length; i++) {
60 | tokenNames[i] = VOCABULARY.getLiteralName(i);
61 | if (tokenNames[i] == null) {
62 | tokenNames[i] = VOCABULARY.getSymbolicName(i);
63 | }
64 |
65 | if (tokenNames[i] == null) {
66 | tokenNames[i] = "";
67 | }
68 | }
69 | }
70 |
71 | @Override
72 | @Deprecated
73 | public String[] getTokenNames() {
74 | return tokenNames;
75 | }
76 |
77 | @Override
78 |
79 | public Vocabulary getVocabulary() {
80 | return VOCABULARY;
81 | }
82 |
83 | @Override
84 | public String getGrammarFileName() { return "Enquanto.g4"; }
85 |
86 | @Override
87 | public String[] getRuleNames() { return ruleNames; }
88 |
89 | @Override
90 | public String getSerializedATN() { return _serializedATN; }
91 |
92 | @Override
93 | public ATN getATN() { return _ATN; }
94 |
95 | public EnquantoParser(TokenStream input) {
96 | super(input);
97 | _interp = new ParserATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
98 | }
99 |
100 | @SuppressWarnings("CheckReturnValue")
101 | public static class ProgramaContext extends ParserRuleContext {
102 | public SeqComandoContext seqComando() {
103 | return getRuleContext(SeqComandoContext.class,0);
104 | }
105 | public ProgramaContext(ParserRuleContext parent, int invokingState) {
106 | super(parent, invokingState);
107 | }
108 | @Override public int getRuleIndex() { return RULE_programa; }
109 | @Override
110 | public void enterRule(ParseTreeListener listener) {
111 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterPrograma(this);
112 | }
113 | @Override
114 | public void exitRule(ParseTreeListener listener) {
115 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitPrograma(this);
116 | }
117 | }
118 |
119 | public final ProgramaContext programa() throws RecognitionException {
120 | ProgramaContext _localctx = new ProgramaContext(_ctx, getState());
121 | enterRule(_localctx, 0, RULE_programa);
122 | try {
123 | enterOuterAlt(_localctx, 1);
124 | {
125 | setState(10);
126 | seqComando();
127 | }
128 | }
129 | catch (RecognitionException re) {
130 | _localctx.exception = re;
131 | _errHandler.reportError(this, re);
132 | _errHandler.recover(this, re);
133 | }
134 | finally {
135 | exitRule();
136 | }
137 | return _localctx;
138 | }
139 |
140 | @SuppressWarnings("CheckReturnValue")
141 | public static class SeqComandoContext extends ParserRuleContext {
142 | public List comando() {
143 | return getRuleContexts(ComandoContext.class);
144 | }
145 | public ComandoContext comando(int i) {
146 | return getRuleContext(ComandoContext.class,i);
147 | }
148 | public SeqComandoContext(ParserRuleContext parent, int invokingState) {
149 | super(parent, invokingState);
150 | }
151 | @Override public int getRuleIndex() { return RULE_seqComando; }
152 | @Override
153 | public void enterRule(ParseTreeListener listener) {
154 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterSeqComando(this);
155 | }
156 | @Override
157 | public void exitRule(ParseTreeListener listener) {
158 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitSeqComando(this);
159 | }
160 | }
161 |
162 | public final SeqComandoContext seqComando() throws RecognitionException {
163 | SeqComandoContext _localctx = new SeqComandoContext(_ctx, getState());
164 | enterRule(_localctx, 2, RULE_seqComando);
165 | int _la;
166 | try {
167 | enterOuterAlt(_localctx, 1);
168 | {
169 | setState(12);
170 | comando();
171 | setState(17);
172 | _errHandler.sync(this);
173 | _la = _input.LA(1);
174 | while (_la==T__0) {
175 | {
176 | {
177 | setState(13);
178 | match(T__0);
179 | setState(14);
180 | comando();
181 | }
182 | }
183 | setState(19);
184 | _errHandler.sync(this);
185 | _la = _input.LA(1);
186 | }
187 | }
188 | }
189 | catch (RecognitionException re) {
190 | _localctx.exception = re;
191 | _errHandler.reportError(this, re);
192 | _errHandler.recover(this, re);
193 | }
194 | finally {
195 | exitRule();
196 | }
197 | return _localctx;
198 | }
199 |
200 | @SuppressWarnings("CheckReturnValue")
201 | public static class ComandoContext extends ParserRuleContext {
202 | public ComandoContext(ParserRuleContext parent, int invokingState) {
203 | super(parent, invokingState);
204 | }
205 | @Override public int getRuleIndex() { return RULE_comando; }
206 |
207 | public ComandoContext() { }
208 | public void copyFrom(ComandoContext ctx) {
209 | super.copyFrom(ctx);
210 | }
211 | }
212 | @SuppressWarnings("CheckReturnValue")
213 | public static class AtribuicaoContext extends ComandoContext {
214 | public TerminalNode ID() { return getToken(EnquantoParser.ID, 0); }
215 | public ExpressaoContext expressao() {
216 | return getRuleContext(ExpressaoContext.class,0);
217 | }
218 | public AtribuicaoContext(ComandoContext ctx) { copyFrom(ctx); }
219 | @Override
220 | public void enterRule(ParseTreeListener listener) {
221 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterAtribuicao(this);
222 | }
223 | @Override
224 | public void exitRule(ParseTreeListener listener) {
225 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitAtribuicao(this);
226 | }
227 | }
228 | @SuppressWarnings("CheckReturnValue")
229 | public static class SeContext extends ComandoContext {
230 | public BooleanoContext booleano() {
231 | return getRuleContext(BooleanoContext.class,0);
232 | }
233 | public List comando() {
234 | return getRuleContexts(ComandoContext.class);
235 | }
236 | public ComandoContext comando(int i) {
237 | return getRuleContext(ComandoContext.class,i);
238 | }
239 | public SeContext(ComandoContext ctx) { copyFrom(ctx); }
240 | @Override
241 | public void enterRule(ParseTreeListener listener) {
242 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterSe(this);
243 | }
244 | @Override
245 | public void exitRule(ParseTreeListener listener) {
246 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitSe(this);
247 | }
248 | }
249 | @SuppressWarnings("CheckReturnValue")
250 | public static class ExibaContext extends ComandoContext {
251 | public TerminalNode TEXTO() { return getToken(EnquantoParser.TEXTO, 0); }
252 | public ExibaContext(ComandoContext ctx) { copyFrom(ctx); }
253 | @Override
254 | public void enterRule(ParseTreeListener listener) {
255 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterExiba(this);
256 | }
257 | @Override
258 | public void exitRule(ParseTreeListener listener) {
259 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitExiba(this);
260 | }
261 | }
262 | @SuppressWarnings("CheckReturnValue")
263 | public static class EnquantoContext extends ComandoContext {
264 | public BooleanoContext booleano() {
265 | return getRuleContext(BooleanoContext.class,0);
266 | }
267 | public ComandoContext comando() {
268 | return getRuleContext(ComandoContext.class,0);
269 | }
270 | public EnquantoContext(ComandoContext ctx) { copyFrom(ctx); }
271 | @Override
272 | public void enterRule(ParseTreeListener listener) {
273 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterEnquanto(this);
274 | }
275 | @Override
276 | public void exitRule(ParseTreeListener listener) {
277 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitEnquanto(this);
278 | }
279 | }
280 | @SuppressWarnings("CheckReturnValue")
281 | public static class BlocoContext extends ComandoContext {
282 | public SeqComandoContext seqComando() {
283 | return getRuleContext(SeqComandoContext.class,0);
284 | }
285 | public BlocoContext(ComandoContext ctx) { copyFrom(ctx); }
286 | @Override
287 | public void enterRule(ParseTreeListener listener) {
288 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterBloco(this);
289 | }
290 | @Override
291 | public void exitRule(ParseTreeListener listener) {
292 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitBloco(this);
293 | }
294 | }
295 | @SuppressWarnings("CheckReturnValue")
296 | public static class EscrevaContext extends ComandoContext {
297 | public ExpressaoContext expressao() {
298 | return getRuleContext(ExpressaoContext.class,0);
299 | }
300 | public EscrevaContext(ComandoContext ctx) { copyFrom(ctx); }
301 | @Override
302 | public void enterRule(ParseTreeListener listener) {
303 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterEscreva(this);
304 | }
305 | @Override
306 | public void exitRule(ParseTreeListener listener) {
307 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitEscreva(this);
308 | }
309 | }
310 | @SuppressWarnings("CheckReturnValue")
311 | public static class SkipContext extends ComandoContext {
312 | public SkipContext(ComandoContext ctx) { copyFrom(ctx); }
313 | @Override
314 | public void enterRule(ParseTreeListener listener) {
315 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterSkip(this);
316 | }
317 | @Override
318 | public void exitRule(ParseTreeListener listener) {
319 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitSkip(this);
320 | }
321 | }
322 |
323 | public final ComandoContext comando() throws RecognitionException {
324 | ComandoContext _localctx = new ComandoContext(_ctx, getState());
325 | enterRule(_localctx, 4, RULE_comando);
326 | try {
327 | setState(44);
328 | _errHandler.sync(this);
329 | switch (_input.LA(1)) {
330 | case ID:
331 | _localctx = new AtribuicaoContext(_localctx);
332 | enterOuterAlt(_localctx, 1);
333 | {
334 | setState(20);
335 | match(ID);
336 | setState(21);
337 | match(T__1);
338 | setState(22);
339 | expressao(0);
340 | }
341 | break;
342 | case T__2:
343 | _localctx = new SkipContext(_localctx);
344 | enterOuterAlt(_localctx, 2);
345 | {
346 | setState(23);
347 | match(T__2);
348 | }
349 | break;
350 | case T__3:
351 | _localctx = new SeContext(_localctx);
352 | enterOuterAlt(_localctx, 3);
353 | {
354 | setState(24);
355 | match(T__3);
356 | setState(25);
357 | booleano(0);
358 | setState(26);
359 | match(T__4);
360 | setState(27);
361 | comando();
362 | setState(28);
363 | match(T__5);
364 | setState(29);
365 | comando();
366 | }
367 | break;
368 | case T__6:
369 | _localctx = new EnquantoContext(_localctx);
370 | enterOuterAlt(_localctx, 4);
371 | {
372 | setState(31);
373 | match(T__6);
374 | setState(32);
375 | booleano(0);
376 | setState(33);
377 | match(T__7);
378 | setState(34);
379 | comando();
380 | }
381 | break;
382 | case T__8:
383 | _localctx = new ExibaContext(_localctx);
384 | enterOuterAlt(_localctx, 5);
385 | {
386 | setState(36);
387 | match(T__8);
388 | setState(37);
389 | match(TEXTO);
390 | }
391 | break;
392 | case T__9:
393 | _localctx = new EscrevaContext(_localctx);
394 | enterOuterAlt(_localctx, 6);
395 | {
396 | setState(38);
397 | match(T__9);
398 | setState(39);
399 | expressao(0);
400 | }
401 | break;
402 | case T__10:
403 | _localctx = new BlocoContext(_localctx);
404 | enterOuterAlt(_localctx, 7);
405 | {
406 | setState(40);
407 | match(T__10);
408 | setState(41);
409 | seqComando();
410 | setState(42);
411 | match(T__11);
412 | }
413 | break;
414 | default:
415 | throw new NoViableAltException(this);
416 | }
417 | }
418 | catch (RecognitionException re) {
419 | _localctx.exception = re;
420 | _errHandler.reportError(this, re);
421 | _errHandler.recover(this, re);
422 | }
423 | finally {
424 | exitRule();
425 | }
426 | return _localctx;
427 | }
428 |
429 | @SuppressWarnings("CheckReturnValue")
430 | public static class ExpressaoContext extends ParserRuleContext {
431 | public ExpressaoContext(ParserRuleContext parent, int invokingState) {
432 | super(parent, invokingState);
433 | }
434 | @Override public int getRuleIndex() { return RULE_expressao; }
435 |
436 | public ExpressaoContext() { }
437 | public void copyFrom(ExpressaoContext ctx) {
438 | super.copyFrom(ctx);
439 | }
440 | }
441 | @SuppressWarnings("CheckReturnValue")
442 | public static class LeiaContext extends ExpressaoContext {
443 | public LeiaContext(ExpressaoContext ctx) { copyFrom(ctx); }
444 | @Override
445 | public void enterRule(ParseTreeListener listener) {
446 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterLeia(this);
447 | }
448 | @Override
449 | public void exitRule(ParseTreeListener listener) {
450 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitLeia(this);
451 | }
452 | }
453 | @SuppressWarnings("CheckReturnValue")
454 | public static class InteiroContext extends ExpressaoContext {
455 | public TerminalNode INT() { return getToken(EnquantoParser.INT, 0); }
456 | public InteiroContext(ExpressaoContext ctx) { copyFrom(ctx); }
457 | @Override
458 | public void enterRule(ParseTreeListener listener) {
459 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterInteiro(this);
460 | }
461 | @Override
462 | public void exitRule(ParseTreeListener listener) {
463 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitInteiro(this);
464 | }
465 | }
466 | @SuppressWarnings("CheckReturnValue")
467 | public static class OpBinContext extends ExpressaoContext {
468 | public List expressao() {
469 | return getRuleContexts(ExpressaoContext.class);
470 | }
471 | public ExpressaoContext expressao(int i) {
472 | return getRuleContext(ExpressaoContext.class,i);
473 | }
474 | public OpBinContext(ExpressaoContext ctx) { copyFrom(ctx); }
475 | @Override
476 | public void enterRule(ParseTreeListener listener) {
477 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterOpBin(this);
478 | }
479 | @Override
480 | public void exitRule(ParseTreeListener listener) {
481 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitOpBin(this);
482 | }
483 | }
484 | @SuppressWarnings("CheckReturnValue")
485 | public static class IdContext extends ExpressaoContext {
486 | public TerminalNode ID() { return getToken(EnquantoParser.ID, 0); }
487 | public IdContext(ExpressaoContext ctx) { copyFrom(ctx); }
488 | @Override
489 | public void enterRule(ParseTreeListener listener) {
490 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterId(this);
491 | }
492 | @Override
493 | public void exitRule(ParseTreeListener listener) {
494 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitId(this);
495 | }
496 | }
497 | @SuppressWarnings("CheckReturnValue")
498 | public static class ExpParContext extends ExpressaoContext {
499 | public ExpressaoContext expressao() {
500 | return getRuleContext(ExpressaoContext.class,0);
501 | }
502 | public ExpParContext(ExpressaoContext ctx) { copyFrom(ctx); }
503 | @Override
504 | public void enterRule(ParseTreeListener listener) {
505 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterExpPar(this);
506 | }
507 | @Override
508 | public void exitRule(ParseTreeListener listener) {
509 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitExpPar(this);
510 | }
511 | }
512 |
513 | public final ExpressaoContext expressao() throws RecognitionException {
514 | return expressao(0);
515 | }
516 |
517 | private ExpressaoContext expressao(int _p) throws RecognitionException {
518 | ParserRuleContext _parentctx = _ctx;
519 | int _parentState = getState();
520 | ExpressaoContext _localctx = new ExpressaoContext(_ctx, _parentState);
521 | ExpressaoContext _prevctx = _localctx;
522 | int _startState = 6;
523 | enterRecursionRule(_localctx, 6, RULE_expressao, _p);
524 | int _la;
525 | try {
526 | int _alt;
527 | enterOuterAlt(_localctx, 1);
528 | {
529 | setState(54);
530 | _errHandler.sync(this);
531 | switch (_input.LA(1)) {
532 | case INT:
533 | {
534 | _localctx = new InteiroContext(_localctx);
535 | _ctx = _localctx;
536 | _prevctx = _localctx;
537 |
538 | setState(47);
539 | match(INT);
540 | }
541 | break;
542 | case T__12:
543 | {
544 | _localctx = new LeiaContext(_localctx);
545 | _ctx = _localctx;
546 | _prevctx = _localctx;
547 | setState(48);
548 | match(T__12);
549 | }
550 | break;
551 | case ID:
552 | {
553 | _localctx = new IdContext(_localctx);
554 | _ctx = _localctx;
555 | _prevctx = _localctx;
556 | setState(49);
557 | match(ID);
558 | }
559 | break;
560 | case T__16:
561 | {
562 | _localctx = new ExpParContext(_localctx);
563 | _ctx = _localctx;
564 | _prevctx = _localctx;
565 | setState(50);
566 | match(T__16);
567 | setState(51);
568 | expressao(0);
569 | setState(52);
570 | match(T__17);
571 | }
572 | break;
573 | default:
574 | throw new NoViableAltException(this);
575 | }
576 | _ctx.stop = _input.LT(-1);
577 | setState(64);
578 | _errHandler.sync(this);
579 | _alt = getInterpreter().adaptivePredict(_input,4,_ctx);
580 | while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
581 | if ( _alt==1 ) {
582 | if ( _parseListeners!=null ) triggerExitRuleEvent();
583 | _prevctx = _localctx;
584 | {
585 | setState(62);
586 | _errHandler.sync(this);
587 | switch ( getInterpreter().adaptivePredict(_input,3,_ctx) ) {
588 | case 1:
589 | {
590 | _localctx = new OpBinContext(new ExpressaoContext(_parentctx, _parentState));
591 | pushNewRecursionContext(_localctx, _startState, RULE_expressao);
592 | setState(56);
593 | if (!(precpred(_ctx, 3))) throw new FailedPredicateException(this, "precpred(_ctx, 3)");
594 | setState(57);
595 | match(T__13);
596 | setState(58);
597 | expressao(4);
598 | }
599 | break;
600 | case 2:
601 | {
602 | _localctx = new OpBinContext(new ExpressaoContext(_parentctx, _parentState));
603 | pushNewRecursionContext(_localctx, _startState, RULE_expressao);
604 | setState(59);
605 | if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)");
606 | setState(60);
607 | _la = _input.LA(1);
608 | if ( !(_la==T__14 || _la==T__15) ) {
609 | _errHandler.recoverInline(this);
610 | }
611 | else {
612 | if ( _input.LA(1)==Token.EOF ) matchedEOF = true;
613 | _errHandler.reportMatch(this);
614 | consume();
615 | }
616 | setState(61);
617 | expressao(3);
618 | }
619 | break;
620 | }
621 | }
622 | }
623 | setState(66);
624 | _errHandler.sync(this);
625 | _alt = getInterpreter().adaptivePredict(_input,4,_ctx);
626 | }
627 | }
628 | }
629 | catch (RecognitionException re) {
630 | _localctx.exception = re;
631 | _errHandler.reportError(this, re);
632 | _errHandler.recover(this, re);
633 | }
634 | finally {
635 | unrollRecursionContexts(_parentctx);
636 | }
637 | return _localctx;
638 | }
639 |
640 | @SuppressWarnings("CheckReturnValue")
641 | public static class BooleanoContext extends ParserRuleContext {
642 | public BooleanoContext(ParserRuleContext parent, int invokingState) {
643 | super(parent, invokingState);
644 | }
645 | @Override public int getRuleIndex() { return RULE_booleano; }
646 |
647 | public BooleanoContext() { }
648 | public void copyFrom(BooleanoContext ctx) {
649 | super.copyFrom(ctx);
650 | }
651 | }
652 | @SuppressWarnings("CheckReturnValue")
653 | public static class BoolContext extends BooleanoContext {
654 | public TerminalNode BOOLEANO() { return getToken(EnquantoParser.BOOLEANO, 0); }
655 | public BoolContext(BooleanoContext ctx) { copyFrom(ctx); }
656 | @Override
657 | public void enterRule(ParseTreeListener listener) {
658 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterBool(this);
659 | }
660 | @Override
661 | public void exitRule(ParseTreeListener listener) {
662 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitBool(this);
663 | }
664 | }
665 | @SuppressWarnings("CheckReturnValue")
666 | public static class ELogicoContext extends BooleanoContext {
667 | public List booleano() {
668 | return getRuleContexts(BooleanoContext.class);
669 | }
670 | public BooleanoContext booleano(int i) {
671 | return getRuleContext(BooleanoContext.class,i);
672 | }
673 | public ELogicoContext(BooleanoContext ctx) { copyFrom(ctx); }
674 | @Override
675 | public void enterRule(ParseTreeListener listener) {
676 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterELogico(this);
677 | }
678 | @Override
679 | public void exitRule(ParseTreeListener listener) {
680 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitELogico(this);
681 | }
682 | }
683 | @SuppressWarnings("CheckReturnValue")
684 | public static class NaoLogicoContext extends BooleanoContext {
685 | public BooleanoContext booleano() {
686 | return getRuleContext(BooleanoContext.class,0);
687 | }
688 | public NaoLogicoContext(BooleanoContext ctx) { copyFrom(ctx); }
689 | @Override
690 | public void enterRule(ParseTreeListener listener) {
691 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterNaoLogico(this);
692 | }
693 | @Override
694 | public void exitRule(ParseTreeListener listener) {
695 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitNaoLogico(this);
696 | }
697 | }
698 | @SuppressWarnings("CheckReturnValue")
699 | public static class OpRelContext extends BooleanoContext {
700 | public List expressao() {
701 | return getRuleContexts(ExpressaoContext.class);
702 | }
703 | public ExpressaoContext expressao(int i) {
704 | return getRuleContext(ExpressaoContext.class,i);
705 | }
706 | public OpRelContext(BooleanoContext ctx) { copyFrom(ctx); }
707 | @Override
708 | public void enterRule(ParseTreeListener listener) {
709 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterOpRel(this);
710 | }
711 | @Override
712 | public void exitRule(ParseTreeListener listener) {
713 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitOpRel(this);
714 | }
715 | }
716 | @SuppressWarnings("CheckReturnValue")
717 | public static class BoolParContext extends BooleanoContext {
718 | public BooleanoContext booleano() {
719 | return getRuleContext(BooleanoContext.class,0);
720 | }
721 | public BoolParContext(BooleanoContext ctx) { copyFrom(ctx); }
722 | @Override
723 | public void enterRule(ParseTreeListener listener) {
724 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).enterBoolPar(this);
725 | }
726 | @Override
727 | public void exitRule(ParseTreeListener listener) {
728 | if ( listener instanceof EnquantoListener ) ((EnquantoListener)listener).exitBoolPar(this);
729 | }
730 | }
731 |
732 | public final BooleanoContext booleano() throws RecognitionException {
733 | return booleano(0);
734 | }
735 |
736 | private BooleanoContext booleano(int _p) throws RecognitionException {
737 | ParserRuleContext _parentctx = _ctx;
738 | int _parentState = getState();
739 | BooleanoContext _localctx = new BooleanoContext(_ctx, _parentState);
740 | BooleanoContext _prevctx = _localctx;
741 | int _startState = 8;
742 | enterRecursionRule(_localctx, 8, RULE_booleano, _p);
743 | try {
744 | int _alt;
745 | enterOuterAlt(_localctx, 1);
746 | {
747 | setState(83);
748 | _errHandler.sync(this);
749 | switch ( getInterpreter().adaptivePredict(_input,5,_ctx) ) {
750 | case 1:
751 | {
752 | _localctx = new BoolContext(_localctx);
753 | _ctx = _localctx;
754 | _prevctx = _localctx;
755 |
756 | setState(68);
757 | match(BOOLEANO);
758 | }
759 | break;
760 | case 2:
761 | {
762 | _localctx = new OpRelContext(_localctx);
763 | _ctx = _localctx;
764 | _prevctx = _localctx;
765 | setState(69);
766 | expressao(0);
767 | setState(70);
768 | match(T__18);
769 | setState(71);
770 | expressao(0);
771 | }
772 | break;
773 | case 3:
774 | {
775 | _localctx = new OpRelContext(_localctx);
776 | _ctx = _localctx;
777 | _prevctx = _localctx;
778 | setState(73);
779 | expressao(0);
780 | setState(74);
781 | match(T__19);
782 | setState(75);
783 | expressao(0);
784 | }
785 | break;
786 | case 4:
787 | {
788 | _localctx = new NaoLogicoContext(_localctx);
789 | _ctx = _localctx;
790 | _prevctx = _localctx;
791 | setState(77);
792 | match(T__20);
793 | setState(78);
794 | booleano(3);
795 | }
796 | break;
797 | case 5:
798 | {
799 | _localctx = new BoolParContext(_localctx);
800 | _ctx = _localctx;
801 | _prevctx = _localctx;
802 | setState(79);
803 | match(T__16);
804 | setState(80);
805 | booleano(0);
806 | setState(81);
807 | match(T__17);
808 | }
809 | break;
810 | }
811 | _ctx.stop = _input.LT(-1);
812 | setState(90);
813 | _errHandler.sync(this);
814 | _alt = getInterpreter().adaptivePredict(_input,6,_ctx);
815 | while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
816 | if ( _alt==1 ) {
817 | if ( _parseListeners!=null ) triggerExitRuleEvent();
818 | _prevctx = _localctx;
819 | {
820 | {
821 | _localctx = new ELogicoContext(new BooleanoContext(_parentctx, _parentState));
822 | pushNewRecursionContext(_localctx, _startState, RULE_booleano);
823 | setState(85);
824 | if (!(precpred(_ctx, 2))) throw new FailedPredicateException(this, "precpred(_ctx, 2)");
825 | setState(86);
826 | match(T__21);
827 | setState(87);
828 | booleano(3);
829 | }
830 | }
831 | }
832 | setState(92);
833 | _errHandler.sync(this);
834 | _alt = getInterpreter().adaptivePredict(_input,6,_ctx);
835 | }
836 | }
837 | }
838 | catch (RecognitionException re) {
839 | _localctx.exception = re;
840 | _errHandler.reportError(this, re);
841 | _errHandler.recover(this, re);
842 | }
843 | finally {
844 | unrollRecursionContexts(_parentctx);
845 | }
846 | return _localctx;
847 | }
848 |
849 | public boolean sempred(RuleContext _localctx, int ruleIndex, int predIndex) {
850 | switch (ruleIndex) {
851 | case 3:
852 | return expressao_sempred((ExpressaoContext)_localctx, predIndex);
853 | case 4:
854 | return booleano_sempred((BooleanoContext)_localctx, predIndex);
855 | }
856 | return true;
857 | }
858 | private boolean expressao_sempred(ExpressaoContext _localctx, int predIndex) {
859 | switch (predIndex) {
860 | case 0:
861 | return precpred(_ctx, 3);
862 | case 1:
863 | return precpred(_ctx, 2);
864 | }
865 | return true;
866 | }
867 | private boolean booleano_sempred(BooleanoContext _localctx, int predIndex) {
868 | switch (predIndex) {
869 | case 2:
870 | return precpred(_ctx, 2);
871 | }
872 | return true;
873 | }
874 |
875 | public static final String _serializedATN =
876 | "\u0004\u0001\u001c^\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
877 | "\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004\u0007\u0004\u0001"+
878 | "\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0005\u0001\u0010"+
879 | "\b\u0001\n\u0001\f\u0001\u0013\t\u0001\u0001\u0002\u0001\u0002\u0001\u0002"+
880 | "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002"+
881 | "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002"+
882 | "\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002"+
883 | "\u0001\u0002\u0001\u0002\u0001\u0002\u0003\u0002-\b\u0002\u0001\u0003"+
884 | "\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+
885 | "\u0001\u0003\u0003\u00037\b\u0003\u0001\u0003\u0001\u0003\u0001\u0003"+
886 | "\u0001\u0003\u0001\u0003\u0001\u0003\u0005\u0003?\b\u0003\n\u0003\f\u0003"+
887 | "B\t\u0003\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+
888 | "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004"+
889 | "\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0003\u0004"+
890 | "T\b\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0005\u0004Y\b\u0004\n\u0004"+
891 | "\f\u0004\\\t\u0004\u0001\u0004\u0000\u0002\u0006\b\u0005\u0000\u0002\u0004"+
892 | "\u0006\b\u0000\u0001\u0001\u0000\u000f\u0010i\u0000\n\u0001\u0000\u0000"+
893 | "\u0000\u0002\f\u0001\u0000\u0000\u0000\u0004,\u0001\u0000\u0000\u0000"+
894 | "\u00066\u0001\u0000\u0000\u0000\bS\u0001\u0000\u0000\u0000\n\u000b\u0003"+
895 | "\u0002\u0001\u0000\u000b\u0001\u0001\u0000\u0000\u0000\f\u0011\u0003\u0004"+
896 | "\u0002\u0000\r\u000e\u0005\u0001\u0000\u0000\u000e\u0010\u0003\u0004\u0002"+
897 | "\u0000\u000f\r\u0001\u0000\u0000\u0000\u0010\u0013\u0001\u0000\u0000\u0000"+
898 | "\u0011\u000f\u0001\u0000\u0000\u0000\u0011\u0012\u0001\u0000\u0000\u0000"+
899 | "\u0012\u0003\u0001\u0000\u0000\u0000\u0013\u0011\u0001\u0000\u0000\u0000"+
900 | "\u0014\u0015\u0005\u0019\u0000\u0000\u0015\u0016\u0005\u0002\u0000\u0000"+
901 | "\u0016-\u0003\u0006\u0003\u0000\u0017-\u0005\u0003\u0000\u0000\u0018\u0019"+
902 | "\u0005\u0004\u0000\u0000\u0019\u001a\u0003\b\u0004\u0000\u001a\u001b\u0005"+
903 | "\u0005\u0000\u0000\u001b\u001c\u0003\u0004\u0002\u0000\u001c\u001d\u0005"+
904 | "\u0006\u0000\u0000\u001d\u001e\u0003\u0004\u0002\u0000\u001e-\u0001\u0000"+
905 | "\u0000\u0000\u001f \u0005\u0007\u0000\u0000 !\u0003\b\u0004\u0000!\"\u0005"+
906 | "\b\u0000\u0000\"#\u0003\u0004\u0002\u0000#-\u0001\u0000\u0000\u0000$%"+
907 | "\u0005\t\u0000\u0000%-\u0005\u001a\u0000\u0000&\'\u0005\n\u0000\u0000"+
908 | "\'-\u0003\u0006\u0003\u0000()\u0005\u000b\u0000\u0000)*\u0003\u0002\u0001"+
909 | "\u0000*+\u0005\f\u0000\u0000+-\u0001\u0000\u0000\u0000,\u0014\u0001\u0000"+
910 | "\u0000\u0000,\u0017\u0001\u0000\u0000\u0000,\u0018\u0001\u0000\u0000\u0000"+
911 | ",\u001f\u0001\u0000\u0000\u0000,$\u0001\u0000\u0000\u0000,&\u0001\u0000"+
912 | "\u0000\u0000,(\u0001\u0000\u0000\u0000-\u0005\u0001\u0000\u0000\u0000"+
913 | "./\u0006\u0003\uffff\uffff\u0000/7\u0005\u0018\u0000\u000007\u0005\r\u0000"+
914 | "\u000017\u0005\u0019\u0000\u000023\u0005\u0011\u0000\u000034\u0003\u0006"+
915 | "\u0003\u000045\u0005\u0012\u0000\u000057\u0001\u0000\u0000\u00006.\u0001"+
916 | "\u0000\u0000\u000060\u0001\u0000\u0000\u000061\u0001\u0000\u0000\u0000"+
917 | "62\u0001\u0000\u0000\u00007@\u0001\u0000\u0000\u000089\n\u0003\u0000\u0000"+
918 | "9:\u0005\u000e\u0000\u0000:?\u0003\u0006\u0003\u0004;<\n\u0002\u0000\u0000"+
919 | "<=\u0007\u0000\u0000\u0000=?\u0003\u0006\u0003\u0003>8\u0001\u0000\u0000"+
920 | "\u0000>;\u0001\u0000\u0000\u0000?B\u0001\u0000\u0000\u0000@>\u0001\u0000"+
921 | "\u0000\u0000@A\u0001\u0000\u0000\u0000A\u0007\u0001\u0000\u0000\u0000"+
922 | "B@\u0001\u0000\u0000\u0000CD\u0006\u0004\uffff\uffff\u0000DT\u0005\u0017"+
923 | "\u0000\u0000EF\u0003\u0006\u0003\u0000FG\u0005\u0013\u0000\u0000GH\u0003"+
924 | "\u0006\u0003\u0000HT\u0001\u0000\u0000\u0000IJ\u0003\u0006\u0003\u0000"+
925 | "JK\u0005\u0014\u0000\u0000KL\u0003\u0006\u0003\u0000LT\u0001\u0000\u0000"+
926 | "\u0000MN\u0005\u0015\u0000\u0000NT\u0003\b\u0004\u0003OP\u0005\u0011\u0000"+
927 | "\u0000PQ\u0003\b\u0004\u0000QR\u0005\u0012\u0000\u0000RT\u0001\u0000\u0000"+
928 | "\u0000SC\u0001\u0000\u0000\u0000SE\u0001\u0000\u0000\u0000SI\u0001\u0000"+
929 | "\u0000\u0000SM\u0001\u0000\u0000\u0000SO\u0001\u0000\u0000\u0000TZ\u0001"+
930 | "\u0000\u0000\u0000UV\n\u0002\u0000\u0000VW\u0005\u0016\u0000\u0000WY\u0003"+
931 | "\b\u0004\u0003XU\u0001\u0000\u0000\u0000Y\\\u0001\u0000\u0000\u0000ZX"+
932 | "\u0001\u0000\u0000\u0000Z[\u0001\u0000\u0000\u0000[\t\u0001\u0000\u0000"+
933 | "\u0000\\Z\u0001\u0000\u0000\u0000\u0007\u0011,6>@SZ";
934 | public static final ATN _ATN =
935 | new ATNDeserializer().deserialize(_serializedATN.toCharArray());
936 | static {
937 | _decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
938 | for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
939 | _decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
940 | }
941 | }
942 | }
--------------------------------------------------------------------------------
/teste.while:
--------------------------------------------------------------------------------
1 | a := 10;
2 | escreva a;
3 | exiba "as"
--------------------------------------------------------------------------------
/testes/escolha1.while:
--------------------------------------------------------------------------------
1 | x = leia
2 | escolha x
3 | caso 1 : exiba "um"
4 | caso 2 : exiba "dois"
5 | outro : exiba "outro numero"
6 |
--------------------------------------------------------------------------------
/testes/escolha2.while:
--------------------------------------------------------------------------------
1 | x = leia
2 | escolha x
3 | caso 1 : exiba "um"
4 | caso 2 : exiba "dois"
5 | caso 1 : exiba "one"
6 | outro : exiba "outro numero"
7 |
--------------------------------------------------------------------------------
/testes/escolha3.while:
--------------------------------------------------------------------------------
1 | x = leia
2 | escolha x + 1
3 | caso 1 : exiba "um"
4 | caso 2 : exiba "dois"
5 | outro : exiba "outro numero"
6 |
--------------------------------------------------------------------------------
/testes/funcao1.while:
--------------------------------------------------------------------------------
1 | soma(a,b) = a + b ;
2 |
3 | escreva soma(2,3)
4 |
--------------------------------------------------------------------------------
/testes/funcao2.while:
--------------------------------------------------------------------------------
1 | soma(a,b) = a + b ;
2 |
3 | soma3(a,b,c) = soma(a, soma(b, c));
4 |
5 | escreva soma3(2,3,4)
6 |
--------------------------------------------------------------------------------
/testes/funcao3.while:
--------------------------------------------------------------------------------
1 | x = 10;
2 |
3 | soma(x, y) = x + y;
4 |
5 | escreva soma(17, x + 1)
6 |
--------------------------------------------------------------------------------
/testes/funcao4.while:
--------------------------------------------------------------------------------
1 | x := 10;
2 | f(a, b) = a + b + g(a, b);
3 | g(x, y) = x * y;
4 |
5 | escreva f(2, 3)
6 |
--------------------------------------------------------------------------------
/testes/para1.while:
--------------------------------------------------------------------------------
1 | n := 10;
2 | para i de 1 ate n faca {
3 | escreva i;
4 | }
5 |
--------------------------------------------------------------------------------
/testes/para2.while:
--------------------------------------------------------------------------------
1 | n := 1;
2 | para i de 1 ate 100 passo n faca {
3 | escreva i;
4 | n := n + 1
5 | }
6 |
--------------------------------------------------------------------------------
/testes/para3.while:
--------------------------------------------------------------------------------
1 | n := 100;
2 | para i de 1 ate n faca {
3 | escreva i;
4 | n := n / 2
5 | }
6 |
--------------------------------------------------------------------------------
/testes/se1.while:
--------------------------------------------------------------------------------
1 | nota := leia;
2 | se nota>=6 entao
3 | exiba "Aprovado"
4 | senaose nota >= 2 entao
5 | exiba "Recuperacao"
6 | senao
7 | exiba "Reprovado"
8 |
--------------------------------------------------------------------------------
/testes/se2.while:
--------------------------------------------------------------------------------
1 | n := leia;
2 | n = n - n / 5 * 5;
3 | se n=0 então exiba "zero"
4 | senaose n = 1 entao exiba "um"
5 | senaose n = 2 entao exiba "dois"
6 | senaose n = 3 entao exiba "tres"
7 | senao exiba "quatro
8 |
--------------------------------------------------------------------------------
/testes/se3.while:
--------------------------------------------------------------------------------
1 | n := 10;
2 | se n < 20 então exiba "menor do que vinte"
3 | senaose n < 15 entao exiba "menor do que quinze"
4 | senao exiba "nao sei"
5 |
--------------------------------------------------------------------------------
/while:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | java -Xmx1879m -jar while.jar $1
--------------------------------------------------------------------------------
/while.bat:
--------------------------------------------------------------------------------
1 | @echo off
2 | java -jar while.jar %1
--------------------------------------------------------------------------------
/while.jar:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/lrlucena/while/92824b20e4f3125b26cff4c7cc180ceaab11080e/while.jar
--------------------------------------------------------------------------------