mirror of
https://github.com/404Simon/WhileLoopInterpreter.git
synced 2024-12-27 08:38:03 +00:00
add while support
This commit is contained in:
parent
25b4ab9aea
commit
325babac5c
124
.idea/uiDesigner.xml
generated
Normal file
124
.idea/uiDesigner.xml
generated
Normal file
@ -0,0 +1,124 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project version="4">
|
||||
<component name="Palette2">
|
||||
<group name="Swing">
|
||||
<item class="com.intellij.uiDesigner.HSpacer" tooltip-text="Horizontal Spacer" icon="/com/intellij/uiDesigner/icons/hspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="1" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="com.intellij.uiDesigner.VSpacer" tooltip-text="Vertical Spacer" icon="/com/intellij/uiDesigner/icons/vspacer.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="1" anchor="0" fill="2" />
|
||||
</item>
|
||||
<item class="javax.swing.JPanel" icon="/com/intellij/uiDesigner/icons/panel.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollPane" icon="/com/intellij/uiDesigner/icons/scrollPane.svg" removable="false" auto-create-binding="false" can-attach-label="true">
|
||||
<default-constraints vsize-policy="7" hsize-policy="7" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JButton" icon="/com/intellij/uiDesigner/icons/button.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="0" fill="1" />
|
||||
<initial-values>
|
||||
<property name="text" value="Button" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JRadioButton" icon="/com/intellij/uiDesigner/icons/radioButton.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="RadioButton" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JCheckBox" icon="/com/intellij/uiDesigner/icons/checkBox.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="3" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="CheckBox" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JLabel" icon="/com/intellij/uiDesigner/icons/label.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="8" fill="0" />
|
||||
<initial-values>
|
||||
<property name="text" value="Label" />
|
||||
</initial-values>
|
||||
</item>
|
||||
<item class="javax.swing.JTextField" icon="/com/intellij/uiDesigner/icons/textField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JPasswordField" icon="/com/intellij/uiDesigner/icons/passwordField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JFormattedTextField" icon="/com/intellij/uiDesigner/icons/formattedTextField.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1">
|
||||
<preferred-size width="150" height="-1" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextArea" icon="/com/intellij/uiDesigner/icons/textArea.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTextPane" icon="/com/intellij/uiDesigner/icons/textPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JEditorPane" icon="/com/intellij/uiDesigner/icons/editorPane.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JComboBox" icon="/com/intellij/uiDesigner/icons/comboBox.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="2" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JTable" icon="/com/intellij/uiDesigner/icons/table.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JList" icon="/com/intellij/uiDesigner/icons/list.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="2" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTree" icon="/com/intellij/uiDesigner/icons/tree.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3">
|
||||
<preferred-size width="150" height="50" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JTabbedPane" icon="/com/intellij/uiDesigner/icons/tabbedPane.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSplitPane" icon="/com/intellij/uiDesigner/icons/splitPane.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="3" hsize-policy="3" anchor="0" fill="3">
|
||||
<preferred-size width="200" height="200" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JSpinner" icon="/com/intellij/uiDesigner/icons/spinner.svg" removable="false" auto-create-binding="true" can-attach-label="true">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSlider" icon="/com/intellij/uiDesigner/icons/slider.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="8" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JSeparator" icon="/com/intellij/uiDesigner/icons/separator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="6" anchor="0" fill="3" />
|
||||
</item>
|
||||
<item class="javax.swing.JProgressBar" icon="/com/intellij/uiDesigner/icons/progressbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar" icon="/com/intellij/uiDesigner/icons/toolbar.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="6" anchor="0" fill="1">
|
||||
<preferred-size width="-1" height="20" />
|
||||
</default-constraints>
|
||||
</item>
|
||||
<item class="javax.swing.JToolBar$Separator" icon="/com/intellij/uiDesigner/icons/toolbarSeparator.svg" removable="false" auto-create-binding="false" can-attach-label="false">
|
||||
<default-constraints vsize-policy="0" hsize-policy="0" anchor="0" fill="1" />
|
||||
</item>
|
||||
<item class="javax.swing.JScrollBar" icon="/com/intellij/uiDesigner/icons/scrollbar.svg" removable="false" auto-create-binding="true" can-attach-label="false">
|
||||
<default-constraints vsize-policy="6" hsize-policy="0" anchor="0" fill="2" />
|
||||
</item>
|
||||
</group>
|
||||
</component>
|
||||
</project>
|
@ -2,8 +2,8 @@
|
||||
`java -jar WHILEParser.jar <whileprogram> <x1Value> <x2Value> ...`
|
||||
|
||||
# Build it yourself
|
||||
## parse with antlr
|
||||
`antlr4 -package parser.grammar -o main/java/parser -no-listener -visitor grammar/Loop.g4`
|
||||
## create parser with antlr
|
||||
`antlr4 -package parser.grammar -o main/java/parser/grammar -no-listener -visitor Loop.g4`
|
||||
|
||||
## create executable
|
||||
`mvn clean compile assembly:single`
|
BIN
WHILEParser.jar
BIN
WHILEParser.jar
Binary file not shown.
@ -10,6 +10,7 @@ asrt: var=VAR '=' ex=expr ';' #Ex
|
||||
;
|
||||
prog: asrt #Asert
|
||||
| 'LOOP' var=VAR 'DO' p=prog 'END' #Loop
|
||||
| 'WHILE' var=VAR '!=' c=INT 'DO' p=prog 'END' #While
|
||||
| prog prog #ProgProg
|
||||
;
|
||||
|
@ -39,6 +39,6 @@ public class Main {
|
||||
LoopParser parser = new LoopParser(tokens);
|
||||
|
||||
ParseTree tree = parser.start();
|
||||
new MyVisitor().visit(tree);
|
||||
new Visitor().visit(tree);
|
||||
}
|
||||
}
|
||||
|
@ -3,7 +3,7 @@ package interpreter.grammar;
|
||||
import parser.grammar.LoopBaseVisitor;
|
||||
import parser.grammar.LoopParser;
|
||||
|
||||
public class MyVisitor extends LoopBaseVisitor<Integer> {
|
||||
public class Visitor extends LoopBaseVisitor<Integer> {
|
||||
|
||||
@Override
|
||||
public Integer visitStart(LoopParser.StartContext ctx) {
|
||||
@ -11,6 +11,7 @@ public class MyVisitor extends LoopBaseVisitor<Integer> {
|
||||
System.out.println("\nFinal value of x0 = " + VariableSingleton.getInstance().getValue("x0"));
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitPlus(LoopParser.PlusContext ctx) {
|
||||
int varVal = VariableSingleton.getInstance().getValue(ctx.var.getText());
|
||||
@ -56,4 +57,13 @@ public class MyVisitor extends LoopBaseVisitor<Integer> {
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Integer visitWhile(LoopParser.WhileContext ctx) {
|
||||
int c = Integer.parseInt(ctx.c.getText());
|
||||
while(VariableSingleton.getInstance().getValue(ctx.var.getText()) != c) {
|
||||
visit(ctx.p);
|
||||
}
|
||||
return null;
|
||||
}
|
||||
}
|
@ -7,6 +7,8 @@ null
|
||||
'LOOP'
|
||||
'DO'
|
||||
'END'
|
||||
'WHILE'
|
||||
'!='
|
||||
null
|
||||
null
|
||||
null
|
||||
@ -22,6 +24,8 @@ null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
VAR
|
||||
INT
|
||||
NEWLINE
|
||||
@ -36,4 +40,4 @@ prog
|
||||
|
||||
|
||||
atn:
|
||||
[4, 1, 12, 52, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 18, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 33, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 43, 8, 3, 1, 3, 1, 3, 5, 3, 47, 8, 3, 10, 3, 12, 3, 50, 9, 3, 1, 3, 0, 1, 6, 4, 0, 2, 4, 6, 0, 0, 52, 0, 8, 1, 0, 0, 0, 2, 17, 1, 0, 0, 0, 4, 32, 1, 0, 0, 0, 6, 42, 1, 0, 0, 0, 8, 9, 3, 6, 3, 0, 9, 10, 5, 0, 0, 1, 10, 1, 1, 0, 0, 0, 11, 12, 5, 8, 0, 0, 12, 13, 5, 1, 0, 0, 13, 18, 5, 9, 0, 0, 14, 15, 5, 8, 0, 0, 15, 16, 5, 2, 0, 0, 16, 18, 5, 9, 0, 0, 17, 11, 1, 0, 0, 0, 17, 14, 1, 0, 0, 0, 18, 3, 1, 0, 0, 0, 19, 20, 5, 8, 0, 0, 20, 21, 5, 3, 0, 0, 21, 22, 3, 2, 1, 0, 22, 23, 5, 4, 0, 0, 23, 33, 1, 0, 0, 0, 24, 25, 5, 8, 0, 0, 25, 26, 5, 3, 0, 0, 26, 27, 5, 8, 0, 0, 27, 33, 5, 4, 0, 0, 28, 29, 5, 8, 0, 0, 29, 30, 5, 3, 0, 0, 30, 31, 5, 9, 0, 0, 31, 33, 5, 4, 0, 0, 32, 19, 1, 0, 0, 0, 32, 24, 1, 0, 0, 0, 32, 28, 1, 0, 0, 0, 33, 5, 1, 0, 0, 0, 34, 35, 6, 3, -1, 0, 35, 43, 3, 4, 2, 0, 36, 37, 5, 5, 0, 0, 37, 38, 5, 8, 0, 0, 38, 39, 5, 6, 0, 0, 39, 40, 3, 6, 3, 0, 40, 41, 5, 7, 0, 0, 41, 43, 1, 0, 0, 0, 42, 34, 1, 0, 0, 0, 42, 36, 1, 0, 0, 0, 43, 48, 1, 0, 0, 0, 44, 45, 10, 1, 0, 0, 45, 47, 3, 6, 3, 2, 46, 44, 1, 0, 0, 0, 47, 50, 1, 0, 0, 0, 48, 46, 1, 0, 0, 0, 48, 49, 1, 0, 0, 0, 49, 7, 1, 0, 0, 0, 50, 48, 1, 0, 0, 0, 4, 17, 32, 42, 48]
|
||||
[4, 1, 14, 60, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 1, 0, 1, 0, 1, 0, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 3, 1, 18, 8, 1, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 1, 2, 3, 2, 33, 8, 2, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 1, 3, 3, 3, 51, 8, 3, 1, 3, 1, 3, 5, 3, 55, 8, 3, 10, 3, 12, 3, 58, 9, 3, 1, 3, 0, 1, 6, 4, 0, 2, 4, 6, 0, 0, 61, 0, 8, 1, 0, 0, 0, 2, 17, 1, 0, 0, 0, 4, 32, 1, 0, 0, 0, 6, 50, 1, 0, 0, 0, 8, 9, 3, 6, 3, 0, 9, 10, 5, 0, 0, 1, 10, 1, 1, 0, 0, 0, 11, 12, 5, 10, 0, 0, 12, 13, 5, 1, 0, 0, 13, 18, 5, 11, 0, 0, 14, 15, 5, 10, 0, 0, 15, 16, 5, 2, 0, 0, 16, 18, 5, 11, 0, 0, 17, 11, 1, 0, 0, 0, 17, 14, 1, 0, 0, 0, 18, 3, 1, 0, 0, 0, 19, 20, 5, 10, 0, 0, 20, 21, 5, 3, 0, 0, 21, 22, 3, 2, 1, 0, 22, 23, 5, 4, 0, 0, 23, 33, 1, 0, 0, 0, 24, 25, 5, 10, 0, 0, 25, 26, 5, 3, 0, 0, 26, 27, 5, 10, 0, 0, 27, 33, 5, 4, 0, 0, 28, 29, 5, 10, 0, 0, 29, 30, 5, 3, 0, 0, 30, 31, 5, 11, 0, 0, 31, 33, 5, 4, 0, 0, 32, 19, 1, 0, 0, 0, 32, 24, 1, 0, 0, 0, 32, 28, 1, 0, 0, 0, 33, 5, 1, 0, 0, 0, 34, 35, 6, 3, -1, 0, 35, 51, 3, 4, 2, 0, 36, 37, 5, 5, 0, 0, 37, 38, 5, 10, 0, 0, 38, 39, 5, 6, 0, 0, 39, 40, 3, 6, 3, 0, 40, 41, 5, 7, 0, 0, 41, 51, 1, 0, 0, 0, 42, 43, 5, 8, 0, 0, 43, 44, 5, 10, 0, 0, 44, 45, 5, 9, 0, 0, 45, 46, 5, 11, 0, 0, 46, 47, 5, 6, 0, 0, 47, 48, 3, 6, 3, 0, 48, 49, 5, 7, 0, 0, 49, 51, 1, 0, 0, 0, 50, 34, 1, 0, 0, 0, 50, 36, 1, 0, 0, 0, 50, 42, 1, 0, 0, 0, 51, 56, 1, 0, 0, 0, 52, 53, 10, 1, 0, 0, 53, 55, 3, 6, 3, 2, 54, 52, 1, 0, 0, 0, 55, 58, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 7, 1, 0, 0, 0, 58, 56, 1, 0, 0, 0, 4, 17, 32, 50, 56]
|
@ -5,11 +5,13 @@ T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
VAR=8
|
||||
INT=9
|
||||
NEWLINE=10
|
||||
LEER=11
|
||||
LINE_COMMENT=12
|
||||
T__7=8
|
||||
T__8=9
|
||||
VAR=10
|
||||
INT=11
|
||||
NEWLINE=12
|
||||
LEER=13
|
||||
LINE_COMMENT=14
|
||||
'+'=1
|
||||
'-'=2
|
||||
'='=3
|
||||
@ -17,4 +19,6 @@ LINE_COMMENT=12
|
||||
'LOOP'=5
|
||||
'DO'=6
|
||||
'END'=7
|
||||
' '=11
|
||||
'WHILE'=8
|
||||
'!='=9
|
||||
' '=13
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from grammar/Loop.g4 by ANTLR 4.13.1
|
||||
// Generated from Loop.g4 by ANTLR 4.13.1
|
||||
package parser.grammar;
|
||||
import org.antlr.v4.runtime.tree.AbstractParseTreeVisitor;
|
||||
|
||||
@ -61,6 +61,13 @@ public class LoopBaseVisitor<T> extends AbstractParseTreeVisitor<T> implements L
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitLoop(LoopParser.LoopContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
* <p>The default implementation returns the result of calling
|
||||
* {@link #visitChildren} on {@code ctx}.</p>
|
||||
*/
|
||||
@Override public T visitWhile(LoopParser.WhileContext ctx) { return visitChildren(ctx); }
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*
|
||||
|
@ -7,6 +7,8 @@ null
|
||||
'LOOP'
|
||||
'DO'
|
||||
'END'
|
||||
'WHILE'
|
||||
'!='
|
||||
null
|
||||
null
|
||||
null
|
||||
@ -22,6 +24,8 @@ null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
null
|
||||
VAR
|
||||
INT
|
||||
NEWLINE
|
||||
@ -36,6 +40,8 @@ T__3
|
||||
T__4
|
||||
T__5
|
||||
T__6
|
||||
T__7
|
||||
T__8
|
||||
VAR
|
||||
INT
|
||||
NEWLINE
|
||||
@ -50,4 +56,4 @@ mode names:
|
||||
DEFAULT_MODE
|
||||
|
||||
atn:
|
||||
[4, 0, 12, 75, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 8, 4, 8, 50, 8, 8, 11, 8, 12, 8, 51, 1, 9, 4, 9, 55, 8, 9, 11, 9, 12, 9, 56, 1, 9, 1, 9, 1, 10, 1, 10, 1, 10, 1, 10, 1, 11, 1, 11, 1, 11, 1, 11, 5, 11, 69, 8, 11, 10, 11, 12, 11, 72, 9, 11, 1, 11, 1, 11, 0, 0, 12, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 1, 0, 2, 1, 0, 48, 57, 2, 0, 10, 10, 13, 13, 77, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 1, 25, 1, 0, 0, 0, 3, 27, 1, 0, 0, 0, 5, 29, 1, 0, 0, 0, 7, 31, 1, 0, 0, 0, 9, 33, 1, 0, 0, 0, 11, 38, 1, 0, 0, 0, 13, 41, 1, 0, 0, 0, 15, 45, 1, 0, 0, 0, 17, 49, 1, 0, 0, 0, 19, 54, 1, 0, 0, 0, 21, 60, 1, 0, 0, 0, 23, 64, 1, 0, 0, 0, 25, 26, 5, 43, 0, 0, 26, 2, 1, 0, 0, 0, 27, 28, 5, 45, 0, 0, 28, 4, 1, 0, 0, 0, 29, 30, 5, 61, 0, 0, 30, 6, 1, 0, 0, 0, 31, 32, 5, 59, 0, 0, 32, 8, 1, 0, 0, 0, 33, 34, 5, 76, 0, 0, 34, 35, 5, 79, 0, 0, 35, 36, 5, 79, 0, 0, 36, 37, 5, 80, 0, 0, 37, 10, 1, 0, 0, 0, 38, 39, 5, 68, 0, 0, 39, 40, 5, 79, 0, 0, 40, 12, 1, 0, 0, 0, 41, 42, 5, 69, 0, 0, 42, 43, 5, 78, 0, 0, 43, 44, 5, 68, 0, 0, 44, 14, 1, 0, 0, 0, 45, 46, 2, 120, 122, 0, 46, 47, 3, 17, 8, 0, 47, 16, 1, 0, 0, 0, 48, 50, 7, 0, 0, 0, 49, 48, 1, 0, 0, 0, 50, 51, 1, 0, 0, 0, 51, 49, 1, 0, 0, 0, 51, 52, 1, 0, 0, 0, 52, 18, 1, 0, 0, 0, 53, 55, 7, 1, 0, 0, 54, 53, 1, 0, 0, 0, 55, 56, 1, 0, 0, 0, 56, 54, 1, 0, 0, 0, 56, 57, 1, 0, 0, 0, 57, 58, 1, 0, 0, 0, 58, 59, 6, 9, 0, 0, 59, 20, 1, 0, 0, 0, 60, 61, 5, 32, 0, 0, 61, 62, 1, 0, 0, 0, 62, 63, 6, 10, 0, 0, 63, 22, 1, 0, 0, 0, 64, 65, 5, 47, 0, 0, 65, 66, 5, 47, 0, 0, 66, 70, 1, 0, 0, 0, 67, 69, 8, 1, 0, 0, 68, 67, 1, 0, 0, 0, 69, 72, 1, 0, 0, 0, 70, 68, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 73, 1, 0, 0, 0, 72, 70, 1, 0, 0, 0, 73, 74, 6, 11, 0, 0, 74, 24, 1, 0, 0, 0, 4, 0, 51, 56, 70, 1, 6, 0, 0]
|
||||
[4, 0, 14, 88, 6, -1, 2, 0, 7, 0, 2, 1, 7, 1, 2, 2, 7, 2, 2, 3, 7, 3, 2, 4, 7, 4, 2, 5, 7, 5, 2, 6, 7, 6, 2, 7, 7, 7, 2, 8, 7, 8, 2, 9, 7, 9, 2, 10, 7, 10, 2, 11, 7, 11, 2, 12, 7, 12, 2, 13, 7, 13, 1, 0, 1, 0, 1, 1, 1, 1, 1, 2, 1, 2, 1, 3, 1, 3, 1, 4, 1, 4, 1, 4, 1, 4, 1, 4, 1, 5, 1, 5, 1, 5, 1, 6, 1, 6, 1, 6, 1, 6, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 7, 1, 8, 1, 8, 1, 8, 1, 9, 1, 9, 1, 9, 1, 10, 4, 10, 63, 8, 10, 11, 10, 12, 10, 64, 1, 11, 4, 11, 68, 8, 11, 11, 11, 12, 11, 69, 1, 11, 1, 11, 1, 12, 1, 12, 1, 12, 1, 12, 1, 13, 1, 13, 1, 13, 1, 13, 5, 13, 82, 8, 13, 10, 13, 12, 13, 85, 9, 13, 1, 13, 1, 13, 0, 0, 14, 1, 1, 3, 2, 5, 3, 7, 4, 9, 5, 11, 6, 13, 7, 15, 8, 17, 9, 19, 10, 21, 11, 23, 12, 25, 13, 27, 14, 1, 0, 2, 1, 0, 48, 57, 2, 0, 10, 10, 13, 13, 90, 0, 1, 1, 0, 0, 0, 0, 3, 1, 0, 0, 0, 0, 5, 1, 0, 0, 0, 0, 7, 1, 0, 0, 0, 0, 9, 1, 0, 0, 0, 0, 11, 1, 0, 0, 0, 0, 13, 1, 0, 0, 0, 0, 15, 1, 0, 0, 0, 0, 17, 1, 0, 0, 0, 0, 19, 1, 0, 0, 0, 0, 21, 1, 0, 0, 0, 0, 23, 1, 0, 0, 0, 0, 25, 1, 0, 0, 0, 0, 27, 1, 0, 0, 0, 1, 29, 1, 0, 0, 0, 3, 31, 1, 0, 0, 0, 5, 33, 1, 0, 0, 0, 7, 35, 1, 0, 0, 0, 9, 37, 1, 0, 0, 0, 11, 42, 1, 0, 0, 0, 13, 45, 1, 0, 0, 0, 15, 49, 1, 0, 0, 0, 17, 55, 1, 0, 0, 0, 19, 58, 1, 0, 0, 0, 21, 62, 1, 0, 0, 0, 23, 67, 1, 0, 0, 0, 25, 73, 1, 0, 0, 0, 27, 77, 1, 0, 0, 0, 29, 30, 5, 43, 0, 0, 30, 2, 1, 0, 0, 0, 31, 32, 5, 45, 0, 0, 32, 4, 1, 0, 0, 0, 33, 34, 5, 61, 0, 0, 34, 6, 1, 0, 0, 0, 35, 36, 5, 59, 0, 0, 36, 8, 1, 0, 0, 0, 37, 38, 5, 76, 0, 0, 38, 39, 5, 79, 0, 0, 39, 40, 5, 79, 0, 0, 40, 41, 5, 80, 0, 0, 41, 10, 1, 0, 0, 0, 42, 43, 5, 68, 0, 0, 43, 44, 5, 79, 0, 0, 44, 12, 1, 0, 0, 0, 45, 46, 5, 69, 0, 0, 46, 47, 5, 78, 0, 0, 47, 48, 5, 68, 0, 0, 48, 14, 1, 0, 0, 0, 49, 50, 5, 87, 0, 0, 50, 51, 5, 72, 0, 0, 51, 52, 5, 73, 0, 0, 52, 53, 5, 76, 0, 0, 53, 54, 5, 69, 0, 0, 54, 16, 1, 0, 0, 0, 55, 56, 5, 33, 0, 0, 56, 57, 5, 61, 0, 0, 57, 18, 1, 0, 0, 0, 58, 59, 2, 120, 122, 0, 59, 60, 3, 21, 10, 0, 60, 20, 1, 0, 0, 0, 61, 63, 7, 0, 0, 0, 62, 61, 1, 0, 0, 0, 63, 64, 1, 0, 0, 0, 64, 62, 1, 0, 0, 0, 64, 65, 1, 0, 0, 0, 65, 22, 1, 0, 0, 0, 66, 68, 7, 1, 0, 0, 67, 66, 1, 0, 0, 0, 68, 69, 1, 0, 0, 0, 69, 67, 1, 0, 0, 0, 69, 70, 1, 0, 0, 0, 70, 71, 1, 0, 0, 0, 71, 72, 6, 11, 0, 0, 72, 24, 1, 0, 0, 0, 73, 74, 5, 32, 0, 0, 74, 75, 1, 0, 0, 0, 75, 76, 6, 12, 0, 0, 76, 26, 1, 0, 0, 0, 77, 78, 5, 47, 0, 0, 78, 79, 5, 47, 0, 0, 79, 83, 1, 0, 0, 0, 80, 82, 8, 1, 0, 0, 81, 80, 1, 0, 0, 0, 82, 85, 1, 0, 0, 0, 83, 81, 1, 0, 0, 0, 83, 84, 1, 0, 0, 0, 84, 86, 1, 0, 0, 0, 85, 83, 1, 0, 0, 0, 86, 87, 6, 13, 0, 0, 87, 28, 1, 0, 0, 0, 4, 0, 64, 69, 83, 1, 6, 0, 0]
|
@ -1,4 +1,4 @@
|
||||
// Generated from grammar/Loop.g4 by ANTLR 4.13.1
|
||||
// Generated from Loop.g4 by ANTLR 4.13.1
|
||||
package parser.grammar;
|
||||
import org.antlr.v4.runtime.Lexer;
|
||||
import org.antlr.v4.runtime.CharStream;
|
||||
@ -17,8 +17,8 @@ public class LoopLexer extends Lexer {
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, VAR=8, INT=9,
|
||||
NEWLINE=10, LEER=11, LINE_COMMENT=12;
|
||||
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,
|
||||
VAR=10, INT=11, NEWLINE=12, LEER=13, LINE_COMMENT=14;
|
||||
public static String[] channelNames = {
|
||||
"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
|
||||
};
|
||||
@ -29,23 +29,23 @@ public class LoopLexer extends Lexer {
|
||||
|
||||
private static String[] makeRuleNames() {
|
||||
return new String[] {
|
||||
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "VAR", "INT",
|
||||
"NEWLINE", "LEER", "LINE_COMMENT"
|
||||
"T__0", "T__1", "T__2", "T__3", "T__4", "T__5", "T__6", "T__7", "T__8",
|
||||
"VAR", "INT", "NEWLINE", "LEER", "LINE_COMMENT"
|
||||
};
|
||||
}
|
||||
public static final String[] ruleNames = makeRuleNames();
|
||||
|
||||
private static String[] makeLiteralNames() {
|
||||
return new String[] {
|
||||
null, "'+'", "'-'", "'='", "';'", "'LOOP'", "'DO'", "'END'", null, null,
|
||||
null, "' '"
|
||||
null, "'+'", "'-'", "'='", "';'", "'LOOP'", "'DO'", "'END'", "'WHILE'",
|
||||
"'!='", null, null, null, "' '"
|
||||
};
|
||||
}
|
||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
||||
private static String[] makeSymbolicNames() {
|
||||
return new String[] {
|
||||
null, null, null, null, null, null, null, null, "VAR", "INT", "NEWLINE",
|
||||
"LEER", "LINE_COMMENT"
|
||||
null, null, null, null, null, null, null, null, null, null, "VAR", "INT",
|
||||
"NEWLINE", "LEER", "LINE_COMMENT"
|
||||
};
|
||||
}
|
||||
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
|
||||
@ -107,51 +107,57 @@ public class LoopLexer extends Lexer {
|
||||
public ATN getATN() { return _ATN; }
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\u0004\u0000\fK\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
|
||||
"\u0004\u0000\u000eX\u0006\uffff\uffff\u0002\u0000\u0007\u0000\u0002\u0001"+
|
||||
"\u0007\u0001\u0002\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0002\u0004"+
|
||||
"\u0007\u0004\u0002\u0005\u0007\u0005\u0002\u0006\u0007\u0006\u0002\u0007"+
|
||||
"\u0007\u0007\u0002\b\u0007\b\u0002\t\u0007\t\u0002\n\u0007\n\u0002\u000b"+
|
||||
"\u0007\u000b\u0001\u0000\u0001\u0000\u0001\u0001\u0001\u0001\u0001\u0002"+
|
||||
"\u0001\u0002\u0001\u0003\u0001\u0003\u0001\u0004\u0001\u0004\u0001\u0004"+
|
||||
"\u0001\u0004\u0001\u0004\u0001\u0005\u0001\u0005\u0001\u0005\u0001\u0006"+
|
||||
"\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0007\u0001\u0007\u0001\u0007"+
|
||||
"\u0001\b\u0004\b2\b\b\u000b\b\f\b3\u0001\t\u0004\t7\b\t\u000b\t\f\t8\u0001"+
|
||||
"\t\u0001\t\u0001\n\u0001\n\u0001\n\u0001\n\u0001\u000b\u0001\u000b\u0001"+
|
||||
"\u000b\u0001\u000b\u0005\u000bE\b\u000b\n\u000b\f\u000bH\t\u000b\u0001"+
|
||||
"\u000b\u0001\u000b\u0000\u0000\f\u0001\u0001\u0003\u0002\u0005\u0003\u0007"+
|
||||
"\u0004\t\u0005\u000b\u0006\r\u0007\u000f\b\u0011\t\u0013\n\u0015\u000b"+
|
||||
"\u0017\f\u0001\u0000\u0002\u0001\u000009\u0002\u0000\n\n\r\rM\u0000\u0001"+
|
||||
"\u0001\u0000\u0000\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0005"+
|
||||
"\u0001\u0000\u0000\u0000\u0000\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001"+
|
||||
"\u0000\u0000\u0000\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000"+
|
||||
"\u0000\u0000\u0000\u000f\u0001\u0000\u0000\u0000\u0000\u0011\u0001\u0000"+
|
||||
"\u0000\u0000\u0000\u0013\u0001\u0000\u0000\u0000\u0000\u0015\u0001\u0000"+
|
||||
"\u0000\u0000\u0000\u0017\u0001\u0000\u0000\u0000\u0001\u0019\u0001\u0000"+
|
||||
"\u0000\u0000\u0003\u001b\u0001\u0000\u0000\u0000\u0005\u001d\u0001\u0000"+
|
||||
"\u0000\u0000\u0007\u001f\u0001\u0000\u0000\u0000\t!\u0001\u0000\u0000"+
|
||||
"\u0000\u000b&\u0001\u0000\u0000\u0000\r)\u0001\u0000\u0000\u0000\u000f"+
|
||||
"-\u0001\u0000\u0000\u0000\u00111\u0001\u0000\u0000\u0000\u00136\u0001"+
|
||||
"\u0000\u0000\u0000\u0015<\u0001\u0000\u0000\u0000\u0017@\u0001\u0000\u0000"+
|
||||
"\u0000\u0019\u001a\u0005+\u0000\u0000\u001a\u0002\u0001\u0000\u0000\u0000"+
|
||||
"\u001b\u001c\u0005-\u0000\u0000\u001c\u0004\u0001\u0000\u0000\u0000\u001d"+
|
||||
"\u001e\u0005=\u0000\u0000\u001e\u0006\u0001\u0000\u0000\u0000\u001f \u0005"+
|
||||
";\u0000\u0000 \b\u0001\u0000\u0000\u0000!\"\u0005L\u0000\u0000\"#\u0005"+
|
||||
"O\u0000\u0000#$\u0005O\u0000\u0000$%\u0005P\u0000\u0000%\n\u0001\u0000"+
|
||||
"\u0000\u0000&\'\u0005D\u0000\u0000\'(\u0005O\u0000\u0000(\f\u0001\u0000"+
|
||||
"\u0000\u0000)*\u0005E\u0000\u0000*+\u0005N\u0000\u0000+,\u0005D\u0000"+
|
||||
"\u0000,\u000e\u0001\u0000\u0000\u0000-.\u0002xz\u0000./\u0003\u0011\b"+
|
||||
"\u0000/\u0010\u0001\u0000\u0000\u000002\u0007\u0000\u0000\u000010\u0001"+
|
||||
"\u0000\u0000\u000023\u0001\u0000\u0000\u000031\u0001\u0000\u0000\u0000"+
|
||||
"34\u0001\u0000\u0000\u00004\u0012\u0001\u0000\u0000\u000057\u0007\u0001"+
|
||||
"\u0000\u000065\u0001\u0000\u0000\u000078\u0001\u0000\u0000\u000086\u0001"+
|
||||
"\u0000\u0000\u000089\u0001\u0000\u0000\u00009:\u0001\u0000\u0000\u0000"+
|
||||
":;\u0006\t\u0000\u0000;\u0014\u0001\u0000\u0000\u0000<=\u0005 \u0000\u0000"+
|
||||
"=>\u0001\u0000\u0000\u0000>?\u0006\n\u0000\u0000?\u0016\u0001\u0000\u0000"+
|
||||
"\u0000@A\u0005/\u0000\u0000AB\u0005/\u0000\u0000BF\u0001\u0000\u0000\u0000"+
|
||||
"CE\b\u0001\u0000\u0000DC\u0001\u0000\u0000\u0000EH\u0001\u0000\u0000\u0000"+
|
||||
"FD\u0001\u0000\u0000\u0000FG\u0001\u0000\u0000\u0000GI\u0001\u0000\u0000"+
|
||||
"\u0000HF\u0001\u0000\u0000\u0000IJ\u0006\u000b\u0000\u0000J\u0018\u0001"+
|
||||
"\u0000\u0000\u0000\u0004\u000038F\u0001\u0006\u0000\u0000";
|
||||
"\u0007\u000b\u0002\f\u0007\f\u0002\r\u0007\r\u0001\u0000\u0001\u0000\u0001"+
|
||||
"\u0001\u0001\u0001\u0001\u0002\u0001\u0002\u0001\u0003\u0001\u0003\u0001"+
|
||||
"\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0004\u0001\u0005\u0001"+
|
||||
"\u0005\u0001\u0005\u0001\u0006\u0001\u0006\u0001\u0006\u0001\u0006\u0001"+
|
||||
"\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001\u0007\u0001"+
|
||||
"\b\u0001\b\u0001\b\u0001\t\u0001\t\u0001\t\u0001\n\u0004\n?\b\n\u000b"+
|
||||
"\n\f\n@\u0001\u000b\u0004\u000bD\b\u000b\u000b\u000b\f\u000bE\u0001\u000b"+
|
||||
"\u0001\u000b\u0001\f\u0001\f\u0001\f\u0001\f\u0001\r\u0001\r\u0001\r\u0001"+
|
||||
"\r\u0005\rR\b\r\n\r\f\rU\t\r\u0001\r\u0001\r\u0000\u0000\u000e\u0001\u0001"+
|
||||
"\u0003\u0002\u0005\u0003\u0007\u0004\t\u0005\u000b\u0006\r\u0007\u000f"+
|
||||
"\b\u0011\t\u0013\n\u0015\u000b\u0017\f\u0019\r\u001b\u000e\u0001\u0000"+
|
||||
"\u0002\u0001\u000009\u0002\u0000\n\n\r\rZ\u0000\u0001\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u0003\u0001\u0000\u0000\u0000\u0000\u0005\u0001\u0000\u0000"+
|
||||
"\u0000\u0000\u0007\u0001\u0000\u0000\u0000\u0000\t\u0001\u0000\u0000\u0000"+
|
||||
"\u0000\u000b\u0001\u0000\u0000\u0000\u0000\r\u0001\u0000\u0000\u0000\u0000"+
|
||||
"\u000f\u0001\u0000\u0000\u0000\u0000\u0011\u0001\u0000\u0000\u0000\u0000"+
|
||||
"\u0013\u0001\u0000\u0000\u0000\u0000\u0015\u0001\u0000\u0000\u0000\u0000"+
|
||||
"\u0017\u0001\u0000\u0000\u0000\u0000\u0019\u0001\u0000\u0000\u0000\u0000"+
|
||||
"\u001b\u0001\u0000\u0000\u0000\u0001\u001d\u0001\u0000\u0000\u0000\u0003"+
|
||||
"\u001f\u0001\u0000\u0000\u0000\u0005!\u0001\u0000\u0000\u0000\u0007#\u0001"+
|
||||
"\u0000\u0000\u0000\t%\u0001\u0000\u0000\u0000\u000b*\u0001\u0000\u0000"+
|
||||
"\u0000\r-\u0001\u0000\u0000\u0000\u000f1\u0001\u0000\u0000\u0000\u0011"+
|
||||
"7\u0001\u0000\u0000\u0000\u0013:\u0001\u0000\u0000\u0000\u0015>\u0001"+
|
||||
"\u0000\u0000\u0000\u0017C\u0001\u0000\u0000\u0000\u0019I\u0001\u0000\u0000"+
|
||||
"\u0000\u001bM\u0001\u0000\u0000\u0000\u001d\u001e\u0005+\u0000\u0000\u001e"+
|
||||
"\u0002\u0001\u0000\u0000\u0000\u001f \u0005-\u0000\u0000 \u0004\u0001"+
|
||||
"\u0000\u0000\u0000!\"\u0005=\u0000\u0000\"\u0006\u0001\u0000\u0000\u0000"+
|
||||
"#$\u0005;\u0000\u0000$\b\u0001\u0000\u0000\u0000%&\u0005L\u0000\u0000"+
|
||||
"&\'\u0005O\u0000\u0000\'(\u0005O\u0000\u0000()\u0005P\u0000\u0000)\n\u0001"+
|
||||
"\u0000\u0000\u0000*+\u0005D\u0000\u0000+,\u0005O\u0000\u0000,\f\u0001"+
|
||||
"\u0000\u0000\u0000-.\u0005E\u0000\u0000./\u0005N\u0000\u0000/0\u0005D"+
|
||||
"\u0000\u00000\u000e\u0001\u0000\u0000\u000012\u0005W\u0000\u000023\u0005"+
|
||||
"H\u0000\u000034\u0005I\u0000\u000045\u0005L\u0000\u000056\u0005E\u0000"+
|
||||
"\u00006\u0010\u0001\u0000\u0000\u000078\u0005!\u0000\u000089\u0005=\u0000"+
|
||||
"\u00009\u0012\u0001\u0000\u0000\u0000:;\u0002xz\u0000;<\u0003\u0015\n"+
|
||||
"\u0000<\u0014\u0001\u0000\u0000\u0000=?\u0007\u0000\u0000\u0000>=\u0001"+
|
||||
"\u0000\u0000\u0000?@\u0001\u0000\u0000\u0000@>\u0001\u0000\u0000\u0000"+
|
||||
"@A\u0001\u0000\u0000\u0000A\u0016\u0001\u0000\u0000\u0000BD\u0007\u0001"+
|
||||
"\u0000\u0000CB\u0001\u0000\u0000\u0000DE\u0001\u0000\u0000\u0000EC\u0001"+
|
||||
"\u0000\u0000\u0000EF\u0001\u0000\u0000\u0000FG\u0001\u0000\u0000\u0000"+
|
||||
"GH\u0006\u000b\u0000\u0000H\u0018\u0001\u0000\u0000\u0000IJ\u0005 \u0000"+
|
||||
"\u0000JK\u0001\u0000\u0000\u0000KL\u0006\f\u0000\u0000L\u001a\u0001\u0000"+
|
||||
"\u0000\u0000MN\u0005/\u0000\u0000NO\u0005/\u0000\u0000OS\u0001\u0000\u0000"+
|
||||
"\u0000PR\b\u0001\u0000\u0000QP\u0001\u0000\u0000\u0000RU\u0001\u0000\u0000"+
|
||||
"\u0000SQ\u0001\u0000\u0000\u0000ST\u0001\u0000\u0000\u0000TV\u0001\u0000"+
|
||||
"\u0000\u0000US\u0001\u0000\u0000\u0000VW\u0006\r\u0000\u0000W\u001c\u0001"+
|
||||
"\u0000\u0000\u0000\u0004\u0000@ES\u0001\u0006\u0000\u0000";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
|
@ -5,11 +5,13 @@ T__3=4
|
||||
T__4=5
|
||||
T__5=6
|
||||
T__6=7
|
||||
VAR=8
|
||||
INT=9
|
||||
NEWLINE=10
|
||||
LEER=11
|
||||
LINE_COMMENT=12
|
||||
T__7=8
|
||||
T__8=9
|
||||
VAR=10
|
||||
INT=11
|
||||
NEWLINE=12
|
||||
LEER=13
|
||||
LINE_COMMENT=14
|
||||
'+'=1
|
||||
'-'=2
|
||||
'='=3
|
||||
@ -17,4 +19,6 @@ LINE_COMMENT=12
|
||||
'LOOP'=5
|
||||
'DO'=6
|
||||
'END'=7
|
||||
' '=11
|
||||
'WHILE'=8
|
||||
'!='=9
|
||||
' '=13
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from grammar/Loop.g4 by ANTLR 4.13.1
|
||||
// Generated from Loop.g4 by ANTLR 4.13.1
|
||||
package parser.grammar;
|
||||
import org.antlr.v4.runtime.atn.*;
|
||||
import org.antlr.v4.runtime.dfa.DFA;
|
||||
@ -17,8 +17,8 @@ public class LoopParser extends Parser {
|
||||
protected static final PredictionContextCache _sharedContextCache =
|
||||
new PredictionContextCache();
|
||||
public static final int
|
||||
T__0=1, T__1=2, T__2=3, T__3=4, T__4=5, T__5=6, T__6=7, VAR=8, INT=9,
|
||||
NEWLINE=10, LEER=11, LINE_COMMENT=12;
|
||||
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,
|
||||
VAR=10, INT=11, NEWLINE=12, LEER=13, LINE_COMMENT=14;
|
||||
public static final int
|
||||
RULE_start = 0, RULE_expr = 1, RULE_asrt = 2, RULE_prog = 3;
|
||||
private static String[] makeRuleNames() {
|
||||
@ -30,15 +30,15 @@ public class LoopParser extends Parser {
|
||||
|
||||
private static String[] makeLiteralNames() {
|
||||
return new String[] {
|
||||
null, "'+'", "'-'", "'='", "';'", "'LOOP'", "'DO'", "'END'", null, null,
|
||||
null, "' '"
|
||||
null, "'+'", "'-'", "'='", "';'", "'LOOP'", "'DO'", "'END'", "'WHILE'",
|
||||
"'!='", null, null, null, "' '"
|
||||
};
|
||||
}
|
||||
private static final String[] _LITERAL_NAMES = makeLiteralNames();
|
||||
private static String[] makeSymbolicNames() {
|
||||
return new String[] {
|
||||
null, null, null, null, null, null, null, null, "VAR", "INT", "NEWLINE",
|
||||
"LEER", "LINE_COMMENT"
|
||||
null, null, null, null, null, null, null, null, null, null, "VAR", "INT",
|
||||
"NEWLINE", "LEER", "LINE_COMMENT"
|
||||
};
|
||||
}
|
||||
private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
|
||||
@ -361,6 +361,23 @@ public class LoopParser extends Parser {
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class WhileContext extends ProgContext {
|
||||
public Token var;
|
||||
public Token c;
|
||||
public ProgContext p;
|
||||
public TerminalNode VAR() { return getToken(LoopParser.VAR, 0); }
|
||||
public TerminalNode INT() { return getToken(LoopParser.INT, 0); }
|
||||
public ProgContext prog() {
|
||||
return getRuleContext(ProgContext.class,0);
|
||||
}
|
||||
public WhileContext(ProgContext ctx) { copyFrom(ctx); }
|
||||
@Override
|
||||
public <T> T accept(ParseTreeVisitor<? extends T> visitor) {
|
||||
if ( visitor instanceof LoopVisitor ) return ((LoopVisitor<? extends T>)visitor).visitWhile(this);
|
||||
else return visitor.visitChildren(this);
|
||||
}
|
||||
}
|
||||
@SuppressWarnings("CheckReturnValue")
|
||||
public static class ProgProgContext extends ProgContext {
|
||||
public List<ProgContext> prog() {
|
||||
return getRuleContexts(ProgContext.class);
|
||||
@ -403,7 +420,7 @@ public class LoopParser extends Parser {
|
||||
int _alt;
|
||||
enterOuterAlt(_localctx, 1);
|
||||
{
|
||||
setState(42);
|
||||
setState(50);
|
||||
_errHandler.sync(this);
|
||||
switch (_input.LA(1)) {
|
||||
case VAR:
|
||||
@ -433,11 +450,32 @@ public class LoopParser extends Parser {
|
||||
match(T__6);
|
||||
}
|
||||
break;
|
||||
case T__7:
|
||||
{
|
||||
_localctx = new WhileContext(_localctx);
|
||||
_ctx = _localctx;
|
||||
_prevctx = _localctx;
|
||||
setState(42);
|
||||
match(T__7);
|
||||
setState(43);
|
||||
((WhileContext)_localctx).var = match(VAR);
|
||||
setState(44);
|
||||
match(T__8);
|
||||
setState(45);
|
||||
((WhileContext)_localctx).c = match(INT);
|
||||
setState(46);
|
||||
match(T__5);
|
||||
setState(47);
|
||||
((WhileContext)_localctx).p = prog(0);
|
||||
setState(48);
|
||||
match(T__6);
|
||||
}
|
||||
break;
|
||||
default:
|
||||
throw new NoViableAltException(this);
|
||||
}
|
||||
_ctx.stop = _input.LT(-1);
|
||||
setState(48);
|
||||
setState(56);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,3,_ctx);
|
||||
while ( _alt!=2 && _alt!=org.antlr.v4.runtime.atn.ATN.INVALID_ALT_NUMBER ) {
|
||||
@ -448,14 +486,14 @@ public class LoopParser extends Parser {
|
||||
{
|
||||
_localctx = new ProgProgContext(new ProgContext(_parentctx, _parentState));
|
||||
pushNewRecursionContext(_localctx, _startState, RULE_prog);
|
||||
setState(44);
|
||||
setState(52);
|
||||
if (!(precpred(_ctx, 1))) throw new FailedPredicateException(this, "precpred(_ctx, 1)");
|
||||
setState(45);
|
||||
setState(53);
|
||||
prog(2);
|
||||
}
|
||||
}
|
||||
}
|
||||
setState(50);
|
||||
setState(58);
|
||||
_errHandler.sync(this);
|
||||
_alt = getInterpreter().adaptivePredict(_input,3,_ctx);
|
||||
}
|
||||
@ -488,38 +526,43 @@ public class LoopParser extends Parser {
|
||||
}
|
||||
|
||||
public static final String _serializedATN =
|
||||
"\u0004\u0001\f4\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
|
||||
"\u0004\u0001\u000e<\u0002\u0000\u0007\u0000\u0002\u0001\u0007\u0001\u0002"+
|
||||
"\u0002\u0007\u0002\u0002\u0003\u0007\u0003\u0001\u0000\u0001\u0000\u0001"+
|
||||
"\u0000\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001\u0001"+
|
||||
"\u0001\u0003\u0001\u0012\b\u0001\u0001\u0002\u0001\u0002\u0001\u0002\u0001"+
|
||||
"\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0001"+
|
||||
"\u0002\u0001\u0002\u0001\u0002\u0001\u0002\u0003\u0002!\b\u0002\u0001"+
|
||||
"\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001"+
|
||||
"\u0003\u0001\u0003\u0003\u0003+\b\u0003\u0001\u0003\u0001\u0003\u0005"+
|
||||
"\u0003/\b\u0003\n\u0003\f\u00032\t\u0003\u0001\u0003\u0000\u0001\u0006"+
|
||||
"\u0004\u0000\u0002\u0004\u0006\u0000\u00004\u0000\b\u0001\u0000\u0000"+
|
||||
"\u0000\u0002\u0011\u0001\u0000\u0000\u0000\u0004 \u0001\u0000\u0000\u0000"+
|
||||
"\u0006*\u0001\u0000\u0000\u0000\b\t\u0003\u0006\u0003\u0000\t\n\u0005"+
|
||||
"\u0000\u0000\u0001\n\u0001\u0001\u0000\u0000\u0000\u000b\f\u0005\b\u0000"+
|
||||
"\u0000\f\r\u0005\u0001\u0000\u0000\r\u0012\u0005\t\u0000\u0000\u000e\u000f"+
|
||||
"\u0005\b\u0000\u0000\u000f\u0010\u0005\u0002\u0000\u0000\u0010\u0012\u0005"+
|
||||
"\t\u0000\u0000\u0011\u000b\u0001\u0000\u0000\u0000\u0011\u000e\u0001\u0000"+
|
||||
"\u0000\u0000\u0012\u0003\u0001\u0000\u0000\u0000\u0013\u0014\u0005\b\u0000"+
|
||||
"\u0000\u0014\u0015\u0005\u0003\u0000\u0000\u0015\u0016\u0003\u0002\u0001"+
|
||||
"\u0000\u0016\u0017\u0005\u0004\u0000\u0000\u0017!\u0001\u0000\u0000\u0000"+
|
||||
"\u0018\u0019\u0005\b\u0000\u0000\u0019\u001a\u0005\u0003\u0000\u0000\u001a"+
|
||||
"\u001b\u0005\b\u0000\u0000\u001b!\u0005\u0004\u0000\u0000\u001c\u001d"+
|
||||
"\u0005\b\u0000\u0000\u001d\u001e\u0005\u0003\u0000\u0000\u001e\u001f\u0005"+
|
||||
"\t\u0000\u0000\u001f!\u0005\u0004\u0000\u0000 \u0013\u0001\u0000\u0000"+
|
||||
"\u0000 \u0018\u0001\u0000\u0000\u0000 \u001c\u0001\u0000\u0000\u0000!"+
|
||||
"\u0005\u0001\u0000\u0000\u0000\"#\u0006\u0003\uffff\uffff\u0000#+\u0003"+
|
||||
"\u0004\u0002\u0000$%\u0005\u0005\u0000\u0000%&\u0005\b\u0000\u0000&\'"+
|
||||
"\u0005\u0006\u0000\u0000\'(\u0003\u0006\u0003\u0000()\u0005\u0007\u0000"+
|
||||
"\u0000)+\u0001\u0000\u0000\u0000*\"\u0001\u0000\u0000\u0000*$\u0001\u0000"+
|
||||
"\u0000\u0000+0\u0001\u0000\u0000\u0000,-\n\u0001\u0000\u0000-/\u0003\u0006"+
|
||||
"\u0003\u0002.,\u0001\u0000\u0000\u0000/2\u0001\u0000\u0000\u00000.\u0001"+
|
||||
"\u0000\u0000\u000001\u0001\u0000\u0000\u00001\u0007\u0001\u0000\u0000"+
|
||||
"\u000020\u0001\u0000\u0000\u0000\u0004\u0011 *0";
|
||||
"\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0001"+
|
||||
"\u0003\u0001\u0003\u0001\u0003\u0001\u0003\u0003\u00033\b\u0003\u0001"+
|
||||
"\u0003\u0001\u0003\u0005\u00037\b\u0003\n\u0003\f\u0003:\t\u0003\u0001"+
|
||||
"\u0003\u0000\u0001\u0006\u0004\u0000\u0002\u0004\u0006\u0000\u0000=\u0000"+
|
||||
"\b\u0001\u0000\u0000\u0000\u0002\u0011\u0001\u0000\u0000\u0000\u0004 "+
|
||||
"\u0001\u0000\u0000\u0000\u00062\u0001\u0000\u0000\u0000\b\t\u0003\u0006"+
|
||||
"\u0003\u0000\t\n\u0005\u0000\u0000\u0001\n\u0001\u0001\u0000\u0000\u0000"+
|
||||
"\u000b\f\u0005\n\u0000\u0000\f\r\u0005\u0001\u0000\u0000\r\u0012\u0005"+
|
||||
"\u000b\u0000\u0000\u000e\u000f\u0005\n\u0000\u0000\u000f\u0010\u0005\u0002"+
|
||||
"\u0000\u0000\u0010\u0012\u0005\u000b\u0000\u0000\u0011\u000b\u0001\u0000"+
|
||||
"\u0000\u0000\u0011\u000e\u0001\u0000\u0000\u0000\u0012\u0003\u0001\u0000"+
|
||||
"\u0000\u0000\u0013\u0014\u0005\n\u0000\u0000\u0014\u0015\u0005\u0003\u0000"+
|
||||
"\u0000\u0015\u0016\u0003\u0002\u0001\u0000\u0016\u0017\u0005\u0004\u0000"+
|
||||
"\u0000\u0017!\u0001\u0000\u0000\u0000\u0018\u0019\u0005\n\u0000\u0000"+
|
||||
"\u0019\u001a\u0005\u0003\u0000\u0000\u001a\u001b\u0005\n\u0000\u0000\u001b"+
|
||||
"!\u0005\u0004\u0000\u0000\u001c\u001d\u0005\n\u0000\u0000\u001d\u001e"+
|
||||
"\u0005\u0003\u0000\u0000\u001e\u001f\u0005\u000b\u0000\u0000\u001f!\u0005"+
|
||||
"\u0004\u0000\u0000 \u0013\u0001\u0000\u0000\u0000 \u0018\u0001\u0000\u0000"+
|
||||
"\u0000 \u001c\u0001\u0000\u0000\u0000!\u0005\u0001\u0000\u0000\u0000\""+
|
||||
"#\u0006\u0003\uffff\uffff\u0000#3\u0003\u0004\u0002\u0000$%\u0005\u0005"+
|
||||
"\u0000\u0000%&\u0005\n\u0000\u0000&\'\u0005\u0006\u0000\u0000\'(\u0003"+
|
||||
"\u0006\u0003\u0000()\u0005\u0007\u0000\u0000)3\u0001\u0000\u0000\u0000"+
|
||||
"*+\u0005\b\u0000\u0000+,\u0005\n\u0000\u0000,-\u0005\t\u0000\u0000-.\u0005"+
|
||||
"\u000b\u0000\u0000./\u0005\u0006\u0000\u0000/0\u0003\u0006\u0003\u0000"+
|
||||
"01\u0005\u0007\u0000\u000013\u0001\u0000\u0000\u00002\"\u0001\u0000\u0000"+
|
||||
"\u00002$\u0001\u0000\u0000\u00002*\u0001\u0000\u0000\u000038\u0001\u0000"+
|
||||
"\u0000\u000045\n\u0001\u0000\u000057\u0003\u0006\u0003\u000264\u0001\u0000"+
|
||||
"\u0000\u00007:\u0001\u0000\u0000\u000086\u0001\u0000\u0000\u000089\u0001"+
|
||||
"\u0000\u0000\u00009\u0007\u0001\u0000\u0000\u0000:8\u0001\u0000\u0000"+
|
||||
"\u0000\u0004\u0011 28";
|
||||
public static final ATN _ATN =
|
||||
new ATNDeserializer().deserialize(_serializedATN.toCharArray());
|
||||
static {
|
||||
|
@ -1,4 +1,4 @@
|
||||
// Generated from grammar/Loop.g4 by ANTLR 4.13.1
|
||||
// Generated from Loop.g4 by ANTLR 4.13.1
|
||||
package parser.grammar;
|
||||
import org.antlr.v4.runtime.tree.ParseTreeVisitor;
|
||||
|
||||
@ -58,6 +58,13 @@ public interface LoopVisitor<T> extends ParseTreeVisitor<T> {
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitLoop(LoopParser.LoopContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code While}
|
||||
* labeled alternative in {@link LoopParser#prog}.
|
||||
* @param ctx the parse tree
|
||||
* @return the visitor result
|
||||
*/
|
||||
T visitWhile(LoopParser.WhileContext ctx);
|
||||
/**
|
||||
* Visit a parse tree produced by the {@code ProgProg}
|
||||
* labeled alternative in {@link LoopParser#prog}.
|
||||
|
Loading…
Reference in New Issue
Block a user