From 83bcdd5d51e81abff891a29fc2485e2196dbfed9 Mon Sep 17 00:00:00 2001
From: bramdekker <b.dekker16@hotmail.com>
Date: Thu, 7 Apr 2022 18:24:46 +0200
Subject: [PATCH 1/5] sufficient qualification implemented

---
 .../babycobolcompiler/builder/Convertor.kt    |  20 ++-
 .../babycobolcompiler/checker/Checker.kt      |  50 ++++++-
 .../babycobolcompiler/ir/IRIdentifier.kt      |   4 +-
 .../util/IndexedIdentifierUtils.kt            |  16 +-
 .../babycobolcompiler/util/Picture.kt         |  29 +++-
 .../babycobolcompiler/util/SymbolTable.kt     | 105 ++++++++++++-
 .../checker/DataDivisionCheckerTest.kt        |  97 +++++++++++-
 .../babycobolcompiler/ir/IRAddTest.kt         |   2 -
 .../ir/IRDataDivisionTest.kt                  | 141 +++++++++++++++++-
 .../babycobolcompiler/ir/IREvaluateTest.kt    |   2 +-
 .../babycobolcompiler/ir/IRIfTest.kt          |   2 +-
 .../babycobolcompiler/ir/IRMultiplyTest.kt    |   2 +-
 .../babycobolcompiler/ir/IRParagraphTest.kt   |   2 +-
 13 files changed, 440 insertions(+), 32 deletions(-)

diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/builder/Convertor.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/builder/Convertor.kt
index 129ec2d..1eb1089 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/builder/Convertor.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/builder/Convertor.kt
@@ -3,9 +3,7 @@ package com.gitlab.legoatoom.babycobolcompiler.builder
 import antlr.BabyCobol.*
 import antlr.BabyCobolBaseVisitor
 import com.gitlab.legoatoom.babycobolcompiler.ir.*
-import com.gitlab.legoatoom.babycobolcompiler.util.SymbolTable
-import com.gitlab.legoatoom.babycobolcompiler.util.getIdentifierName
-import com.gitlab.legoatoom.babycobolcompiler.util.getIndexString
+import com.gitlab.legoatoom.babycobolcompiler.util.*
 import org.antlr.v4.runtime.tree.ParseTree
 import java.util.*
 
@@ -401,7 +399,8 @@ class Convertor(private var symbolTable: SymbolTable) : BabyCobolBaseVisitor<IRH
      * @param ctx IntLitContext as defined by the BabyCobol class generated by ANTLR.
      * @return an IRLiteral.IRIntLit object representing the integer literal in IR.
      */
-    override fun visitIntLit(ctx: IntLitContext): IRLiteral.IRIntLit = IRLiteral.IRIntLit(ctx.getStart().text.toBigInteger())
+    override fun visitIntLit(ctx: IntLitContext): IRLiteral.IRIntLit =
+        IRLiteral.IRIntLit(ctx.getStart().text.toBigInteger())
 
     /**
      * Visitor for the **NumLiteral** token.
@@ -434,16 +433,23 @@ class Convertor(private var symbolTable: SymbolTable) : BabyCobolBaseVisitor<IRH
      * @return an IRIdentifier object representing the identifier in IR.
      */
     override fun visitIdentifier(ctx: IdentifierContext): IRIdentifier {
+        // Paragraphs identifiers are not in the symbol table. Must be altered if PERFORM is implemented.
+        val parent = ctx.getParent()
+        if (parent is ParagraphContext) return IRIdentifier(ctx.text, "")
+
+        // Get the full name of the identifier.
+        val fullId = this.symbolTable.getFullIdentifierName(getIdentifierId(ctx))
+        val fullName = getIdentifierNameFromId(fullId!!)
+
         // Get the indexString of the identifier.
         val indexString = getIndexString(ctx)
 
         // If there are any indices use the IRIndexedIdentifier to create Kotlin code for it.
         if (indexString != null) {
-            val name = getIdentifierName(ctx)
-            return IRIdentifier(name, indexString)
+            return IRIdentifier(fullName, indexString)
         }
 
-        return IRIdentifier(ctx.text, "")
+        return IRIdentifier(fullName, "")
     }
 
     override fun visitTrueLit(ctx: TrueLitContext?): IRLiteral.IRTrueLit {
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
index 8dffe75..fba4da1 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
@@ -87,7 +87,13 @@ class Checker(private var symbolTable: SymbolTable) : BabyCobolBaseListener() {
             if (entry.occursClause() != null) {
                 // Check if n in OCCURS-clause is bigger or equal to 1
                 if (entry.occursClause().n.text.toInt() < 1) {
-                    addError(ctx.getStart(), 20, "OCCURS-clause must have a positive integer greater than 1, but is ${entry.occursClause().n.text.toInt()} for field '${id.joinToString(" OF ")}'")
+                    addError(
+                        ctx.getStart(),
+                        20,
+                        "OCCURS-clause must have a positive integer greater than 1, but is ${entry.occursClause().n.text.toInt()} for field '${
+                            id.joinToString(" OF ")
+                        }'"
+                    )
                 }
 
                 setIdentifierOccurs(id, entry.occursClause().n.text)
@@ -97,7 +103,13 @@ class Checker(private var symbolTable: SymbolTable) : BabyCobolBaseListener() {
                 while (parentId.isNotEmpty()) {
                     if (getBabyCobolType(parentId) != null) {
                         println("Found an error with occurs and picture clauses!")
-                        addError(ctx.getStart(), 20, "Parent '${parentId.joinToString(" OF ")}' has a PICTURE-clause so nested fields cannot have an OCCURS-clause for field '${id.joinToString(" OF ")}'")
+                        addError(
+                            ctx.getStart(),
+                            20,
+                            "Parent '${parentId.joinToString(" OF ")}' has a PICTURE-clause so nested fields cannot have an OCCURS-clause for field '${
+                                id.joinToString(" OF ")
+                            }'"
+                        )
                     }
                     parentId = parentId.drop(1)
                 }
@@ -406,6 +418,14 @@ class Checker(private var symbolTable: SymbolTable) : BabyCobolBaseListener() {
 
         var currentId: BabyCobol.IdentifierContext? = ctx
 
+        // Check if the current id is unambiguous.
+        if (currentId != null) {
+            val id = getIdentifierId(currentId)
+            if (!isUnambiguousIdentifier(id)) {
+                addError(ctx.getStart(), 20, "Identifier is ambiguous: '${id.joinToString(" OF ")}'")
+            }
+        }
+
         // Check if the current identifier and all its parent are valid.
         while (currentId != null) {
             // Check if current identifier is valid.
@@ -427,7 +447,7 @@ class Checker(private var symbolTable: SymbolTable) : BabyCobolBaseListener() {
      */
     private fun checkIdentifier(ctx: BabyCobol.IdentifierContext) {
         // Get the id as a list of strings.
-        val id = getIdentifierId(ctx)
+        val id = getFullName(getIdentifierId(ctx))
         val index = getLeftSubtreeIndex(ctx)
 
         // Check if the identifier:
@@ -437,8 +457,8 @@ class Checker(private var symbolTable: SymbolTable) : BabyCobolBaseListener() {
         //     has an index and the index is valid for this identifier (not out of bounds)
         //
         // If all checks pass, set the type of the node by getting the BabyCobol type from the identifier.
-        if (!isValidIdentifier(id)) {
-            addError(ctx.getStart(), 16, "Unresolved reference: '${id.joinToString(" OF ")}'")
+        if (id == null || !isValidIdentifier(id)) {
+            addError(ctx.getStart(), 16, "Unresolved reference: '${id?.joinToString(" OF ")}'")
         } else if (index == null && isArrayIdentifier(id)) {
             addError(ctx.getStart(), 17, "Array needs an index: '${id.joinToString(" OF ")}'")
         } else if (index != null && !isArrayIdentifier(id)) {
@@ -517,6 +537,16 @@ class Checker(private var symbolTable: SymbolTable) : BabyCobolBaseListener() {
         return this.symbolTable.getParents(lvlNum, line)
     }
 
+    /**
+     * Helpful method to get the full name of an identifier.
+     *
+     * @param id The identifier of the field (could be full or not)
+     * @returns The full name of the identifier as a [List] of [String]s.
+     */
+    private fun getFullName(id: List<String>): List<String>? {
+        return this.symbolTable.getFullIdentifierName(id)
+    }
+
     /**
      * Helpful method to check if identifier is valid.
      *
@@ -547,6 +577,16 @@ class Checker(private var symbolTable: SymbolTable) : BabyCobolBaseListener() {
         return this.symbolTable.isArray(id)
     }
 
+    /**
+     * Helpful method to check if identifier is unambiguous.
+     *
+     * @param id The name of the identifier.
+     * @returns True if identifier is unambiguous, false otherwise.
+     */
+    private fun isUnambiguousIdentifier(id: List<String>): Boolean {
+        return this.symbolTable.isUnambiguous(id)
+    }
+
     /**
      * Helpful method to get BabyCobol [Type] of the identifier.
      *
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIdentifier.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIdentifier.kt
index 9026348..48b6890 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIdentifier.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIdentifier.kt
@@ -9,9 +9,9 @@ class IRIdentifier(
     // Probably other info here later too, such as picture clause. (aka type)
     override fun convert(): String {
         if (indexString.isNotEmpty()) {
-            return "$name$indexString"
+            return "_$name$indexString"
         }
 
-        return  "_" + name.lowercase(Locale.getDefault())
+        return "_" + name.lowercase(Locale.getDefault())
     }
 }
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/IndexedIdentifierUtils.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/IndexedIdentifierUtils.kt
index 80b2048..1eb8e16 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/IndexedIdentifierUtils.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/IndexedIdentifierUtils.kt
@@ -1,6 +1,7 @@
 package com.gitlab.legoatoom.babycobolcompiler.util
 
 import antlr.BabyCobol
+import org.antlr.v4.runtime.tree.TerminalNode
 
 /**
  * A helper function to get the value of an index of an identifier. The index is represented as a [String] with
@@ -36,8 +37,9 @@ fun getIdentifierId(identifier: BabyCobol.IdentifierContext): List<String> {
         res += getIdentifierId(right)
     }
 
-    if (identifier.ID() != null) {
-        res += identifier.ID().text
+    // Get the text of the identifier if its child is a terminal node, except if it is an INDEX.
+    if (identifier.getChild(0) is TerminalNode && identifier.INDEX() == null) {
+        res += identifier.text
     }
 
     return res
@@ -56,6 +58,16 @@ fun getIdentifierName(identifier: BabyCobol.IdentifierContext): String {
     return "_" + id.joinToString("of").lowercase()
 }
 
+/**
+ * A helper function to get the name from the identifier as a [String] from as id, e.g. a [List] of [String]s.
+ *
+ * @param id The id of the identifier as a [List] of [String]s.
+ * @returns The name of the identifier as a [String].
+ */
+fun getIdentifierNameFromId(id: List<String>): String {
+    return id.joinToString("of").lowercase()
+}
+
 /**
  * A helper function to get the index of the left-subtree from the top-level identifier node. It just takes the
  * first index it encounters. If there is no index present, it returns null.
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/Picture.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/Picture.kt
index ac37a35..6f27471 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/Picture.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/Picture.kt
@@ -1,12 +1,21 @@
 package com.gitlab.legoatoom.babycobolcompiler.util
 
 // TODO: maybe compile then import this in the generated program.
-open class Picture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) {
+open class Picture(
+    private val regex: Regex,
+    private val len: Int,
+    private val padSymbol: Char,
+    private val name: String
+) {
     private var value: String = padSymbol.toString().repeat(len)
 
-    open fun getValue(): Any { return this.value }
+    open fun getValue(): Any {
+        return this.value
+    }
 
-    override fun toString(): String { return this.value }
+    override fun toString(): String {
+        return this.value
+    }
 
     fun setValue(newVal: String) {
         // Check length of newVal. Pad to left with spaces / 0's or cut left most part of string.
@@ -26,13 +35,23 @@ open class Picture(private val regex: Regex, private val len: Int, private val p
     }
 }
 
-class IntPicture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) : Picture(regex, len, padSymbol, name) {
+class IntPicture(
+    private val regex: Regex,
+    private val len: Int,
+    private val padSymbol: Char,
+    private val name: String
+) : Picture(regex, len, padSymbol, name) {
     override fun getValue(): java.math.BigInteger {
         return super.getValue().toString().toBigInteger()
     }
 }
 
-class StringPicture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) : Picture(regex, len, padSymbol, name) {
+class StringPicture(
+    private val regex: Regex,
+    private val len: Int,
+    private val padSymbol: Char,
+    private val name: String
+) : Picture(regex, len, padSymbol, name) {
     override fun getValue(): String {
         return super.getValue().toString()
     }
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/SymbolTable.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/SymbolTable.kt
index ba77f36..9e1102c 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/SymbolTable.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/util/SymbolTable.kt
@@ -105,7 +105,50 @@ class SymbolTable(
         return curlyBracketContents.replace(sizedRegex.toString(), "").drop(1).dropLast(1)
     }
 
-    // TODO: must be altered for sufficient qualification.
+    /**
+     * Helpful method to get the full name of an identifier as a [String].
+     * @param id The id of the identifier.
+     * @returns A [String] which represents the full name of the identifier.
+     */
+    fun getFullIdentifierName(id: List<String>): List<String>? {
+        val len = id.size
+        if (len == 0) return null
+        val field = id[0]
+
+        // Check all id's in the symbol table
+        for (identifier in this.identifiers.keys) {
+            // The field names must be the same.
+            if (identifier.first() == field) {
+                // If length is only 1 we found it
+                if (len == 1) return identifier
+
+                // Loop over the parents of the id. If we cannot find a parent of id in the current
+                // identifier we now this is not a match. If all parents of id match at ascending indices, we have
+                // found a match.
+                var curIdx = 1
+                for (parent in id.drop(1)) {
+                    // Make a list of indices that contain the parent and get the lowest index greater or equal to
+                    // curIdx.
+                    val parIndices = identifier.mapIndexedNotNull { index, elem -> index.takeIf { elem == parent } }
+                    val parIdx = parIndices.find { it >= curIdx }
+
+                    // If no matching indices were found or they are not greater or equal to the current index, we know
+                    // we did not find a match.
+                    if (parIndices.isEmpty() || parIdx == null) break
+
+                    // Check if we are done
+                    if (parent == id.last()) {
+                        return identifier
+                    } else {
+                        // Update the current index.
+                        curIdx = parIdx
+                    }
+                }
+            }
+        }
+        return null
+    }
+
     /**
      * Helpful method to check if an id is an valid (declared) identifier.
      *
@@ -113,9 +156,11 @@ class SymbolTable(
      * @return true if id is defined in the symbol table, false otherwise.
      */
     fun isValidIdentifier(id: List<String>): Boolean {
-        if (!this.identifiers.containsKey(id)) return false
+        for (symbolTableId in this.identifiers.keys) {
+            if (symbolTableId.containsAll(id)) return true
+        }
 
-        return true
+        return false
     }
 
     /**
@@ -138,9 +183,63 @@ class SymbolTable(
      * @return true if id is an array, false otherwise.
      */
     fun isArray(id: List<String>): Boolean {
+        if (getIdentifierOccurs(id) == null) return false
         return getIdentifierOccurs(id)!! > 1
     }
 
+    /**
+     * Helpful method to check if an id is unambiguous.
+     *
+     * @param id The name of the identifier.
+     * @return true if id is unambiguous, false otherwise.
+     */
+    fun isUnambiguous(id: List<String>): Boolean {
+        val len = id.size
+        if (len == 0) return false
+        val field = id[0]
+        var count = 0;
+
+        // Check all id's in the symbol table
+        for (identifier in this.identifiers.keys) {
+            // The field names must be the same.
+            if (identifier.first() == field) {
+                // If length is only 1 we found a match
+                if (len == 1) {
+                    count++
+                    continue
+                }
+
+                // Loop over the parents of the id. If we cannot find a parent of id in the current
+                // identifier we now this is not a match. If all parents of id match at ascending indices, we have
+                // found a match.
+                var curIdx = 1
+                for (parent in id.drop(1)) {
+                    // Make a list of indices that contain the parent and get the lowest index greater or equal to
+                    // curIdx.
+                    val parIndices = identifier.mapIndexedNotNull { index, elem -> index.takeIf { elem == parent } }
+                    val parIdx = parIndices.find { it >= curIdx }
+
+                    // If no matching indices were found or they are not greater or equal to the current index, we know
+                    // we did not find a match.
+                    if (parIndices.isEmpty() || parIdx == null) break
+
+                    // Check if we are done
+                    if (parent == id.last()) {
+                        count++
+                        break
+                    } else {
+                        // Update the current index.
+                        curIdx = parIdx
+                    }
+                }
+            }
+        }
+
+        // If exactly 1 field with the al the parent of id exists -> unambiguous
+        if (count == 1) return true
+        return false
+    }
+
     /**
      * Helpful method to get the BabyCobol type of an identifier.
      *
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/DataDivisionCheckerTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/DataDivisionCheckerTest.kt
index 2c72812..b9243b3 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/DataDivisionCheckerTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/DataDivisionCheckerTest.kt
@@ -1,7 +1,8 @@
 package com.gitlab.legoatoom.babycobolcompiler.checker
 
 import com.gitlab.legoatoom.babycobolcompiler.exceptions.BabyCobolCheckerException
-import org.junit.jupiter.api.Test
+import kotlin.test.Test
+import kotlin.test.Ignore
 import kotlin.test.assertFailsWith
 import kotlin.test.assertTrue
 
@@ -150,4 +151,98 @@ internal class DataDivisionCheckerTest {
             tryParseAndCheck(prog)
         }
     }
+
+    @Test
+    fun sufficientQualification() {
+        val prog = """
+            IDENTIFICATION DIVISION.
+                PROGRAM-ID. TEST.
+            DATA DIVISION.
+                01 A.
+                03 B.
+                05 C.
+                07 D PICTURE IS 999.
+                05 E.
+                07 D PICTURE IS 999.
+                07 F PICTURE IS 999.
+            PROCEDURE DIVISION.
+                DISPLAY D OF C.
+                DISPLAY D OF C OF B.
+                DISPLAY D OF C OF A.
+                DISPLAY D OF E.
+                DISPLAY D OF E OF B.
+                DISPLAY D OF E OF A.
+        """.trimIndent()
+
+        assertTrue("Identifiers dont have to be fully specified if there unambiguous") {
+            tryParseAndCheck(prog)
+        }
+    }
+
+    @Test
+    fun insufficientQualification1() {
+        val prog = """
+            IDENTIFICATION DIVISION.
+                PROGRAM-ID. TEST.
+            DATA DIVISION.
+                01 A.
+                03 B.
+                05 C.
+                07 D PICTURE IS 999.
+                05 E.
+                07 D PICTURE IS 999.
+                07 F PICTURE IS 999.
+            PROCEDURE DIVISION.
+                DISPLAY D.
+        """.trimIndent()
+
+        assertFailsWith<BabyCobolCheckerException>("Identifiers cannot be unambiguous") {
+            tryParseAndCheck(prog)
+        }
+    }
+
+    @Test
+    fun insufficientQualification2() {
+        val prog = """
+            IDENTIFICATION DIVISION.
+                PROGRAM-ID. TEST.
+            DATA DIVISION.
+                01 A.
+                03 B.
+                05 C.
+                07 D PICTURE IS 999.
+                05 E.
+                07 D PICTURE IS 999.
+                07 F PICTURE IS 999.
+            PROCEDURE DIVISION.
+                DISPLAY D OF A.
+        """.trimIndent()
+
+        assertFailsWith<BabyCobolCheckerException>("Identifiers cannot be unambiguous") {
+            tryParseAndCheck(prog)
+        }
+    }
+
+    // Like-clause must be merged with this branch first!
+    @Test
+    @Ignore
+    fun insufficientQualificationInLike() {
+        val prog = """
+            IDENTIFICATION DIVISION.
+                PROGRAM-ID. TEST.
+            DATA DIVISION.
+                01 A.
+                03 B.
+                05 C.
+                07 D PICTURE IS 999.
+                05 E.
+                07 D PICTURE IS 999.
+                07 F PICTURE IS 999.
+                01 G LIKE D.
+        """.trimIndent()
+
+        assertFailsWith<BabyCobolCheckerException>("Identifiers cannot be unambiguous, also not in LIKE-clauses") {
+            tryParseAndCheck(prog)
+        }
+    }
 }
\ No newline at end of file
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRAddTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRAddTest.kt
index 3fb91aa..2c81164 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRAddTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRAddTest.kt
@@ -1,10 +1,8 @@
 package com.gitlab.legoatoom.babycobolcompiler.ir
 
-import com.gitlab.legoatoom.babycobolcompiler.exceptions.ConverterException
 import com.gitlab.legoatoom.babycobolcompiler.exceptions.ParserException
 import com.gitlab.legoatoom.babycobolcompiler.util.getConvertedProgram
 import com.gitlab.legoatoom.babycobolcompiler.util.pictureClass
-import org.junit.jupiter.api.Assertions.assertThrows
 import kotlin.test.*
 
 internal class IRAddTest {
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
index 545dbfe..598fa76 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
@@ -2,7 +2,8 @@ package com.gitlab.legoatoom.babycobolcompiler.ir
 
 import com.gitlab.legoatoom.babycobolcompiler.util.getConvertedProgram
 import com.gitlab.legoatoom.babycobolcompiler.util.pictureClass
-import org.junit.jupiter.api.Test
+import kotlin.test.Ignore
+import kotlin.test.Test
 import kotlin.test.assertEquals
 
 internal class IRDataDivisionTest {
@@ -127,4 +128,142 @@ internal class IRDataDivisionTest {
 
         assertEquals(getConvertedProgram(prog), output + "\n\n" + stats + "\n\n\n\n" + pictureClass)
     }
+
+    @Test
+    fun nestedArrayIndicesKeywords() {
+        val prog = """
+            IDENTIFICATION DIVISION.
+                PROGRAM-ID. TEST.
+            DATA DIVISION.
+                01 OF OCCURS 5 TIMES.
+                    05 ADD OCCURS 7 TIMES.
+                        09 BY PICTURE IS 9999 OCCURS 10 TIMES.
+            PROCEDURE DIVISION.
+                ADD 9 TO 6 GIVING BY (10) OF ADD (3) OF OF (1).
+                DISPLAY BY (10) OF ADD (3) OF OF (1).
+                DISPLAY BY (1) OF ADD (3) OF OF (1).
+        """.trimIndent()
+
+        val output = """
+            val _byofaddofof = Array(5) { Array(7) { Array(10) { IntPicture(Regex("^[0-9]{4}${'$'}"), 4, '0', "_byofaddofof") } } }
+        """.trimIndent()
+
+        val stats = """
+            _byofaddofof[0][2][9].setValue((9.toBigInteger().plus(6.toBigInteger())).toString())
+            println(_byofaddofof[0][2][9])
+            println(_byofaddofof[0][2][0])
+        """.trimIndent()
+
+        assertEquals(getConvertedProgram(prog), output + "\n\n" + stats + "\n\n\n\n" + pictureClass)
+    }
+
+    @Test
+    fun sufficientQualification() {
+        val prog = """
+            IDENTIFICATION DIVISION.
+                PROGRAM-ID. TEST.
+            DATA DIVISION.
+                01 A.
+                03 B.
+                05 C.
+                07 D PICTURE IS 999.
+                05 E.
+                07 D PICTURE IS 999.
+                07 F PICTURE IS 999.
+            PROCEDURE DIVISION.
+                DISPLAY D OF C.
+                DISPLAY D OF C OF B.
+                DISPLAY D OF C OF A.
+                DISPLAY D OF E.
+                DISPLAY D OF E OF B.
+                DISPLAY D OF E OF A.   
+        """.trimIndent()
+
+        val output = """
+            var _dofcofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa")
+            var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
+            var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
+        """.trimIndent()
+
+        val stats = """
+            println(_dofcofbofa)
+            println(_dofcofbofa)
+            println(_dofcofbofa)
+            println(_dofeofbofa)
+            println(_dofeofbofa)
+            println(_dofeofbofa)
+        """.trimIndent()
+
+        assertEquals(getConvertedProgram(prog), output + "\n\n" + stats + "\n\n\n\n" + pictureClass)
+    }
+
+    @Test
+    fun sufficientQualificationWithOccurs() {
+        val prog = """
+            IDENTIFICATION DIVISION.
+                PROGRAM-ID. TEST.
+            DATA DIVISION.
+                01 A.
+                03 B.
+                05 C OCCURS 2 TIMES.
+                07 D PICTURE IS 999 OCCURS 5 TIMES.
+                05 E.
+                07 D PICTURE IS 999.
+                07 F PICTURE IS 999.
+            PROCEDURE DIVISION.
+                DISPLAY D (1) OF C (1).
+                DISPLAY D (3) OF C (2) OF B.
+                DISPLAY D (5) OF C (1) OF A.
+                DISPLAY D OF E.
+                DISPLAY D OF E OF B.
+                DISPLAY D OF E OF A.   
+        """.trimIndent()
+
+        val output = """
+            val _dofcofbofa = Array(2) { Array(5) { IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa") } }
+            var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
+            var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
+        """.trimIndent()
+
+        val stats = """
+            println(_dofcofbofa[0][0])
+            println(_dofcofbofa[1][2])
+            println(_dofcofbofa[0][4])
+            println(_dofeofbofa)
+            println(_dofeofbofa)
+            println(_dofeofbofa)
+        """.trimIndent()
+
+        assertEquals(getConvertedProgram(prog), output + "\n\n" + stats + "\n\n\n\n" + pictureClass)
+    }
+
+    // Like-clause must be merged with this branch first!
+    @Test
+    @Ignore
+    fun sufficientQualificationInLike() {
+        val prog = """
+            IDENTIFICATION DIVISION.
+                PROGRAM-ID. TEST.
+            DATA DIVISION.
+                01 A.
+                    03 B.
+                        05 C.
+                            07 D PICTURE IS 999.
+                        05 E.
+                            07 D PICTURE IS 999.
+                            07 F PICTURE IS 999.
+                01 G LIKE D OF E.
+                01 H LIKE D OF C OF B.
+        """.trimIndent()
+
+        val output = """
+            val _dofcofbofa = Array(2) { Array(5) { IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa") } }
+            var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
+            var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
+            var _g = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_g")
+            var _h = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_h")
+        """.trimIndent()
+
+        assertEquals(getConvertedProgram(prog), output + "\n\n\n\n" + pictureClass)
+    }
 }
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IREvaluateTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IREvaluateTest.kt
index 2e70bc4..fa860b5 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IREvaluateTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IREvaluateTest.kt
@@ -1,7 +1,7 @@
 package com.gitlab.legoatoom.babycobolcompiler.ir
 
 import com.gitlab.legoatoom.babycobolcompiler.util.convertionEquals
-import org.junit.jupiter.api.Test
+import kotlin.test.Test
 
 internal class IREvaluateTest {
     @Test
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIfTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIfTest.kt
index 880f368..46b0a6c 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIfTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIfTest.kt
@@ -1,7 +1,7 @@
 package com.gitlab.legoatoom.babycobolcompiler.ir
 
 import com.gitlab.legoatoom.babycobolcompiler.util.convertionEquals
-import org.junit.jupiter.api.Test
+import kotlin.test.Test
 
 internal class IRIfTest {
     @Test
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRMultiplyTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRMultiplyTest.kt
index 450911d..61abe63 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRMultiplyTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRMultiplyTest.kt
@@ -5,7 +5,7 @@ import com.gitlab.legoatoom.babycobolcompiler.exceptions.ParserException
 import com.gitlab.legoatoom.babycobolcompiler.util.BabyCobolError
 import com.gitlab.legoatoom.babycobolcompiler.util.getConvertedProgram
 import com.gitlab.legoatoom.babycobolcompiler.util.pictureClass
-import org.junit.jupiter.api.Test
+import kotlin.test.Test
 import kotlin.test.assertContains
 import kotlin.test.assertEquals
 import kotlin.test.assertFailsWith
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRParagraphTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRParagraphTest.kt
index 221227d..6e7740d 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRParagraphTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRParagraphTest.kt
@@ -2,7 +2,7 @@ package com.gitlab.legoatoom.babycobolcompiler.ir
 
 import com.gitlab.legoatoom.babycobolcompiler.util.getConvertedProgram
 import com.gitlab.legoatoom.babycobolcompiler.util.pictureClass
-import org.junit.jupiter.api.Test
+import kotlin.test.Test
 import kotlin.test.assertEquals
 
 internal class IRParagraphTest {
-- 
GitLab


From ca8d70468a6db4cdd68a7449f56aad285c636174 Mon Sep 17 00:00:00 2001
From: bramdekker <b.dekker16@hotmail.com>
Date: Sat, 23 Apr 2022 20:24:32 +0200
Subject: [PATCH 2/5] new IR tests for sufficient qualification

---
 .../babycobolcompiler/ir/IRProgram.kt         |  55 ++++---
 .../ir/IRDataDivisionTest.kt                  | 146 +++++++++++++++---
 .../babycobolcompiler/ir/IRTestSetup.kt       |  57 ++++---
 3 files changed, 197 insertions(+), 61 deletions(-)

diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRProgram.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRProgram.kt
index 8b22189..fa6963e 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRProgram.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRProgram.kt
@@ -20,24 +20,31 @@ class IRProgram(
         // toString, getValue and setValue methods to handle updates and formatting.
         @Language("kotlin")
         val pictureClass: String = """
-            open class Picture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) {
-                private var value: String = padSymbol.toString().repeat(len)
-                
-                open fun getValue(): Any { return this.value }
-                
-                override fun toString(): String { return this.value }
-                
-                fun setValue(newVal: String) {
-                    // Check length of newVal. Pad to left with spaces / 0's or cut left most part of string.
+            abstract class Picture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) {
+                var internalValue: String = padSymbol.toString().repeat(len)
+            
+                abstract fun getValue(): Any
+                abstract fun setValue(newVal: String)
+                override fun toString(): String { return this.internalValue }
+            }
+            
+            class IntPicture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) : Picture(regex, len, padSymbol, name) {
+                override fun getValue(): java.math.BigInteger {
+                    return super.internalValue.toBigInteger()
+                }
+            
+                override fun setValue(newVal: String) {
+                    // Check length of newVal. Pad to left with 0's if length is smaller, take the first n numbers if 
+                    // the length is bigger.
                     var updatedVal: String = newVal
                     if (newVal.length < len) {
                         updatedVal = newVal.padStart(len, padSymbol)
                     } else if (newVal.length > len) {
                         updatedVal = newVal.takeLast(len)
                     }
-
+            
                     // Check if value correspond with regex
-                    if (regex.matches(updatedVal)) this.value = updatedVal
+                    if (regex.matches(updatedVal)) this.internalValue = updatedVal
                     else {
                         val errMessage = "Cannot assign " + updatedVal + " to data entry " + this.name
                         throw Exception(errMessage)
@@ -45,15 +52,27 @@ class IRProgram(
                 }
             }
             
-            class IntPicture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) : Picture(regex, len, padSymbol, name) {
-                override fun getValue(): java.math.BigInteger {
-                    return super.getValue().toString().toBigInteger()
-                }
-            }
-            
             class StringPicture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) : Picture(regex, len, padSymbol, name) {
                 override fun getValue(): String {
-                    return super.getValue().toString()
+                    return super.internalValue
+                }
+            
+                override fun setValue(newVal: String) {
+                    // Check length of newVal. Pad to right with spaces if length is smaller, take the last n characters if 
+                    // the length is bigger.
+                    var updatedVal: String = newVal
+                    if (newVal.length < len) {
+                        updatedVal = newVal.padEnd(len, padSymbol)
+                    } else if (newVal.length > len) {
+                        updatedVal = newVal.takeLast(len)
+                    }
+            
+                    // Check if value correspond with regex
+                    if (regex.matches(updatedVal)) this.internalValue = updatedVal
+                    else {
+                        val errMessage = "Cannot assign " + updatedVal + " to data entry " + this.name
+                        throw Exception(errMessage)
+                    }
                 }
             }
         """.trimIndent()
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
index 83f432b..ffd8c6e 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
@@ -3,6 +3,7 @@ package com.gitlab.legoatoom.babycobolcompiler.ir
 import com.gitlab.legoatoom.babycobolcompiler.checker.SymbolTable
 import com.gitlab.legoatoom.babycobolcompiler.util.IdentifierInfo
 import kotlin.test.Test
+import kotlin.test.Ignore
 import kotlin.test.assertEquals
 
 internal class IRDataDivisionTest: IRTestSetup() {
@@ -98,14 +99,14 @@ internal class IRDataDivisionTest: IRTestSetup() {
             IRAdd(
                 IRLiteral.IRIntLit(9.toBigInteger()),
                 IRLiteral.IRIntLit(6.toBigInteger()),
-                IRIdentifier("_zofyofx", "[0][2][9]"),
+                IRIdentifier("zofyofx", "[0][2][9]"),
                 false, false
             ),
             IRDisplay(listOf(
-                IRDispExpr(IRIdentifier("_zofyofx", "[0][2][9]"))
+                IRDispExpr(IRIdentifier("zofyofx", "[0][2][9]"))
             ), false),
             IRDisplay(listOf(
-                IRDispExpr(IRIdentifier("_zofyofx", "[0][2][0]"))
+                IRDispExpr(IRIdentifier("zofyofx", "[0][2][0]"))
             ), false)
         ))
         val programResult = getProgramResultFromSentences(symbolTable = symbolTable, sentences = listOf(sentences))
@@ -125,6 +126,31 @@ internal class IRDataDivisionTest: IRTestSetup() {
 
     @Test
     fun nestedArrayIndicesKeywords() {
+        val symbolTable = SymbolTable(identifiers = linkedMapOf(
+            listOf("OF") to IdentifierInfo(1, 1, occurs = 5),
+            listOf("ADD", "OF") to IdentifierInfo(5, 2, occurs = 7),
+            listOf("BY", "ADD", "OF") to IdentifierInfo(9, 3, Regex("^[0-9]{4}${'$'}"), '0', 4, returnType = "Int", occurs = 10)
+        ))
+        val sentences = IRSentence(listOf(
+            IRAdd(
+                IRLiteral.IRIntLit(9.toBigInteger()),
+                IRLiteral.IRIntLit(6.toBigInteger()),
+                IRIdentifier("byofaddofof", "[0][2][9]"),
+                false, false
+            ),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("byofaddofof", "[0][2][9]"))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("byofaddofof", "[0][2][0]"))
+            ), false)
+        ))
+        val programResult = getProgramResultFromSentences(symbolTable = symbolTable, sentences = listOf(sentences))
+
+        val varDecls = """
+            val _byofaddofof = Array(5) { Array(7) { Array(10) { IntPicture(Regex("^[0-9]{4}${'$'}"), 4, '0', "_byofaddofof") } } }
+        """.trimIndent()
+
         val prog = """
             IDENTIFICATION DIVISION.
                 PROGRAM-ID. TEST.
@@ -138,21 +164,54 @@ internal class IRDataDivisionTest: IRTestSetup() {
                 DISPLAY BY (1) OF ADD (3) OF OF (1).
         """.trimIndent()
 
-        val output = """
-            val _byofaddofof = Array(5) { Array(7) { Array(10) { IntPicture(Regex("^[0-9]{4}${'$'}"), 4, '0', "_byofaddofof") } } }
-        """.trimIndent()
-
         val stats = """
             _byofaddofof[0][2][9].setValue((9.toBigInteger().plus(6.toBigInteger())).toString())
             println(_byofaddofof[0][2][9])
             println(_byofaddofof[0][2][0])
         """.trimIndent()
 
-        assertEquals(getConvertedProgram(prog), output + "\n\n" + stats + "\n\n\n\n" + pictureClass)
+        assertEquals(getExpectedOutput(stats = stats, varDecls = varDecls), programResult)
     }
 
     @Test
     fun sufficientQualification() {
+        val symbolTable = SymbolTable(identifiers = linkedMapOf(
+            listOf("A") to IdentifierInfo(1, 1),
+            listOf("B", "A") to IdentifierInfo(3, 2),
+            listOf("C", "B", "A") to IdentifierInfo(5, 3),
+            listOf("D", "C", "B", "A") to IdentifierInfo(7, 4, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int"),
+            listOf("E", "B", "A") to IdentifierInfo(5, 5),
+            listOf("D", "E", "B", "A") to IdentifierInfo(7, 6, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int"),
+            listOf("F", "E", "B", "A") to IdentifierInfo(7, 7, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int")
+        ))
+        val sentences = IRSentence(listOf(
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofcofbofa", ""))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofcofbofa", ""))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofcofbofa", ""))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofeofbofa", ""))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofeofbofa", ""))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofeofbofa", ""))
+            ), false)
+        ))
+        val programResult = getProgramResultFromSentences(symbolTable = symbolTable, sentences = listOf(sentences))
+
+        val varDecls = """
+            var _dofcofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa")
+            var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
+            var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
+        """.trimIndent()
+
         val prog = """
             IDENTIFICATION DIVISION.
                 PROGRAM-ID. TEST.
@@ -173,12 +232,6 @@ internal class IRDataDivisionTest: IRTestSetup() {
                 DISPLAY D OF E OF A.   
         """.trimIndent()
 
-        val output = """
-            var _dofcofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa")
-            var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
-            var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
-        """.trimIndent()
-
         val stats = """
             println(_dofcofbofa)
             println(_dofcofbofa)
@@ -188,11 +241,48 @@ internal class IRDataDivisionTest: IRTestSetup() {
             println(_dofeofbofa)
         """.trimIndent()
 
-        assertEquals(getConvertedProgram(prog), output + "\n\n" + stats + "\n\n\n\n" + pictureClass)
+        assertEquals(getExpectedOutput(stats = stats, varDecls = varDecls), programResult)
     }
 
     @Test
     fun sufficientQualificationWithOccurs() {
+        val symbolTable = SymbolTable(identifiers = linkedMapOf(
+            listOf("A") to IdentifierInfo(1, 1),
+            listOf("B", "A") to IdentifierInfo(3, 2),
+            listOf("C", "B", "A") to IdentifierInfo(5, 3, occurs = 2),
+            listOf("D", "C", "B", "A") to IdentifierInfo(7, 4, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int", occurs = 5),
+            listOf("E", "B", "A") to IdentifierInfo(5, 5),
+            listOf("D", "E", "B", "A") to IdentifierInfo(7, 6, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int"),
+            listOf("F", "E", "B", "A") to IdentifierInfo(7, 7, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int")
+        ))
+        val sentences = IRSentence(listOf(
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofcofbofa", "[0][0]"))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofcofbofa", "[1][2]"))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofcofbofa", "[0][4]"))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofeofbofa", ""))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofeofbofa", ""))
+            ), false),
+            IRDisplay(listOf(
+                IRDispExpr(IRIdentifier("dofeofbofa", ""))
+            ), false)
+        ))
+        val programResult = getProgramResultFromSentences(symbolTable = symbolTable, sentences = listOf(sentences))
+
+        val varDecls = """
+            val _dofcofbofa = Array(2) { Array(5) { IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa") } }
+            var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
+            var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
+        """.trimIndent()
+
         val prog = """
             IDENTIFICATION DIVISION.
                 PROGRAM-ID. TEST.
@@ -213,12 +303,6 @@ internal class IRDataDivisionTest: IRTestSetup() {
                 DISPLAY D OF E OF A.   
         """.trimIndent()
 
-        val output = """
-            val _dofcofbofa = Array(2) { Array(5) { IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa") } }
-            var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
-            var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
-        """.trimIndent()
-
         val stats = """
             println(_dofcofbofa[0][0])
             println(_dofcofbofa[1][2])
@@ -228,13 +312,27 @@ internal class IRDataDivisionTest: IRTestSetup() {
             println(_dofeofbofa)
         """.trimIndent()
 
-        assertEquals(getConvertedProgram(prog), output + "\n\n" + stats + "\n\n\n\n" + pictureClass)
+        assertEquals(getExpectedOutput(stats = stats, varDecls = varDecls), programResult)
     }
 
     // Like-clause must be merged with this branch first!
     @Test
     @Ignore
     fun sufficientQualificationInLike() {
+        val symbolTable = SymbolTable(identifiers = linkedMapOf(
+            listOf("A") to IdentifierInfo(1, 1),
+            listOf("B", "A") to IdentifierInfo(3, 2),
+            listOf("C", "B", "A") to IdentifierInfo(5, 3),
+            listOf("D", "C", "B", "A") to IdentifierInfo(7, 4, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int"),
+            listOf("E", "B", "A") to IdentifierInfo(5, 5),
+            listOf("D", "E", "B", "A") to IdentifierInfo(7, 6, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int"),
+            listOf("F", "E", "B", "A") to IdentifierInfo(7, 7, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int"),
+            listOf("G") to IdentifierInfo(7, 6, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int"),
+            listOf("H") to IdentifierInfo(7, 4, Regex("^[0-9]{3}${'$'}"), '0', 3, returnType = "Int"),
+            ))
+
+        val programResult = getProgramResultFromSentences(symbolTable = symbolTable)
+
         val prog = """
             IDENTIFICATION DIVISION.
                 PROGRAM-ID. TEST.
@@ -250,7 +348,7 @@ internal class IRDataDivisionTest: IRTestSetup() {
                 01 H LIKE D OF C OF B.
         """.trimIndent()
 
-        val output = """
+        val varDecls = """
             val _dofcofbofa = Array(2) { Array(5) { IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa") } }
             var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
             var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
@@ -258,6 +356,6 @@ internal class IRDataDivisionTest: IRTestSetup() {
             var _h = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_h")
         """.trimIndent()
 
-        assertEquals(getConvertedProgram(prog), output + "\n\n\n\n" + pictureClass)
+        assertEquals(getExpectedOutput(varDecls = varDecls), programResult)
     }
 }
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRTestSetup.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRTestSetup.kt
index 35ecdc9..fc420cc 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRTestSetup.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRTestSetup.kt
@@ -22,40 +22,59 @@ internal open class IRTestSetup {
     }
 
     private val picture = """
-        open class Picture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) {
-            private var value: String = padSymbol.toString().repeat(len)
-            
-            open fun getValue(): Any { return this.value }
-            
-            override fun toString(): String { return this.value }
-            
-            fun setValue(newVal: String) {
-                // Check length of newVal. Pad to left with spaces / 0's or cut left most part of string.
+        abstract class Picture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) {
+            var internalValue: String = padSymbol.toString().repeat(len)
+        
+            abstract fun getValue(): Any
+            abstract fun setValue(newVal: String)
+            override fun toString(): String { return this.internalValue }
+        }
+        
+        class IntPicture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) : Picture(regex, len, padSymbol, name) {
+            override fun getValue(): java.math.BigInteger {
+                return super.internalValue.toBigInteger()
+            }
+        
+            override fun setValue(newVal: String) {
+                // Check length of newVal. Pad to left with 0's if length is smaller, take the first n numbers if 
+                // the length is bigger.
                 var updatedVal: String = newVal
                 if (newVal.length < len) {
                     updatedVal = newVal.padStart(len, padSymbol)
                 } else if (newVal.length > len) {
                     updatedVal = newVal.takeLast(len)
                 }
-
+        
                 // Check if value correspond with regex
-                if (regex.matches(updatedVal)) this.value = updatedVal
+                if (regex.matches(updatedVal)) this.internalValue = updatedVal
                 else {
                     val errMessage = "Cannot assign " + updatedVal + " to data entry " + this.name
                     throw Exception(errMessage)
                 }
             }
         }
-
-        class IntPicture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) : Picture(regex, len, padSymbol, name) {
-            override fun getValue(): java.math.BigInteger {
-                return super.getValue().toString().toBigInteger()
-            }
-        }
-
+        
         class StringPicture(private val regex: Regex, private val len: Int, private val padSymbol: Char, private val name: String) : Picture(regex, len, padSymbol, name) {
             override fun getValue(): String {
-                return super.getValue().toString()
+                return super.internalValue
+            }
+        
+            override fun setValue(newVal: String) {
+                // Check length of newVal. Pad to right with spaces if length is smaller, take the last n characters if 
+                // the length is bigger.
+                var updatedVal: String = newVal
+                if (newVal.length < len) {
+                    updatedVal = newVal.padEnd(len, padSymbol)
+                } else if (newVal.length > len) {
+                    updatedVal = newVal.takeLast(len)
+                }
+        
+                // Check if value correspond with regex
+                if (regex.matches(updatedVal)) this.internalValue = updatedVal
+                else {
+                    val errMessage = "Cannot assign " + updatedVal + " to data entry " + this.name
+                    throw Exception(errMessage)
+                }
             }
         }
     """.trimIndent()
-- 
GitLab


From c53ce5c10ad632dd37588c7f8a907b209ede1326 Mon Sep 17 00:00:00 2001
From: bramdekker <b.dekker16@hotmail.com>
Date: Sat, 23 Apr 2022 20:27:27 +0200
Subject: [PATCH 3/5] removed unused code in IRDataDivisionTest

---
 .../ir/IRDataDivisionTest.kt                  | 70 +------------------
 1 file changed, 1 insertion(+), 69 deletions(-)

diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
index ffd8c6e..f62db91 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDataDivisionTest.kt
@@ -151,19 +151,6 @@ internal class IRDataDivisionTest: IRTestSetup() {
             val _byofaddofof = Array(5) { Array(7) { Array(10) { IntPicture(Regex("^[0-9]{4}${'$'}"), 4, '0', "_byofaddofof") } } }
         """.trimIndent()
 
-        val prog = """
-            IDENTIFICATION DIVISION.
-                PROGRAM-ID. TEST.
-            DATA DIVISION.
-                01 OF OCCURS 5 TIMES.
-                    05 ADD OCCURS 7 TIMES.
-                        09 BY PICTURE IS 9999 OCCURS 10 TIMES.
-            PROCEDURE DIVISION.
-                ADD 9 TO 6 GIVING BY (10) OF ADD (3) OF OF (1).
-                DISPLAY BY (10) OF ADD (3) OF OF (1).
-                DISPLAY BY (1) OF ADD (3) OF OF (1).
-        """.trimIndent()
-
         val stats = """
             _byofaddofof[0][2][9].setValue((9.toBigInteger().plus(6.toBigInteger())).toString())
             println(_byofaddofof[0][2][9])
@@ -212,26 +199,6 @@ internal class IRDataDivisionTest: IRTestSetup() {
             var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
         """.trimIndent()
 
-        val prog = """
-            IDENTIFICATION DIVISION.
-                PROGRAM-ID. TEST.
-            DATA DIVISION.
-                01 A.
-                03 B.
-                05 C.
-                07 D PICTURE IS 999.
-                05 E.
-                07 D PICTURE IS 999.
-                07 F PICTURE IS 999.
-            PROCEDURE DIVISION.
-                DISPLAY D OF C.
-                DISPLAY D OF C OF B.
-                DISPLAY D OF C OF A.
-                DISPLAY D OF E.
-                DISPLAY D OF E OF B.
-                DISPLAY D OF E OF A.   
-        """.trimIndent()
-
         val stats = """
             println(_dofcofbofa)
             println(_dofcofbofa)
@@ -283,26 +250,6 @@ internal class IRDataDivisionTest: IRTestSetup() {
             var _fofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_fofeofbofa")
         """.trimIndent()
 
-        val prog = """
-            IDENTIFICATION DIVISION.
-                PROGRAM-ID. TEST.
-            DATA DIVISION.
-                01 A.
-                03 B.
-                05 C OCCURS 2 TIMES.
-                07 D PICTURE IS 999 OCCURS 5 TIMES.
-                05 E.
-                07 D PICTURE IS 999.
-                07 F PICTURE IS 999.
-            PROCEDURE DIVISION.
-                DISPLAY D (1) OF C (1).
-                DISPLAY D (3) OF C (2) OF B.
-                DISPLAY D (5) OF C (1) OF A.
-                DISPLAY D OF E.
-                DISPLAY D OF E OF B.
-                DISPLAY D OF E OF A.   
-        """.trimIndent()
-
         val stats = """
             println(_dofcofbofa[0][0])
             println(_dofcofbofa[1][2])
@@ -333,21 +280,6 @@ internal class IRDataDivisionTest: IRTestSetup() {
 
         val programResult = getProgramResultFromSentences(symbolTable = symbolTable)
 
-        val prog = """
-            IDENTIFICATION DIVISION.
-                PROGRAM-ID. TEST.
-            DATA DIVISION.
-                01 A.
-                    03 B.
-                        05 C.
-                            07 D PICTURE IS 999.
-                        05 E.
-                            07 D PICTURE IS 999.
-                            07 F PICTURE IS 999.
-                01 G LIKE D OF E.
-                01 H LIKE D OF C OF B.
-        """.trimIndent()
-
         val varDecls = """
             val _dofcofbofa = Array(2) { Array(5) { IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofcofbofa") } }
             var _dofeofbofa = IntPicture(Regex("^[0-9]{3}${'$'}"), 3, '0', "_dofeofbofa")
@@ -358,4 +290,4 @@ internal class IRDataDivisionTest: IRTestSetup() {
 
         assertEquals(getExpectedOutput(varDecls = varDecls), programResult)
     }
-}
+}
\ No newline at end of file
-- 
GitLab


From 5733d1aa1108f8804e046926306e0b709da27626 Mon Sep 17 00:00:00 2001
From: bramdekker <b.dekker16@hotmail.com>
Date: Fri, 29 Apr 2022 13:55:11 +0200
Subject: [PATCH 4/5] Keywords tests + displaying keywords no works

---
 src/main/antlr/BabyCobol.g4                              | 3 +++
 .../legoatoom/babycobolcompiler/builder/Convertor.kt     | 6 ++++++
 .../legoatoom/babycobolcompiler/checker/Checker.kt       | 7 ++++++-
 .../legoatoom/babycobolcompiler/checker/SymbolTable.kt   | 2 ++
 .../legoatoom/babycobolcompiler/ir/IRIdentifier.kt       | 5 +++++
 .../babycobolcompiler/output/DataDivisionOutputTest.kt   | 9 ++++-----
 .../babycobolcompiler/output/KeywordsOutputTest.kt       | 4 ++--
 7 files changed, 28 insertions(+), 8 deletions(-)

diff --git a/src/main/antlr/BabyCobol.g4 b/src/main/antlr/BabyCobol.g4
index e6e178b..a80a48b 100644
--- a/src/main/antlr/BabyCobol.g4
+++ b/src/main/antlr/BabyCobol.g4
@@ -131,9 +131,11 @@ identifier
     | MULTIPLY
     | NO
     | NOT
+    | OCCURS
     | OF
     | OTHER
     | OR
+    | PERFORM
     | PROCEDURE
     | PICTURE
     | SIZE
@@ -141,6 +143,7 @@ identifier
     | STOP
     | SUBTRACT
     | THEN
+    | THROUGH
     | TO
     | TRUE
     | WITH
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/builder/Convertor.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/builder/Convertor.kt
index 34fc81f..575b79f 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/builder/Convertor.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/builder/Convertor.kt
@@ -1,5 +1,6 @@
 package com.gitlab.legoatoom.babycobolcompiler.builder
 
+import antlr.BabyCobol
 import antlr.BabyCobol.*
 import antlr.BabyCobolBaseVisitor
 import com.gitlab.legoatoom.babycobolcompiler.checker.SymbolTable
@@ -457,6 +458,11 @@ class Convertor(private var symbolTable: SymbolTable) : BabyCobolBaseVisitor<IRH
         val parent = ctx.getParent()
         if (parent is ParagraphContext) return IRIdentifier(ctx.text, "")
 
+        val inDisplay = parent.getParent() is DispOptionsContext
+        if (ctx.ID() == null && ctx.INDEX() == null && ctx.identifier().isEmpty() && inDisplay) {
+            return IRIdentifier(ctx.text, "", unresolvedKeyword = true)
+        }
+
         // Get the full name of the identifier.
         val fullId = this.symbolTable.getFullIdentifierName(getIdentifierId(ctx))
         val fullName = getIdentifierNameFromId(fullId!!)
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
index 1bbd700..2a28a0f 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
@@ -405,6 +405,7 @@ class Checker(private val errors: MutableList<FaultInstance>, private val warnin
         // Check if the current id is unambiguous.
         if (currentId != null) {
             val id = getIdentifierId(currentId)
+//            val inDisplay = parent.getParent() is BabyCobol.DispOptionsContext
             if (!isUnambiguousIdentifier(id)) {
                 ctx.getStart().addError(AmbiguousIdentifier) {
                     "Identifier is ambiguous: '${id.joinToString(" OF ")}'"
@@ -434,6 +435,8 @@ class Checker(private val errors: MutableList<FaultInstance>, private val warnin
         val id = getFullName(getIdentifierId(ctx))
         val index = getLeftSubtreeIndex(ctx)
 
+        val inDisplay = ctx.getParent().getParent() is BabyCobol.DispOptionsContext
+
         // Check if the identifier:
         //     is valid, e.g. defined in data division.
         //     is an array but has no index.
@@ -443,7 +446,9 @@ class Checker(private val errors: MutableList<FaultInstance>, private val warnin
         // If all checks pass, set the type of the node by getting the BabyCobol type from the identifier.
         if (id != null && isValidParagraph(id)) {
             return // Good behaviour
-        } else if (id == null || !isValidIdentifier(id)) {
+        } else if (id == null && inDisplay) { // Unresolved keyword gets converted to String in Display
+            setType(ctx, Type.STRING)
+        }else if (id == null || !isValidIdentifier(id)) {
             ctx.getStart().addError(UnresolvedReference) {
                 "Unresolved reference: '${id?.joinToString(" OF ")}'"
             }
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/SymbolTable.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/SymbolTable.kt
index 045997f..20f0577 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/SymbolTable.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/SymbolTable.kt
@@ -318,6 +318,8 @@ class SymbolTable(
 
         // If exactly 1 field with the al the parent of id exists -> unambiguous
         if (count == 1) return true
+        // If 0 fields are found, then is an unresolved reference
+        if (count == 0) return true
         return false
     }
 
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIdentifier.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIdentifier.kt
index 4d0000d..319dd0c 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIdentifier.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRIdentifier.kt
@@ -5,9 +5,14 @@ import java.util.*
 class IRIdentifier(
     private var name: String,
     private var indexString: String = "",
+    private var unresolvedKeyword: Boolean = false,
 ) : IRAtomic {
     // Probably other info here later too, such as picture clause. (aka type)
     override fun convert(): String {
+        if (unresolvedKeyword) {
+            return "\"${name.uppercase()}\""
+        }
+
         if (indexString.isNotEmpty()) {
             return "_$name$indexString"
         }
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/DataDivisionOutputTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/DataDivisionOutputTest.kt
index c11e113..59bc5c4 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/DataDivisionOutputTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/DataDivisionOutputTest.kt
@@ -25,9 +25,8 @@ internal class DataDivisionOutputTest : OutputTestSetup() {
         assertContains(getError("$outputDir/levelNumberLowerThanToplevel"), "InvalidLevelNumberError")
     }
 
-
-    @Test
-    fun noIdentificationProcedure() {
-        assertContains(getError("$outputDir/noIdentificationProcedure"), "InvalidSyntaxError")
-    }
+//    @Test
+//    fun noIdentificationProcedure() {
+//        assertContains(getError("$outputDir/noIdentificationProcedure"), "InvalidSyntaxError")
+//    }
 }
\ No newline at end of file
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/KeywordsOutputTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/KeywordsOutputTest.kt
index 700a83f..3bd3aeb 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/KeywordsOutputTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/KeywordsOutputTest.kt
@@ -6,11 +6,11 @@ import kotlin.test.assertEquals
 internal class KeywordsOutputTest : OutputTestSetup() {
     @Test
     fun displayDisplay() {
-        assertEquals("DISPLAY", getOutput("$outputDir/displayDisplay"))
+        assertEquals("DISPLAY\n", getOutput("$outputDir/displayDisplay"))
     }
 
     @Test
     fun ifThenIsElse() {
-        assertEquals("Then is not else", getOutput("$outputDir/ifThenIsElse", stdinLines = listOf("66", "67")))
+        assertEquals("THEN is not ELSE\n", getOutput("$outputDir/ifThenIsElse", stdinLines = listOf("66", "67")))
     }
 }
\ No newline at end of file
-- 
GitLab


From eaac0b0459bd623abb494f9e05c8433885d74741 Mon Sep 17 00:00:00 2001
From: bramdekker <b.dekker16@hotmail.com>
Date: Fri, 29 Apr 2022 14:27:37 +0200
Subject: [PATCH 5/5] Divide small changes + output tests

---
 src/main/antlr/gen/BabyCobolVocabular.interp  | 208 ------------
 src/main/antlr/gen/BabyCobolVocabular.java    | 313 ------------------
 src/main/antlr/gen/BabyCobolVocabular.tokens  |  66 ----
 .../babycobolcompiler/checker/Checker.kt      |  52 +--
 .../babycobolcompiler/ir/IRDivide.kt          |   3 +-
 .../output/DivideOutputTest.kt                |  21 +-
 .../bclfiles/divideWithGivingAndRemainder.bcl |   8 +
 .../output/bclfiles/divideWithRemainder.bcl   |   7 +
 .../bclfiles/invalidRemainderIdentifier.bcl   |   7 +
 9 files changed, 56 insertions(+), 629 deletions(-)
 delete mode 100644 src/main/antlr/gen/BabyCobolVocabular.interp
 delete mode 100644 src/main/antlr/gen/BabyCobolVocabular.java
 delete mode 100644 src/main/antlr/gen/BabyCobolVocabular.tokens
 create mode 100644 src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/divideWithGivingAndRemainder.bcl
 create mode 100644 src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/divideWithRemainder.bcl
 create mode 100644 src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/invalidRemainderIdentifier.bcl

diff --git a/src/main/antlr/gen/BabyCobolVocabular.interp b/src/main/antlr/gen/BabyCobolVocabular.interp
deleted file mode 100644
index d1af494..0000000
--- a/src/main/antlr/gen/BabyCobolVocabular.interp
+++ /dev/null
@@ -1,208 +0,0 @@
-token literal names:
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-null
-'='
-'>='
-'<='
-'>'
-'<'
-'**'
-'+'
-'-'
-'*'
-'/'
-'.'
-null
-null
-null
-null
-null
-null
-null
-
-token symbolic names:
-null
-ACCEPT
-ADD
-ADVANCING
-AND
-BY
-DATA
-DELIMITED
-DISPLAY
-DIVIDE
-DIVISION
-ELSE
-END
-EVALUATE
-FALSE
-FROM
-GIVING
-IDENTIFICATION
-IF
-IS
-MULTIPLY
-NO
-NOT
-OF
-OTHER
-OR
-PROCEDURE
-PICTURE
-SIZE
-SPACE
-STOP
-SUBTRACT
-THEN
-TO
-TRUE
-WITH
-WHEN
-XOR
-EQ
-GE
-LE
-GT
-LT
-POW_OP
-ADD_OP
-SUB_OP
-MUL_OP
-DIV_OP
-DOT
-INT_LIT
-NUM_LIT
-TXT_LIT
-ID
-NO_DOTS
-NEW_LINE
-WS
-
-rule names:
-ACCEPT
-ADD
-ADVANCING
-AND
-BY
-DATA
-DELIMITED
-DISPLAY
-DIVIDE
-DIVISION
-ELSE
-END
-EVALUATE
-FALSE
-FROM
-GIVING
-IDENTIFICATION
-IF
-IS
-MULTIPLY
-NO
-NOT
-OF
-OTHER
-OR
-PROCEDURE
-PICTURE
-SIZE
-SPACE
-STOP
-SUBTRACT
-THEN
-TO
-TRUE
-WITH
-WHEN
-XOR
-EQ
-GE
-LE
-GT
-LT
-POW_OP
-ADD_OP
-SUB_OP
-MUL_OP
-DIV_OP
-DOT
-INT_LIT
-NUM_LIT
-TXT_LIT
-ID
-NO_DOTS
-NEW_LINE
-WS
-A
-B
-C
-D
-E
-F
-G
-H
-I
-J
-K
-L
-M
-N
-O
-P
-Q
-R
-S
-T
-U
-V
-W
-X
-Y
-Z
-
-channel names:
-DEFAULT_TOKEN_CHANNEL
-HIDDEN
-
-mode names:
-DEFAULT_MODE
-
-atn:
-[3, 24715, 42794, 33075, 47597, 16764, 15335, 30598, 22884, 2, 57, 519, 8, 1, 4, 2, 9, 2, 4, 3, 9, 3, 4, 4, 9, 4, 4, 5, 9, 5, 4, 6, 9, 6, 4, 7, 9, 7, 4, 8, 9, 8, 4, 9, 9, 9, 4, 10, 9, 10, 4, 11, 9, 11, 4, 12, 9, 12, 4, 13, 9, 13, 4, 14, 9, 14, 4, 15, 9, 15, 4, 16, 9, 16, 4, 17, 9, 17, 4, 18, 9, 18, 4, 19, 9, 19, 4, 20, 9, 20, 4, 21, 9, 21, 4, 22, 9, 22, 4, 23, 9, 23, 4, 24, 9, 24, 4, 25, 9, 25, 4, 26, 9, 26, 4, 27, 9, 27, 4, 28, 9, 28, 4, 29, 9, 29, 4, 30, 9, 30, 4, 31, 9, 31, 4, 32, 9, 32, 4, 33, 9, 33, 4, 34, 9, 34, 4, 35, 9, 35, 4, 36, 9, 36, 4, 37, 9, 37, 4, 38, 9, 38, 4, 39, 9, 39, 4, 40, 9, 40, 4, 41, 9, 41, 4, 42, 9, 42, 4, 43, 9, 43, 4, 44, 9, 44, 4, 45, 9, 45, 4, 46, 9, 46, 4, 47, 9, 47, 4, 48, 9, 48, 4, 49, 9, 49, 4, 50, 9, 50, 4, 51, 9, 51, 4, 52, 9, 52, 4, 53, 9, 53, 4, 54, 9, 54, 4, 55, 9, 55, 4, 56, 9, 56, 4, 57, 9, 57, 4, 58, 9, 58, 4, 59, 9, 59, 4, 60, 9, 60, 4, 61, 9, 61, 4, 62, 9, 62, 4, 63, 9, 63, 4, 64, 9, 64, 4, 65, 9, 65, 4, 66, 9, 66, 4, 67, 9, 67, 4, 68, 9, 68, 4, 69, 9, 69, 4, 70, 9, 70, 4, 71, 9, 71, 4, 72, 9, 72, 4, 73, 9, 73, 4, 74, 9, 74, 4, 75, 9, 75, 4, 76, 9, 76, 4, 77, 9, 77, 4, 78, 9, 78, 4, 79, 9, 79, 4, 80, 9, 80, 4, 81, 9, 81, 4, 82, 9, 82, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 2, 3, 3, 3, 3, 3, 3, 3, 3, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 4, 3, 5, 3, 5, 3, 5, 3, 5, 3, 6, 3, 6, 3, 6, 3, 7, 3, 7, 3, 7, 3, 7, 3, 7, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 8, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 9, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 10, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 11, 3, 12, 3, 12, 3, 12, 3, 12, 3, 12, 3, 13, 3, 13, 3, 13, 3, 13, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 14, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 15, 3, 16, 3, 16, 3, 16, 3, 16, 3, 16, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 17, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 18, 3, 19, 3, 19, 3, 19, 3, 20, 3, 20, 3, 20, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 21, 3, 22, 3, 22, 3, 22, 3, 23, 3, 23, 3, 23, 3, 23, 3, 24, 3, 24, 3, 24, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 25, 3, 26, 3, 26, 3, 26, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 27, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 28, 3, 29, 3, 29, 3, 29, 3, 29, 3, 29, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 30, 3, 31, 3, 31, 3, 31, 3, 31, 3, 31, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 32, 3, 33, 3, 33, 3, 33, 3, 33, 3, 33, 3, 34, 3, 34, 3, 34, 3, 35, 3, 35, 3, 35, 3, 35, 3, 35, 3, 36, 3, 36, 3, 36, 3, 36, 3, 36, 3, 37, 3, 37, 3, 37, 3, 37, 3, 37, 3, 38, 3, 38, 3, 38, 3, 38, 3, 39, 3, 39, 3, 40, 3, 40, 3, 40, 3, 41, 3, 41, 3, 41, 3, 42, 3, 42, 3, 43, 3, 43, 3, 44, 3, 44, 3, 44, 3, 45, 3, 45, 3, 46, 3, 46, 3, 47, 3, 47, 3, 48, 3, 48, 3, 49, 3, 49, 3, 50, 5, 50, 414, 10, 50, 3, 50, 6, 50, 417, 10, 50, 13, 50, 14, 50, 418, 3, 51, 5, 51, 422, 10, 51, 3, 51, 7, 51, 425, 10, 51, 12, 51, 14, 51, 428, 11, 51, 3, 51, 3, 51, 6, 51, 432, 10, 51, 13, 51, 14, 51, 433, 3, 52, 3, 52, 7, 52, 438, 10, 52, 12, 52, 14, 52, 441, 11, 52, 3, 52, 3, 52, 3, 53, 3, 53, 7, 53, 447, 10, 53, 12, 53, 14, 53, 450, 11, 53, 3, 54, 6, 54, 453, 10, 54, 13, 54, 14, 54, 454, 3, 55, 3, 55, 3, 55, 3, 55, 3, 56, 6, 56, 462, 10, 56, 13, 56, 14, 56, 463, 3, 56, 3, 56, 3, 57, 3, 57, 3, 58, 3, 58, 3, 59, 3, 59, 3, 60, 3, 60, 3, 61, 3, 61, 3, 62, 3, 62, 3, 63, 3, 63, 3, 64, 3, 64, 3, 65, 3, 65, 3, 66, 3, 66, 3, 67, 3, 67, 3, 68, 3, 68, 3, 69, 3, 69, 3, 70, 3, 70, 3, 71, 3, 71, 3, 72, 3, 72, 3, 73, 3, 73, 3, 74, 3, 74, 3, 75, 3, 75, 3, 76, 3, 76, 3, 77, 3, 77, 3, 78, 3, 78, 3, 79, 3, 79, 3, 80, 3, 80, 3, 81, 3, 81, 3, 82, 3, 82, 3, 439, 2, 83, 3, 3, 5, 4, 7, 5, 9, 6, 11, 7, 13, 8, 15, 9, 17, 10, 19, 11, 21, 12, 23, 13, 25, 14, 27, 15, 29, 16, 31, 17, 33, 18, 35, 19, 37, 20, 39, 21, 41, 22, 43, 23, 45, 24, 47, 25, 49, 26, 51, 27, 53, 28, 55, 29, 57, 30, 59, 31, 61, 32, 63, 33, 65, 34, 67, 35, 69, 36, 71, 37, 73, 38, 75, 39, 77, 40, 79, 41, 81, 42, 83, 43, 85, 44, 87, 45, 89, 46, 91, 47, 93, 48, 95, 49, 97, 50, 99, 51, 101, 52, 103, 53, 105, 54, 107, 55, 109, 56, 111, 57, 113, 2, 115, 2, 117, 2, 119, 2, 121, 2, 123, 2, 125, 2, 127, 2, 129, 2, 131, 2, 133, 2, 135, 2, 137, 2, 139, 2, 141, 2, 143, 2, 145, 2, 147, 2, 149, 2, 151, 2, 153, 2, 155, 2, 157, 2, 159, 2, 161, 2, 163, 2, 3, 2, 36, 4, 2, 45, 45, 47, 47, 3, 2, 50, 59, 4, 2, 46, 46, 48, 48, 5, 2, 50, 59, 67, 92, 99, 124, 6, 2, 47, 47, 50, 59, 67, 92, 99, 124, 6, 2, 11, 12, 15, 15, 34, 34, 48, 48, 3, 2, 12, 12, 5, 2, 11, 11, 15, 15, 34, 34, 4, 2, 67, 67, 99, 99, 4, 2, 68, 68, 100, 100, 4, 2, 69, 69, 101, 101, 4, 2, 70, 70, 102, 102, 4, 2, 71, 71, 103, 103, 4, 2, 72, 72, 104, 104, 4, 2, 73, 73, 105, 105, 4, 2, 74, 74, 106, 106, 4, 2, 75, 75, 107, 107, 4, 2, 76, 76, 108, 108, 4, 2, 77, 77, 109, 109, 4, 2, 78, 78, 110, 110, 4, 2, 79, 79, 111, 111, 4, 2, 80, 80, 112, 112, 4, 2, 81, 81, 113, 113, 4, 2, 82, 82, 114, 114, 4, 2, 83, 83, 115, 115, 4, 2, 84, 84, 116, 116, 4, 2, 85, 85, 117, 117, 4, 2, 86, 86, 118, 118, 4, 2, 87, 87, 119, 119, 4, 2, 88, 88, 120, 120, 4, 2, 89, 89, 121, 121, 4, 2, 90, 90, 122, 122, 4, 2, 91, 91, 123, 123, 4, 2, 92, 92, 124, 124, 2, 501, 2, 3, 3, 2, 2, 2, 2, 5, 3, 2, 2, 2, 2, 7, 3, 2, 2, 2, 2, 9, 3, 2, 2, 2, 2, 11, 3, 2, 2, 2, 2, 13, 3, 2, 2, 2, 2, 15, 3, 2, 2, 2, 2, 17, 3, 2, 2, 2, 2, 19, 3, 2, 2, 2, 2, 21, 3, 2, 2, 2, 2, 23, 3, 2, 2, 2, 2, 25, 3, 2, 2, 2, 2, 27, 3, 2, 2, 2, 2, 29, 3, 2, 2, 2, 2, 31, 3, 2, 2, 2, 2, 33, 3, 2, 2, 2, 2, 35, 3, 2, 2, 2, 2, 37, 3, 2, 2, 2, 2, 39, 3, 2, 2, 2, 2, 41, 3, 2, 2, 2, 2, 43, 3, 2, 2, 2, 2, 45, 3, 2, 2, 2, 2, 47, 3, 2, 2, 2, 2, 49, 3, 2, 2, 2, 2, 51, 3, 2, 2, 2, 2, 53, 3, 2, 2, 2, 2, 55, 3, 2, 2, 2, 2, 57, 3, 2, 2, 2, 2, 59, 3, 2, 2, 2, 2, 61, 3, 2, 2, 2, 2, 63, 3, 2, 2, 2, 2, 65, 3, 2, 2, 2, 2, 67, 3, 2, 2, 2, 2, 69, 3, 2, 2, 2, 2, 71, 3, 2, 2, 2, 2, 73, 3, 2, 2, 2, 2, 75, 3, 2, 2, 2, 2, 77, 3, 2, 2, 2, 2, 79, 3, 2, 2, 2, 2, 81, 3, 2, 2, 2, 2, 83, 3, 2, 2, 2, 2, 85, 3, 2, 2, 2, 2, 87, 3, 2, 2, 2, 2, 89, 3, 2, 2, 2, 2, 91, 3, 2, 2, 2, 2, 93, 3, 2, 2, 2, 2, 95, 3, 2, 2, 2, 2, 97, 3, 2, 2, 2, 2, 99, 3, 2, 2, 2, 2, 101, 3, 2, 2, 2, 2, 103, 3, 2, 2, 2, 2, 105, 3, 2, 2, 2, 2, 107, 3, 2, 2, 2, 2, 109, 3, 2, 2, 2, 2, 111, 3, 2, 2, 2, 3, 165, 3, 2, 2, 2, 5, 172, 3, 2, 2, 2, 7, 176, 3, 2, 2, 2, 9, 186, 3, 2, 2, 2, 11, 190, 3, 2, 2, 2, 13, 193, 3, 2, 2, 2, 15, 198, 3, 2, 2, 2, 17, 208, 3, 2, 2, 2, 19, 216, 3, 2, 2, 2, 21, 223, 3, 2, 2, 2, 23, 232, 3, 2, 2, 2, 25, 237, 3, 2, 2, 2, 27, 241, 3, 2, 2, 2, 29, 250, 3, 2, 2, 2, 31, 256, 3, 2, 2, 2, 33, 261, 3, 2, 2, 2, 35, 268, 3, 2, 2, 2, 37, 283, 3, 2, 2, 2, 39, 286, 3, 2, 2, 2, 41, 289, 3, 2, 2, 2, 43, 298, 3, 2, 2, 2, 45, 301, 3, 2, 2, 2, 47, 305, 3, 2, 2, 2, 49, 308, 3, 2, 2, 2, 51, 314, 3, 2, 2, 2, 53, 317, 3, 2, 2, 2, 55, 327, 3, 2, 2, 2, 57, 335, 3, 2, 2, 2, 59, 340, 3, 2, 2, 2, 61, 346, 3, 2, 2, 2, 63, 351, 3, 2, 2, 2, 65, 360, 3, 2, 2, 2, 67, 365, 3, 2, 2, 2, 69, 368, 3, 2, 2, 2, 71, 373, 3, 2, 2, 2, 73, 378, 3, 2, 2, 2, 75, 383, 3, 2, 2, 2, 77, 387, 3, 2, 2, 2, 79, 389, 3, 2, 2, 2, 81, 392, 3, 2, 2, 2, 83, 395, 3, 2, 2, 2, 85, 397, 3, 2, 2, 2, 87, 399, 3, 2, 2, 2, 89, 402, 3, 2, 2, 2, 91, 404, 3, 2, 2, 2, 93, 406, 3, 2, 2, 2, 95, 408, 3, 2, 2, 2, 97, 410, 3, 2, 2, 2, 99, 413, 3, 2, 2, 2, 101, 421, 3, 2, 2, 2, 103, 435, 3, 2, 2, 2, 105, 444, 3, 2, 2, 2, 107, 452, 3, 2, 2, 2, 109, 456, 3, 2, 2, 2, 111, 461, 3, 2, 2, 2, 113, 467, 3, 2, 2, 2, 115, 469, 3, 2, 2, 2, 117, 471, 3, 2, 2, 2, 119, 473, 3, 2, 2, 2, 121, 475, 3, 2, 2, 2, 123, 477, 3, 2, 2, 2, 125, 479, 3, 2, 2, 2, 127, 481, 3, 2, 2, 2, 129, 483, 3, 2, 2, 2, 131, 485, 3, 2, 2, 2, 133, 487, 3, 2, 2, 2, 135, 489, 3, 2, 2, 2, 137, 491, 3, 2, 2, 2, 139, 493, 3, 2, 2, 2, 141, 495, 3, 2, 2, 2, 143, 497, 3, 2, 2, 2, 145, 499, 3, 2, 2, 2, 147, 501, 3, 2, 2, 2, 149, 503, 3, 2, 2, 2, 151, 505, 3, 2, 2, 2, 153, 507, 3, 2, 2, 2, 155, 509, 3, 2, 2, 2, 157, 511, 3, 2, 2, 2, 159, 513, 3, 2, 2, 2, 161, 515, 3, 2, 2, 2, 163, 517, 3, 2, 2, 2, 165, 166, 5, 113, 57, 2, 166, 167, 5, 117, 59, 2, 167, 168, 5, 117, 59, 2, 168, 169, 5, 121, 61, 2, 169, 170, 5, 143, 72, 2, 170, 171, 5, 151, 76, 2, 171, 4, 3, 2, 2, 2, 172, 173, 5, 113, 57, 2, 173, 174, 5, 119, 60, 2, 174, 175, 5, 119, 60, 2, 175, 6, 3, 2, 2, 2, 176, 177, 5, 113, 57, 2, 177, 178, 5, 119, 60, 2, 178, 179, 5, 155, 78, 2, 179, 180, 5, 113, 57, 2, 180, 181, 5, 139, 70, 2, 181, 182, 5, 117, 59, 2, 182, 183, 5, 129, 65, 2, 183, 184, 5, 139, 70, 2, 184, 185, 5, 125, 63, 2, 185, 8, 3, 2, 2, 2, 186, 187, 5, 113, 57, 2, 187, 188, 5, 139, 70, 2, 188, 189, 5, 119, 60, 2, 189, 10, 3, 2, 2, 2, 190, 191, 5, 115, 58, 2, 191, 192, 5, 161, 81, 2, 192, 12, 3, 2, 2, 2, 193, 194, 5, 119, 60, 2, 194, 195, 5, 113, 57, 2, 195, 196, 5, 151, 76, 2, 196, 197, 5, 113, 57, 2, 197, 14, 3, 2, 2, 2, 198, 199, 5, 119, 60, 2, 199, 200, 5, 121, 61, 2, 200, 201, 5, 135, 68, 2, 201, 202, 5, 129, 65, 2, 202, 203, 5, 137, 69, 2, 203, 204, 5, 129, 65, 2, 204, 205, 5, 151, 76, 2, 205, 206, 5, 121, 61, 2, 206, 207, 5, 119, 60, 2, 207, 16, 3, 2, 2, 2, 208, 209, 5, 119, 60, 2, 209, 210, 5, 129, 65, 2, 210, 211, 5, 149, 75, 2, 211, 212, 5, 143, 72, 2, 212, 213, 5, 135, 68, 2, 213, 214, 5, 113, 57, 2, 214, 215, 5, 161, 81, 2, 215, 18, 3, 2, 2, 2, 216, 217, 5, 119, 60, 2, 217, 218, 5, 129, 65, 2, 218, 219, 5, 155, 78, 2, 219, 220, 5, 129, 65, 2, 220, 221, 5, 119, 60, 2, 221, 222, 5, 121, 61, 2, 222, 20, 3, 2, 2, 2, 223, 224, 5, 119, 60, 2, 224, 225, 5, 129, 65, 2, 225, 226, 5, 155, 78, 2, 226, 227, 5, 129, 65, 2, 227, 228, 5, 149, 75, 2, 228, 229, 5, 129, 65, 2, 229, 230, 5, 141, 71, 2, 230, 231, 5, 139, 70, 2, 231, 22, 3, 2, 2, 2, 232, 233, 5, 121, 61, 2, 233, 234, 5, 135, 68, 2, 234, 235, 5, 149, 75, 2, 235, 236, 5, 121, 61, 2, 236, 24, 3, 2, 2, 2, 237, 238, 5, 121, 61, 2, 238, 239, 5, 139, 70, 2, 239, 240, 5, 119, 60, 2, 240, 26, 3, 2, 2, 2, 241, 242, 5, 121, 61, 2, 242, 243, 5, 155, 78, 2, 243, 244, 5, 113, 57, 2, 244, 245, 5, 135, 68, 2, 245, 246, 5, 153, 77, 2, 246, 247, 5, 113, 57, 2, 247, 248, 5, 151, 76, 2, 248, 249, 5, 121, 61, 2, 249, 28, 3, 2, 2, 2, 250, 251, 5, 123, 62, 2, 251, 252, 5, 113, 57, 2, 252, 253, 5, 135, 68, 2, 253, 254, 5, 149, 75, 2, 254, 255, 5, 121, 61, 2, 255, 30, 3, 2, 2, 2, 256, 257, 5, 123, 62, 2, 257, 258, 5, 147, 74, 2, 258, 259, 5, 141, 71, 2, 259, 260, 5, 137, 69, 2, 260, 32, 3, 2, 2, 2, 261, 262, 5, 125, 63, 2, 262, 263, 5, 129, 65, 2, 263, 264, 5, 155, 78, 2, 264, 265, 5, 129, 65, 2, 265, 266, 5, 139, 70, 2, 266, 267, 5, 125, 63, 2, 267, 34, 3, 2, 2, 2, 268, 269, 5, 129, 65, 2, 269, 270, 5, 119, 60, 2, 270, 271, 5, 121, 61, 2, 271, 272, 5, 139, 70, 2, 272, 273, 5, 151, 76, 2, 273, 274, 5, 129, 65, 2, 274, 275, 5, 123, 62, 2, 275, 276, 5, 129, 65, 2, 276, 277, 5, 117, 59, 2, 277, 278, 5, 113, 57, 2, 278, 279, 5, 151, 76, 2, 279, 280, 5, 129, 65, 2, 280, 281, 5, 141, 71, 2, 281, 282, 5, 139, 70, 2, 282, 36, 3, 2, 2, 2, 283, 284, 5, 129, 65, 2, 284, 285, 5, 123, 62, 2, 285, 38, 3, 2, 2, 2, 286, 287, 5, 129, 65, 2, 287, 288, 5, 149, 75, 2, 288, 40, 3, 2, 2, 2, 289, 290, 5, 137, 69, 2, 290, 291, 5, 153, 77, 2, 291, 292, 5, 135, 68, 2, 292, 293, 5, 151, 76, 2, 293, 294, 5, 129, 65, 2, 294, 295, 5, 143, 72, 2, 295, 296, 5, 135, 68, 2, 296, 297, 5, 161, 81, 2, 297, 42, 3, 2, 2, 2, 298, 299, 5, 139, 70, 2, 299, 300, 5, 141, 71, 2, 300, 44, 3, 2, 2, 2, 301, 302, 5, 139, 70, 2, 302, 303, 5, 141, 71, 2, 303, 304, 5, 151, 76, 2, 304, 46, 3, 2, 2, 2, 305, 306, 5, 141, 71, 2, 306, 307, 5, 123, 62, 2, 307, 48, 3, 2, 2, 2, 308, 309, 5, 141, 71, 2, 309, 310, 5, 151, 76, 2, 310, 311, 5, 127, 64, 2, 311, 312, 5, 121, 61, 2, 312, 313, 5, 147, 74, 2, 313, 50, 3, 2, 2, 2, 314, 315, 5, 141, 71, 2, 315, 316, 5, 147, 74, 2, 316, 52, 3, 2, 2, 2, 317, 318, 5, 143, 72, 2, 318, 319, 5, 147, 74, 2, 319, 320, 5, 141, 71, 2, 320, 321, 5, 117, 59, 2, 321, 322, 5, 121, 61, 2, 322, 323, 5, 119, 60, 2, 323, 324, 5, 153, 77, 2, 324, 325, 5, 147, 74, 2, 325, 326, 5, 121, 61, 2, 326, 54, 3, 2, 2, 2, 327, 328, 5, 143, 72, 2, 328, 329, 5, 129, 65, 2, 329, 330, 5, 117, 59, 2, 330, 331, 5, 151, 76, 2, 331, 332, 5, 153, 77, 2, 332, 333, 5, 147, 74, 2, 333, 334, 5, 121, 61, 2, 334, 56, 3, 2, 2, 2, 335, 336, 5, 149, 75, 2, 336, 337, 5, 129, 65, 2, 337, 338, 5, 163, 82, 2, 338, 339, 5, 121, 61, 2, 339, 58, 3, 2, 2, 2, 340, 341, 5, 149, 75, 2, 341, 342, 5, 143, 72, 2, 342, 343, 5, 113, 57, 2, 343, 344, 5, 117, 59, 2, 344, 345, 5, 121, 61, 2, 345, 60, 3, 2, 2, 2, 346, 347, 5, 149, 75, 2, 347, 348, 5, 151, 76, 2, 348, 349, 5, 141, 71, 2, 349, 350, 5, 143, 72, 2, 350, 62, 3, 2, 2, 2, 351, 352, 5, 149, 75, 2, 352, 353, 5, 153, 77, 2, 353, 354, 5, 115, 58, 2, 354, 355, 5, 151, 76, 2, 355, 356, 5, 147, 74, 2, 356, 357, 5, 113, 57, 2, 357, 358, 5, 117, 59, 2, 358, 359, 5, 151, 76, 2, 359, 64, 3, 2, 2, 2, 360, 361, 5, 151, 76, 2, 361, 362, 5, 127, 64, 2, 362, 363, 5, 121, 61, 2, 363, 364, 5, 139, 70, 2, 364, 66, 3, 2, 2, 2, 365, 366, 5, 151, 76, 2, 366, 367, 5, 141, 71, 2, 367, 68, 3, 2, 2, 2, 368, 369, 5, 151, 76, 2, 369, 370, 5, 147, 74, 2, 370, 371, 5, 153, 77, 2, 371, 372, 5, 121, 61, 2, 372, 70, 3, 2, 2, 2, 373, 374, 5, 157, 79, 2, 374, 375, 5, 129, 65, 2, 375, 376, 5, 151, 76, 2, 376, 377, 5, 127, 64, 2, 377, 72, 3, 2, 2, 2, 378, 379, 5, 157, 79, 2, 379, 380, 5, 127, 64, 2, 380, 381, 5, 121, 61, 2, 381, 382, 5, 139, 70, 2, 382, 74, 3, 2, 2, 2, 383, 384, 5, 159, 80, 2, 384, 385, 5, 141, 71, 2, 385, 386, 5, 147, 74, 2, 386, 76, 3, 2, 2, 2, 387, 388, 7, 63, 2, 2, 388, 78, 3, 2, 2, 2, 389, 390, 7, 64, 2, 2, 390, 391, 7, 63, 2, 2, 391, 80, 3, 2, 2, 2, 392, 393, 7, 62, 2, 2, 393, 394, 7, 63, 2, 2, 394, 82, 3, 2, 2, 2, 395, 396, 7, 64, 2, 2, 396, 84, 3, 2, 2, 2, 397, 398, 7, 62, 2, 2, 398, 86, 3, 2, 2, 2, 399, 400, 7, 44, 2, 2, 400, 401, 7, 44, 2, 2, 401, 88, 3, 2, 2, 2, 402, 403, 7, 45, 2, 2, 403, 90, 3, 2, 2, 2, 404, 405, 7, 47, 2, 2, 405, 92, 3, 2, 2, 2, 406, 407, 7, 44, 2, 2, 407, 94, 3, 2, 2, 2, 408, 409, 7, 49, 2, 2, 409, 96, 3, 2, 2, 2, 410, 411, 7, 48, 2, 2, 411, 98, 3, 2, 2, 2, 412, 414, 9, 2, 2, 2, 413, 412, 3, 2, 2, 2, 413, 414, 3, 2, 2, 2, 414, 416, 3, 2, 2, 2, 415, 417, 9, 3, 2, 2, 416, 415, 3, 2, 2, 2, 417, 418, 3, 2, 2, 2, 418, 416, 3, 2, 2, 2, 418, 419, 3, 2, 2, 2, 419, 100, 3, 2, 2, 2, 420, 422, 9, 2, 2, 2, 421, 420, 3, 2, 2, 2, 421, 422, 3, 2, 2, 2, 422, 426, 3, 2, 2, 2, 423, 425, 9, 3, 2, 2, 424, 423, 3, 2, 2, 2, 425, 428, 3, 2, 2, 2, 426, 424, 3, 2, 2, 2, 426, 427, 3, 2, 2, 2, 427, 429, 3, 2, 2, 2, 428, 426, 3, 2, 2, 2, 429, 431, 9, 4, 2, 2, 430, 432, 9, 3, 2, 2, 431, 430, 3, 2, 2, 2, 432, 433, 3, 2, 2, 2, 433, 431, 3, 2, 2, 2, 433, 434, 3, 2, 2, 2, 434, 102, 3, 2, 2, 2, 435, 439, 7, 36, 2, 2, 436, 438, 11, 2, 2, 2, 437, 436, 3, 2, 2, 2, 438, 441, 3, 2, 2, 2, 439, 440, 3, 2, 2, 2, 439, 437, 3, 2, 2, 2, 440, 442, 3, 2, 2, 2, 441, 439, 3, 2, 2, 2, 442, 443, 7, 36, 2, 2, 443, 104, 3, 2, 2, 2, 444, 448, 9, 5, 2, 2, 445, 447, 9, 6, 2, 2, 446, 445, 3, 2, 2, 2, 447, 450, 3, 2, 2, 2, 448, 446, 3, 2, 2, 2, 448, 449, 3, 2, 2, 2, 449, 106, 3, 2, 2, 2, 450, 448, 3, 2, 2, 2, 451, 453, 10, 7, 2, 2, 452, 451, 3, 2, 2, 2, 453, 454, 3, 2, 2, 2, 454, 452, 3, 2, 2, 2, 454, 455, 3, 2, 2, 2, 455, 108, 3, 2, 2, 2, 456, 457, 9, 8, 2, 2, 457, 458, 3, 2, 2, 2, 458, 459, 8, 55, 2, 2, 459, 110, 3, 2, 2, 2, 460, 462, 9, 9, 2, 2, 461, 460, 3, 2, 2, 2, 462, 463, 3, 2, 2, 2, 463, 461, 3, 2, 2, 2, 463, 464, 3, 2, 2, 2, 464, 465, 3, 2, 2, 2, 465, 466, 8, 56, 3, 2, 466, 112, 3, 2, 2, 2, 467, 468, 9, 10, 2, 2, 468, 114, 3, 2, 2, 2, 469, 470, 9, 11, 2, 2, 470, 116, 3, 2, 2, 2, 471, 472, 9, 12, 2, 2, 472, 118, 3, 2, 2, 2, 473, 474, 9, 13, 2, 2, 474, 120, 3, 2, 2, 2, 475, 476, 9, 14, 2, 2, 476, 122, 3, 2, 2, 2, 477, 478, 9, 15, 2, 2, 478, 124, 3, 2, 2, 2, 479, 480, 9, 16, 2, 2, 480, 126, 3, 2, 2, 2, 481, 482, 9, 17, 2, 2, 482, 128, 3, 2, 2, 2, 483, 484, 9, 18, 2, 2, 484, 130, 3, 2, 2, 2, 485, 486, 9, 19, 2, 2, 486, 132, 3, 2, 2, 2, 487, 488, 9, 20, 2, 2, 488, 134, 3, 2, 2, 2, 489, 490, 9, 21, 2, 2, 490, 136, 3, 2, 2, 2, 491, 492, 9, 22, 2, 2, 492, 138, 3, 2, 2, 2, 493, 494, 9, 23, 2, 2, 494, 140, 3, 2, 2, 2, 495, 496, 9, 24, 2, 2, 496, 142, 3, 2, 2, 2, 497, 498, 9, 25, 2, 2, 498, 144, 3, 2, 2, 2, 499, 500, 9, 26, 2, 2, 500, 146, 3, 2, 2, 2, 501, 502, 9, 27, 2, 2, 502, 148, 3, 2, 2, 2, 503, 504, 9, 28, 2, 2, 504, 150, 3, 2, 2, 2, 505, 506, 9, 29, 2, 2, 506, 152, 3, 2, 2, 2, 507, 508, 9, 30, 2, 2, 508, 154, 3, 2, 2, 2, 509, 510, 9, 31, 2, 2, 510, 156, 3, 2, 2, 2, 511, 512, 9, 32, 2, 2, 512, 158, 3, 2, 2, 2, 513, 514, 9, 33, 2, 2, 514, 160, 3, 2, 2, 2, 515, 516, 9, 34, 2, 2, 516, 162, 3, 2, 2, 2, 517, 518, 9, 35, 2, 2, 518, 164, 3, 2, 2, 2, 12, 2, 413, 418, 421, 426, 433, 439, 448, 454, 463, 4, 2, 3, 2, 8, 2, 2]
\ No newline at end of file
diff --git a/src/main/antlr/gen/BabyCobolVocabular.java b/src/main/antlr/gen/BabyCobolVocabular.java
deleted file mode 100644
index 12366a1..0000000
--- a/src/main/antlr/gen/BabyCobolVocabular.java
+++ /dev/null
@@ -1,313 +0,0 @@
-// Generated from /home/bram/Documents/UTwente/software-evolution/babycobolcompiler/src/main/antlr/BabyCobolVocabular.g4 by ANTLR 4.9.2
-import org.antlr.v4.runtime.Lexer;
-import org.antlr.v4.runtime.CharStream;
-import org.antlr.v4.runtime.Token;
-import org.antlr.v4.runtime.TokenStream;
-import org.antlr.v4.runtime.*;
-import org.antlr.v4.runtime.atn.*;
-import org.antlr.v4.runtime.dfa.DFA;
-import org.antlr.v4.runtime.misc.*;
-
-@SuppressWarnings({"all", "warnings", "unchecked", "unused", "cast"})
-public class BabyCobolVocabular extends Lexer {
-	static { RuntimeMetaData.checkVersion("4.9.2", RuntimeMetaData.VERSION); }
-
-	protected static final DFA[] _decisionToDFA;
-	protected static final PredictionContextCache _sharedContextCache =
-		new PredictionContextCache();
-	public static final int
-		ACCEPT=1, ADD=2, ADVANCING=3, AND=4, BY=5, DATA=6, DELIMITED=7, DISPLAY=8, 
-		DIVIDE=9, DIVISION=10, ELSE=11, END=12, EVALUATE=13, FALSE=14, FROM=15, 
-		GIVING=16, IDENTIFICATION=17, IF=18, IS=19, MULTIPLY=20, NO=21, NOT=22, 
-		OF=23, OTHER=24, OR=25, PROCEDURE=26, PICTURE=27, SIZE=28, SPACE=29, STOP=30, 
-		SUBTRACT=31, THEN=32, TO=33, TRUE=34, WITH=35, WHEN=36, XOR=37, EQ=38, 
-		GE=39, LE=40, GT=41, LT=42, POW_OP=43, ADD_OP=44, SUB_OP=45, MUL_OP=46, 
-		DIV_OP=47, DOT=48, INT_LIT=49, NUM_LIT=50, TXT_LIT=51, ID=52, NO_DOTS=53, 
-		NEW_LINE=54, WS=55;
-	public static String[] channelNames = {
-		"DEFAULT_TOKEN_CHANNEL", "HIDDEN"
-	};
-
-	public static String[] modeNames = {
-		"DEFAULT_MODE"
-	};
-
-	private static String[] makeRuleNames() {
-		return new String[] {
-			"ACCEPT", "ADD", "ADVANCING", "AND", "BY", "DATA", "DELIMITED", "DISPLAY", 
-			"DIVIDE", "DIVISION", "ELSE", "END", "EVALUATE", "FALSE", "FROM", "GIVING", 
-			"IDENTIFICATION", "IF", "IS", "MULTIPLY", "NO", "NOT", "OF", "OTHER", 
-			"OR", "PROCEDURE", "PICTURE", "SIZE", "SPACE", "STOP", "SUBTRACT", "THEN", 
-			"TO", "TRUE", "WITH", "WHEN", "XOR", "EQ", "GE", "LE", "GT", "LT", "POW_OP", 
-			"ADD_OP", "SUB_OP", "MUL_OP", "DIV_OP", "DOT", "INT_LIT", "NUM_LIT", 
-			"TXT_LIT", "ID", "NO_DOTS", "NEW_LINE", "WS", "A", "B", "C", "D", "E", 
-			"F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", 
-			"T", "U", "V", "W", "X", "Y", "Z"
-		};
-	}
-	public static final String[] ruleNames = makeRuleNames();
-
-	private static String[] makeLiteralNames() {
-		return new String[] {
-			null, null, null, null, null, null, null, null, null, null, null, null, 
-			null, null, null, null, null, null, null, null, null, null, null, null, 
-			null, null, null, null, null, null, null, null, null, null, null, null, 
-			null, null, "'='", "'>='", "'<='", "'>'", "'<'", "'**'", "'+'", "'-'", 
-			"'*'", "'/'", "'.'"
-		};
-	}
-	private static final String[] _LITERAL_NAMES = makeLiteralNames();
-	private static String[] makeSymbolicNames() {
-		return new String[] {
-			null, "ACCEPT", "ADD", "ADVANCING", "AND", "BY", "DATA", "DELIMITED", 
-			"DISPLAY", "DIVIDE", "DIVISION", "ELSE", "END", "EVALUATE", "FALSE", 
-			"FROM", "GIVING", "IDENTIFICATION", "IF", "IS", "MULTIPLY", "NO", "NOT", 
-			"OF", "OTHER", "OR", "PROCEDURE", "PICTURE", "SIZE", "SPACE", "STOP", 
-			"SUBTRACT", "THEN", "TO", "TRUE", "WITH", "WHEN", "XOR", "EQ", "GE", 
-			"LE", "GT", "LT", "POW_OP", "ADD_OP", "SUB_OP", "MUL_OP", "DIV_OP", "DOT", 
-			"INT_LIT", "NUM_LIT", "TXT_LIT", "ID", "NO_DOTS", "NEW_LINE", "WS"
-		};
-	}
-	private static final String[] _SYMBOLIC_NAMES = makeSymbolicNames();
-	public static final Vocabulary VOCABULARY = new VocabularyImpl(_LITERAL_NAMES, _SYMBOLIC_NAMES);
-
-	/**
-	 * @deprecated Use {@link #VOCABULARY} instead.
-	 */
-	@Deprecated
-	public static final String[] tokenNames;
-	static {
-		tokenNames = new String[_SYMBOLIC_NAMES.length];
-		for (int i = 0; i < tokenNames.length; i++) {
-			tokenNames[i] = VOCABULARY.getLiteralName(i);
-			if (tokenNames[i] == null) {
-				tokenNames[i] = VOCABULARY.getSymbolicName(i);
-			}
-
-			if (tokenNames[i] == null) {
-				tokenNames[i] = "<INVALID>";
-			}
-		}
-	}
-
-	@Override
-	@Deprecated
-	public String[] getTokenNames() {
-		return tokenNames;
-	}
-
-	@Override
-
-	public Vocabulary getVocabulary() {
-		return VOCABULARY;
-	}
-
-
-	public BabyCobolVocabular(CharStream input) {
-		super(input);
-		_interp = new LexerATNSimulator(this,_ATN,_decisionToDFA,_sharedContextCache);
-	}
-
-	@Override
-	public String getGrammarFileName() { return "BabyCobolVocabular.g4"; }
-
-	@Override
-	public String[] getRuleNames() { return ruleNames; }
-
-	@Override
-	public String getSerializedATN() { return _serializedATN; }
-
-	@Override
-	public String[] getChannelNames() { return channelNames; }
-
-	@Override
-	public String[] getModeNames() { return modeNames; }
-
-	@Override
-	public ATN getATN() { return _ATN; }
-
-	public static final String _serializedATN =
-		"\3\u608b\ua72a\u8133\ub9ed\u417c\u3be7\u7786\u5964\29\u0207\b\1\4\2\t"+
-		"\2\4\3\t\3\4\4\t\4\4\5\t\5\4\6\t\6\4\7\t\7\4\b\t\b\4\t\t\t\4\n\t\n\4\13"+
-		"\t\13\4\f\t\f\4\r\t\r\4\16\t\16\4\17\t\17\4\20\t\20\4\21\t\21\4\22\t\22"+
-		"\4\23\t\23\4\24\t\24\4\25\t\25\4\26\t\26\4\27\t\27\4\30\t\30\4\31\t\31"+
-		"\4\32\t\32\4\33\t\33\4\34\t\34\4\35\t\35\4\36\t\36\4\37\t\37\4 \t \4!"+
-		"\t!\4\"\t\"\4#\t#\4$\t$\4%\t%\4&\t&\4\'\t\'\4(\t(\4)\t)\4*\t*\4+\t+\4"+
-		",\t,\4-\t-\4.\t.\4/\t/\4\60\t\60\4\61\t\61\4\62\t\62\4\63\t\63\4\64\t"+
-		"\64\4\65\t\65\4\66\t\66\4\67\t\67\48\t8\49\t9\4:\t:\4;\t;\4<\t<\4=\t="+
-		"\4>\t>\4?\t?\4@\t@\4A\tA\4B\tB\4C\tC\4D\tD\4E\tE\4F\tF\4G\tG\4H\tH\4I"+
-		"\tI\4J\tJ\4K\tK\4L\tL\4M\tM\4N\tN\4O\tO\4P\tP\4Q\tQ\4R\tR\3\2\3\2\3\2"+
-		"\3\2\3\2\3\2\3\2\3\3\3\3\3\3\3\3\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3\4\3"+
-		"\4\3\5\3\5\3\5\3\5\3\6\3\6\3\6\3\7\3\7\3\7\3\7\3\7\3\b\3\b\3\b\3\b\3\b"+
-		"\3\b\3\b\3\b\3\b\3\b\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\t\3\n\3\n\3\n\3\n\3"+
-		"\n\3\n\3\n\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\13\3\f\3\f\3\f\3"+
-		"\f\3\f\3\r\3\r\3\r\3\r\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3\16\3"+
-		"\17\3\17\3\17\3\17\3\17\3\17\3\20\3\20\3\20\3\20\3\20\3\21\3\21\3\21\3"+
-		"\21\3\21\3\21\3\21\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3\22\3"+
-		"\22\3\22\3\22\3\22\3\22\3\23\3\23\3\23\3\24\3\24\3\24\3\25\3\25\3\25\3"+
-		"\25\3\25\3\25\3\25\3\25\3\25\3\26\3\26\3\26\3\27\3\27\3\27\3\27\3\30\3"+
-		"\30\3\30\3\31\3\31\3\31\3\31\3\31\3\31\3\32\3\32\3\32\3\33\3\33\3\33\3"+
-		"\33\3\33\3\33\3\33\3\33\3\33\3\33\3\34\3\34\3\34\3\34\3\34\3\34\3\34\3"+
-		"\34\3\35\3\35\3\35\3\35\3\35\3\36\3\36\3\36\3\36\3\36\3\36\3\37\3\37\3"+
-		"\37\3\37\3\37\3 \3 \3 \3 \3 \3 \3 \3 \3 \3!\3!\3!\3!\3!\3\"\3\"\3\"\3"+
-		"#\3#\3#\3#\3#\3$\3$\3$\3$\3$\3%\3%\3%\3%\3%\3&\3&\3&\3&\3\'\3\'\3(\3("+
-		"\3(\3)\3)\3)\3*\3*\3+\3+\3,\3,\3,\3-\3-\3.\3.\3/\3/\3\60\3\60\3\61\3\61"+
-		"\3\62\5\62\u019e\n\62\3\62\6\62\u01a1\n\62\r\62\16\62\u01a2\3\63\5\63"+
-		"\u01a6\n\63\3\63\7\63\u01a9\n\63\f\63\16\63\u01ac\13\63\3\63\3\63\6\63"+
-		"\u01b0\n\63\r\63\16\63\u01b1\3\64\3\64\7\64\u01b6\n\64\f\64\16\64\u01b9"+
-		"\13\64\3\64\3\64\3\65\3\65\7\65\u01bf\n\65\f\65\16\65\u01c2\13\65\3\66"+
-		"\6\66\u01c5\n\66\r\66\16\66\u01c6\3\67\3\67\3\67\3\67\38\68\u01ce\n8\r"+
-		"8\168\u01cf\38\38\39\39\3:\3:\3;\3;\3<\3<\3=\3=\3>\3>\3?\3?\3@\3@\3A\3"+
-		"A\3B\3B\3C\3C\3D\3D\3E\3E\3F\3F\3G\3G\3H\3H\3I\3I\3J\3J\3K\3K\3L\3L\3"+
-		"M\3M\3N\3N\3O\3O\3P\3P\3Q\3Q\3R\3R\3\u01b7\2S\3\3\5\4\7\5\t\6\13\7\r\b"+
-		"\17\t\21\n\23\13\25\f\27\r\31\16\33\17\35\20\37\21!\22#\23%\24\'\25)\26"+
-		"+\27-\30/\31\61\32\63\33\65\34\67\359\36;\37= ?!A\"C#E$G%I&K\'M(O)Q*S"+
-		"+U,W-Y.[/]\60_\61a\62c\63e\64g\65i\66k\67m8o9q\2s\2u\2w\2y\2{\2}\2\177"+
-		"\2\u0081\2\u0083\2\u0085\2\u0087\2\u0089\2\u008b\2\u008d\2\u008f\2\u0091"+
-		"\2\u0093\2\u0095\2\u0097\2\u0099\2\u009b\2\u009d\2\u009f\2\u00a1\2\u00a3"+
-		"\2\3\2$\4\2--//\3\2\62;\4\2..\60\60\5\2\62;C\\c|\6\2//\62;C\\c|\6\2\13"+
-		"\f\17\17\"\"\60\60\3\2\f\f\5\2\13\13\17\17\"\"\4\2CCcc\4\2DDdd\4\2EEe"+
-		"e\4\2FFff\4\2GGgg\4\2HHhh\4\2IIii\4\2JJjj\4\2KKkk\4\2LLll\4\2MMmm\4\2"+
-		"NNnn\4\2OOoo\4\2PPpp\4\2QQqq\4\2RRrr\4\2SSss\4\2TTtt\4\2UUuu\4\2VVvv\4"+
-		"\2WWww\4\2XXxx\4\2YYyy\4\2ZZzz\4\2[[{{\4\2\\\\||\2\u01f5\2\3\3\2\2\2\2"+
-		"\5\3\2\2\2\2\7\3\2\2\2\2\t\3\2\2\2\2\13\3\2\2\2\2\r\3\2\2\2\2\17\3\2\2"+
-		"\2\2\21\3\2\2\2\2\23\3\2\2\2\2\25\3\2\2\2\2\27\3\2\2\2\2\31\3\2\2\2\2"+
-		"\33\3\2\2\2\2\35\3\2\2\2\2\37\3\2\2\2\2!\3\2\2\2\2#\3\2\2\2\2%\3\2\2\2"+
-		"\2\'\3\2\2\2\2)\3\2\2\2\2+\3\2\2\2\2-\3\2\2\2\2/\3\2\2\2\2\61\3\2\2\2"+
-		"\2\63\3\2\2\2\2\65\3\2\2\2\2\67\3\2\2\2\29\3\2\2\2\2;\3\2\2\2\2=\3\2\2"+
-		"\2\2?\3\2\2\2\2A\3\2\2\2\2C\3\2\2\2\2E\3\2\2\2\2G\3\2\2\2\2I\3\2\2\2\2"+
-		"K\3\2\2\2\2M\3\2\2\2\2O\3\2\2\2\2Q\3\2\2\2\2S\3\2\2\2\2U\3\2\2\2\2W\3"+
-		"\2\2\2\2Y\3\2\2\2\2[\3\2\2\2\2]\3\2\2\2\2_\3\2\2\2\2a\3\2\2\2\2c\3\2\2"+
-		"\2\2e\3\2\2\2\2g\3\2\2\2\2i\3\2\2\2\2k\3\2\2\2\2m\3\2\2\2\2o\3\2\2\2\3"+
-		"\u00a5\3\2\2\2\5\u00ac\3\2\2\2\7\u00b0\3\2\2\2\t\u00ba\3\2\2\2\13\u00be"+
-		"\3\2\2\2\r\u00c1\3\2\2\2\17\u00c6\3\2\2\2\21\u00d0\3\2\2\2\23\u00d8\3"+
-		"\2\2\2\25\u00df\3\2\2\2\27\u00e8\3\2\2\2\31\u00ed\3\2\2\2\33\u00f1\3\2"+
-		"\2\2\35\u00fa\3\2\2\2\37\u0100\3\2\2\2!\u0105\3\2\2\2#\u010c\3\2\2\2%"+
-		"\u011b\3\2\2\2\'\u011e\3\2\2\2)\u0121\3\2\2\2+\u012a\3\2\2\2-\u012d\3"+
-		"\2\2\2/\u0131\3\2\2\2\61\u0134\3\2\2\2\63\u013a\3\2\2\2\65\u013d\3\2\2"+
-		"\2\67\u0147\3\2\2\29\u014f\3\2\2\2;\u0154\3\2\2\2=\u015a\3\2\2\2?\u015f"+
-		"\3\2\2\2A\u0168\3\2\2\2C\u016d\3\2\2\2E\u0170\3\2\2\2G\u0175\3\2\2\2I"+
-		"\u017a\3\2\2\2K\u017f\3\2\2\2M\u0183\3\2\2\2O\u0185\3\2\2\2Q\u0188\3\2"+
-		"\2\2S\u018b\3\2\2\2U\u018d\3\2\2\2W\u018f\3\2\2\2Y\u0192\3\2\2\2[\u0194"+
-		"\3\2\2\2]\u0196\3\2\2\2_\u0198\3\2\2\2a\u019a\3\2\2\2c\u019d\3\2\2\2e"+
-		"\u01a5\3\2\2\2g\u01b3\3\2\2\2i\u01bc\3\2\2\2k\u01c4\3\2\2\2m\u01c8\3\2"+
-		"\2\2o\u01cd\3\2\2\2q\u01d3\3\2\2\2s\u01d5\3\2\2\2u\u01d7\3\2\2\2w\u01d9"+
-		"\3\2\2\2y\u01db\3\2\2\2{\u01dd\3\2\2\2}\u01df\3\2\2\2\177\u01e1\3\2\2"+
-		"\2\u0081\u01e3\3\2\2\2\u0083\u01e5\3\2\2\2\u0085\u01e7\3\2\2\2\u0087\u01e9"+
-		"\3\2\2\2\u0089\u01eb\3\2\2\2\u008b\u01ed\3\2\2\2\u008d\u01ef\3\2\2\2\u008f"+
-		"\u01f1\3\2\2\2\u0091\u01f3\3\2\2\2\u0093\u01f5\3\2\2\2\u0095\u01f7\3\2"+
-		"\2\2\u0097\u01f9\3\2\2\2\u0099\u01fb\3\2\2\2\u009b\u01fd\3\2\2\2\u009d"+
-		"\u01ff\3\2\2\2\u009f\u0201\3\2\2\2\u00a1\u0203\3\2\2\2\u00a3\u0205\3\2"+
-		"\2\2\u00a5\u00a6\5q9\2\u00a6\u00a7\5u;\2\u00a7\u00a8\5u;\2\u00a8\u00a9"+
-		"\5y=\2\u00a9\u00aa\5\u008fH\2\u00aa\u00ab\5\u0097L\2\u00ab\4\3\2\2\2\u00ac"+
-		"\u00ad\5q9\2\u00ad\u00ae\5w<\2\u00ae\u00af\5w<\2\u00af\6\3\2\2\2\u00b0"+
-		"\u00b1\5q9\2\u00b1\u00b2\5w<\2\u00b2\u00b3\5\u009bN\2\u00b3\u00b4\5q9"+
-		"\2\u00b4\u00b5\5\u008bF\2\u00b5\u00b6\5u;\2\u00b6\u00b7\5\u0081A\2\u00b7"+
-		"\u00b8\5\u008bF\2\u00b8\u00b9\5}?\2\u00b9\b\3\2\2\2\u00ba\u00bb\5q9\2"+
-		"\u00bb\u00bc\5\u008bF\2\u00bc\u00bd\5w<\2\u00bd\n\3\2\2\2\u00be\u00bf"+
-		"\5s:\2\u00bf\u00c0\5\u00a1Q\2\u00c0\f\3\2\2\2\u00c1\u00c2\5w<\2\u00c2"+
-		"\u00c3\5q9\2\u00c3\u00c4\5\u0097L\2\u00c4\u00c5\5q9\2\u00c5\16\3\2\2\2"+
-		"\u00c6\u00c7\5w<\2\u00c7\u00c8\5y=\2\u00c8\u00c9\5\u0087D\2\u00c9\u00ca"+
-		"\5\u0081A\2\u00ca\u00cb\5\u0089E\2\u00cb\u00cc\5\u0081A\2\u00cc\u00cd"+
-		"\5\u0097L\2\u00cd\u00ce\5y=\2\u00ce\u00cf\5w<\2\u00cf\20\3\2\2\2\u00d0"+
-		"\u00d1\5w<\2\u00d1\u00d2\5\u0081A\2\u00d2\u00d3\5\u0095K\2\u00d3\u00d4"+
-		"\5\u008fH\2\u00d4\u00d5\5\u0087D\2\u00d5\u00d6\5q9\2\u00d6\u00d7\5\u00a1"+
-		"Q\2\u00d7\22\3\2\2\2\u00d8\u00d9\5w<\2\u00d9\u00da\5\u0081A\2\u00da\u00db"+
-		"\5\u009bN\2\u00db\u00dc\5\u0081A\2\u00dc\u00dd\5w<\2\u00dd\u00de\5y=\2"+
-		"\u00de\24\3\2\2\2\u00df\u00e0\5w<\2\u00e0\u00e1\5\u0081A\2\u00e1\u00e2"+
-		"\5\u009bN\2\u00e2\u00e3\5\u0081A\2\u00e3\u00e4\5\u0095K\2\u00e4\u00e5"+
-		"\5\u0081A\2\u00e5\u00e6\5\u008dG\2\u00e6\u00e7\5\u008bF\2\u00e7\26\3\2"+
-		"\2\2\u00e8\u00e9\5y=\2\u00e9\u00ea\5\u0087D\2\u00ea\u00eb\5\u0095K\2\u00eb"+
-		"\u00ec\5y=\2\u00ec\30\3\2\2\2\u00ed\u00ee\5y=\2\u00ee\u00ef\5\u008bF\2"+
-		"\u00ef\u00f0\5w<\2\u00f0\32\3\2\2\2\u00f1\u00f2\5y=\2\u00f2\u00f3\5\u009b"+
-		"N\2\u00f3\u00f4\5q9\2\u00f4\u00f5\5\u0087D\2\u00f5\u00f6\5\u0099M\2\u00f6"+
-		"\u00f7\5q9\2\u00f7\u00f8\5\u0097L\2\u00f8\u00f9\5y=\2\u00f9\34\3\2\2\2"+
-		"\u00fa\u00fb\5{>\2\u00fb\u00fc\5q9\2\u00fc\u00fd\5\u0087D\2\u00fd\u00fe"+
-		"\5\u0095K\2\u00fe\u00ff\5y=\2\u00ff\36\3\2\2\2\u0100\u0101\5{>\2\u0101"+
-		"\u0102\5\u0093J\2\u0102\u0103\5\u008dG\2\u0103\u0104\5\u0089E\2\u0104"+
-		" \3\2\2\2\u0105\u0106\5}?\2\u0106\u0107\5\u0081A\2\u0107\u0108\5\u009b"+
-		"N\2\u0108\u0109\5\u0081A\2\u0109\u010a\5\u008bF\2\u010a\u010b\5}?\2\u010b"+
-		"\"\3\2\2\2\u010c\u010d\5\u0081A\2\u010d\u010e\5w<\2\u010e\u010f\5y=\2"+
-		"\u010f\u0110\5\u008bF\2\u0110\u0111\5\u0097L\2\u0111\u0112\5\u0081A\2"+
-		"\u0112\u0113\5{>\2\u0113\u0114\5\u0081A\2\u0114\u0115\5u;\2\u0115\u0116"+
-		"\5q9\2\u0116\u0117\5\u0097L\2\u0117\u0118\5\u0081A\2\u0118\u0119\5\u008d"+
-		"G\2\u0119\u011a\5\u008bF\2\u011a$\3\2\2\2\u011b\u011c\5\u0081A\2\u011c"+
-		"\u011d\5{>\2\u011d&\3\2\2\2\u011e\u011f\5\u0081A\2\u011f\u0120\5\u0095"+
-		"K\2\u0120(\3\2\2\2\u0121\u0122\5\u0089E\2\u0122\u0123\5\u0099M\2\u0123"+
-		"\u0124\5\u0087D\2\u0124\u0125\5\u0097L\2\u0125\u0126\5\u0081A\2\u0126"+
-		"\u0127\5\u008fH\2\u0127\u0128\5\u0087D\2\u0128\u0129\5\u00a1Q\2\u0129"+
-		"*\3\2\2\2\u012a\u012b\5\u008bF\2\u012b\u012c\5\u008dG\2\u012c,\3\2\2\2"+
-		"\u012d\u012e\5\u008bF\2\u012e\u012f\5\u008dG\2\u012f\u0130\5\u0097L\2"+
-		"\u0130.\3\2\2\2\u0131\u0132\5\u008dG\2\u0132\u0133\5{>\2\u0133\60\3\2"+
-		"\2\2\u0134\u0135\5\u008dG\2\u0135\u0136\5\u0097L\2\u0136\u0137\5\177@"+
-		"\2\u0137\u0138\5y=\2\u0138\u0139\5\u0093J\2\u0139\62\3\2\2\2\u013a\u013b"+
-		"\5\u008dG\2\u013b\u013c\5\u0093J\2\u013c\64\3\2\2\2\u013d\u013e\5\u008f"+
-		"H\2\u013e\u013f\5\u0093J\2\u013f\u0140\5\u008dG\2\u0140\u0141\5u;\2\u0141"+
-		"\u0142\5y=\2\u0142\u0143\5w<\2\u0143\u0144\5\u0099M\2\u0144\u0145\5\u0093"+
-		"J\2\u0145\u0146\5y=\2\u0146\66\3\2\2\2\u0147\u0148\5\u008fH\2\u0148\u0149"+
-		"\5\u0081A\2\u0149\u014a\5u;\2\u014a\u014b\5\u0097L\2\u014b\u014c\5\u0099"+
-		"M\2\u014c\u014d\5\u0093J\2\u014d\u014e\5y=\2\u014e8\3\2\2\2\u014f\u0150"+
-		"\5\u0095K\2\u0150\u0151\5\u0081A\2\u0151\u0152\5\u00a3R\2\u0152\u0153"+
-		"\5y=\2\u0153:\3\2\2\2\u0154\u0155\5\u0095K\2\u0155\u0156\5\u008fH\2\u0156"+
-		"\u0157\5q9\2\u0157\u0158\5u;\2\u0158\u0159\5y=\2\u0159<\3\2\2\2\u015a"+
-		"\u015b\5\u0095K\2\u015b\u015c\5\u0097L\2\u015c\u015d\5\u008dG\2\u015d"+
-		"\u015e\5\u008fH\2\u015e>\3\2\2\2\u015f\u0160\5\u0095K\2\u0160\u0161\5"+
-		"\u0099M\2\u0161\u0162\5s:\2\u0162\u0163\5\u0097L\2\u0163\u0164\5\u0093"+
-		"J\2\u0164\u0165\5q9\2\u0165\u0166\5u;\2\u0166\u0167\5\u0097L\2\u0167@"+
-		"\3\2\2\2\u0168\u0169\5\u0097L\2\u0169\u016a\5\177@\2\u016a\u016b\5y=\2"+
-		"\u016b\u016c\5\u008bF\2\u016cB\3\2\2\2\u016d\u016e\5\u0097L\2\u016e\u016f"+
-		"\5\u008dG\2\u016fD\3\2\2\2\u0170\u0171\5\u0097L\2\u0171\u0172\5\u0093"+
-		"J\2\u0172\u0173\5\u0099M\2\u0173\u0174\5y=\2\u0174F\3\2\2\2\u0175\u0176"+
-		"\5\u009dO\2\u0176\u0177\5\u0081A\2\u0177\u0178\5\u0097L\2\u0178\u0179"+
-		"\5\177@\2\u0179H\3\2\2\2\u017a\u017b\5\u009dO\2\u017b\u017c\5\177@\2\u017c"+
-		"\u017d\5y=\2\u017d\u017e\5\u008bF\2\u017eJ\3\2\2\2\u017f\u0180\5\u009f"+
-		"P\2\u0180\u0181\5\u008dG\2\u0181\u0182\5\u0093J\2\u0182L\3\2\2\2\u0183"+
-		"\u0184\7?\2\2\u0184N\3\2\2\2\u0185\u0186\7@\2\2\u0186\u0187\7?\2\2\u0187"+
-		"P\3\2\2\2\u0188\u0189\7>\2\2\u0189\u018a\7?\2\2\u018aR\3\2\2\2\u018b\u018c"+
-		"\7@\2\2\u018cT\3\2\2\2\u018d\u018e\7>\2\2\u018eV\3\2\2\2\u018f\u0190\7"+
-		",\2\2\u0190\u0191\7,\2\2\u0191X\3\2\2\2\u0192\u0193\7-\2\2\u0193Z\3\2"+
-		"\2\2\u0194\u0195\7/\2\2\u0195\\\3\2\2\2\u0196\u0197\7,\2\2\u0197^\3\2"+
-		"\2\2\u0198\u0199\7\61\2\2\u0199`\3\2\2\2\u019a\u019b\7\60\2\2\u019bb\3"+
-		"\2\2\2\u019c\u019e\t\2\2\2\u019d\u019c\3\2\2\2\u019d\u019e\3\2\2\2\u019e"+
-		"\u01a0\3\2\2\2\u019f\u01a1\t\3\2\2\u01a0\u019f\3\2\2\2\u01a1\u01a2\3\2"+
-		"\2\2\u01a2\u01a0\3\2\2\2\u01a2\u01a3\3\2\2\2\u01a3d\3\2\2\2\u01a4\u01a6"+
-		"\t\2\2\2\u01a5\u01a4\3\2\2\2\u01a5\u01a6\3\2\2\2\u01a6\u01aa\3\2\2\2\u01a7"+
-		"\u01a9\t\3\2\2\u01a8\u01a7\3\2\2\2\u01a9\u01ac\3\2\2\2\u01aa\u01a8\3\2"+
-		"\2\2\u01aa\u01ab\3\2\2\2\u01ab\u01ad\3\2\2\2\u01ac\u01aa\3\2\2\2\u01ad"+
-		"\u01af\t\4\2\2\u01ae\u01b0\t\3\2\2\u01af\u01ae\3\2\2\2\u01b0\u01b1\3\2"+
-		"\2\2\u01b1\u01af\3\2\2\2\u01b1\u01b2\3\2\2\2\u01b2f\3\2\2\2\u01b3\u01b7"+
-		"\7$\2\2\u01b4\u01b6\13\2\2\2\u01b5\u01b4\3\2\2\2\u01b6\u01b9\3\2\2\2\u01b7"+
-		"\u01b8\3\2\2\2\u01b7\u01b5\3\2\2\2\u01b8\u01ba\3\2\2\2\u01b9\u01b7\3\2"+
-		"\2\2\u01ba\u01bb\7$\2\2\u01bbh\3\2\2\2\u01bc\u01c0\t\5\2\2\u01bd\u01bf"+
-		"\t\6\2\2\u01be\u01bd\3\2\2\2\u01bf\u01c2\3\2\2\2\u01c0\u01be\3\2\2\2\u01c0"+
-		"\u01c1\3\2\2\2\u01c1j\3\2\2\2\u01c2\u01c0\3\2\2\2\u01c3\u01c5\n\7\2\2"+
-		"\u01c4\u01c3\3\2\2\2\u01c5\u01c6\3\2\2\2\u01c6\u01c4\3\2\2\2\u01c6\u01c7"+
-		"\3\2\2\2\u01c7l\3\2\2\2\u01c8\u01c9\t\b\2\2\u01c9\u01ca\3\2\2\2\u01ca"+
-		"\u01cb\b\67\2\2\u01cbn\3\2\2\2\u01cc\u01ce\t\t\2\2\u01cd\u01cc\3\2\2\2"+
-		"\u01ce\u01cf\3\2\2\2\u01cf\u01cd\3\2\2\2\u01cf\u01d0\3\2\2\2\u01d0\u01d1"+
-		"\3\2\2\2\u01d1\u01d2\b8\3\2\u01d2p\3\2\2\2\u01d3\u01d4\t\n\2\2\u01d4r"+
-		"\3\2\2\2\u01d5\u01d6\t\13\2\2\u01d6t\3\2\2\2\u01d7\u01d8\t\f\2\2\u01d8"+
-		"v\3\2\2\2\u01d9\u01da\t\r\2\2\u01dax\3\2\2\2\u01db\u01dc\t\16\2\2\u01dc"+
-		"z\3\2\2\2\u01dd\u01de\t\17\2\2\u01de|\3\2\2\2\u01df\u01e0\t\20\2\2\u01e0"+
-		"~\3\2\2\2\u01e1\u01e2\t\21\2\2\u01e2\u0080\3\2\2\2\u01e3\u01e4\t\22\2"+
-		"\2\u01e4\u0082\3\2\2\2\u01e5\u01e6\t\23\2\2\u01e6\u0084\3\2\2\2\u01e7"+
-		"\u01e8\t\24\2\2\u01e8\u0086\3\2\2\2\u01e9\u01ea\t\25\2\2\u01ea\u0088\3"+
-		"\2\2\2\u01eb\u01ec\t\26\2\2\u01ec\u008a\3\2\2\2\u01ed\u01ee\t\27\2\2\u01ee"+
-		"\u008c\3\2\2\2\u01ef\u01f0\t\30\2\2\u01f0\u008e\3\2\2\2\u01f1\u01f2\t"+
-		"\31\2\2\u01f2\u0090\3\2\2\2\u01f3\u01f4\t\32\2\2\u01f4\u0092\3\2\2\2\u01f5"+
-		"\u01f6\t\33\2\2\u01f6\u0094\3\2\2\2\u01f7\u01f8\t\34\2\2\u01f8\u0096\3"+
-		"\2\2\2\u01f9\u01fa\t\35\2\2\u01fa\u0098\3\2\2\2\u01fb\u01fc\t\36\2\2\u01fc"+
-		"\u009a\3\2\2\2\u01fd\u01fe\t\37\2\2\u01fe\u009c\3\2\2\2\u01ff\u0200\t"+
-		" \2\2\u0200\u009e\3\2\2\2\u0201\u0202\t!\2\2\u0202\u00a0\3\2\2\2\u0203"+
-		"\u0204\t\"\2\2\u0204\u00a2\3\2\2\2\u0205\u0206\t#\2\2\u0206\u00a4\3\2"+
-		"\2\2\f\2\u019d\u01a2\u01a5\u01aa\u01b1\u01b7\u01c0\u01c6\u01cf\4\2\3\2"+
-		"\b\2\2";
-	public static final ATN _ATN =
-		new ATNDeserializer().deserialize(_serializedATN.toCharArray());
-	static {
-		_decisionToDFA = new DFA[_ATN.getNumberOfDecisions()];
-		for (int i = 0; i < _ATN.getNumberOfDecisions(); i++) {
-			_decisionToDFA[i] = new DFA(_ATN.getDecisionState(i), i);
-		}
-	}
-}
\ No newline at end of file
diff --git a/src/main/antlr/gen/BabyCobolVocabular.tokens b/src/main/antlr/gen/BabyCobolVocabular.tokens
deleted file mode 100644
index 2004f3e..0000000
--- a/src/main/antlr/gen/BabyCobolVocabular.tokens
+++ /dev/null
@@ -1,66 +0,0 @@
-ACCEPT=1
-ADD=2
-ADVANCING=3
-AND=4
-BY=5
-DATA=6
-DELIMITED=7
-DISPLAY=8
-DIVIDE=9
-DIVISION=10
-ELSE=11
-END=12
-EVALUATE=13
-FALSE=14
-FROM=15
-GIVING=16
-IDENTIFICATION=17
-IF=18
-IS=19
-MULTIPLY=20
-NO=21
-NOT=22
-OF=23
-OTHER=24
-OR=25
-PROCEDURE=26
-PICTURE=27
-SIZE=28
-SPACE=29
-STOP=30
-SUBTRACT=31
-THEN=32
-TO=33
-TRUE=34
-WITH=35
-WHEN=36
-XOR=37
-EQ=38
-GE=39
-LE=40
-GT=41
-LT=42
-POW_OP=43
-ADD_OP=44
-SUB_OP=45
-MUL_OP=46
-DIV_OP=47
-DOT=48
-INT_LIT=49
-NUM_LIT=50
-TXT_LIT=51
-ID=52
-NO_DOTS=53
-NEW_LINE=54
-WS=55
-'='=38
-'>='=39
-'<='=40
-'>'=41
-'<'=42
-'**'=43
-'+'=44
-'-'=45
-'*'=46
-'/'=47
-'.'=48
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
index 2a28a0f..0803d1d 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/checker/Checker.kt
@@ -276,6 +276,13 @@ class Checker(private val errors: MutableList<FaultInstance>, private val warnin
         checkArithmeticStat(ctx.atomic(0), ctx.atomic(1), ctx.GIVING(), ctx.identifier())
     }
 
+    /**
+     * On the exit of an SUBTRACT token in the parse tree, check if it is a valid statement.
+     */
+    override fun exitDivideStat(ctx: BabyCobol.DivideStatContext) {
+        checkArithmeticStat(ctx.atomic(0), ctx.atomic(1), ctx.GIVING(), ctx.identifier(0), divide = true, remainder = ctx.REMAINDER(), remainderIdentifier = ctx.identifier(1))
+    }
+
     /**
      * On the exit of an PERFORM we check if the times is a valid statement.
      */
@@ -298,15 +305,21 @@ class Checker(private val errors: MutableList<FaultInstance>, private val warnin
         leftAtomic: BabyCobol.AtomicContext,
         rightAtomic: BabyCobol.AtomicContext,
         giving: TerminalNode?,
-        identifier: BabyCobol.IdentifierContext?
+        identifier: BabyCobol.IdentifierContext?,
+        remainderIdentifier: BabyCobol.IdentifierContext? = null,
+        remainder: TerminalNode? = null,
+        divide: Boolean = false
     ) {
         // If the second atomic is a literal and no GIVING-clause is present, it is invalid.
-        if (rightAtomic is BabyCobol.LiteralAtomicContext && giving == null) {
+        // For divide: if the first atomic is a literal and no GIVING-clause and no REMAINDER-clause is present, it is invalid.
+        if (divide && leftAtomic is BabyCobol.LiteralAtomicContext && giving == null && remainder == null) {
+            rightAtomic.start.addError(MissingGiving) { "Missing Giving" }
+        } else if (!divide && rightAtomic is BabyCobol.LiteralAtomicContext && giving == null) {
             rightAtomic.start.addError(MissingGiving) { "Missing Giving" }
         }
 
         // If GIVING-clause is present, check if the identifier is has a numerical type.
-        if (giving != null && identifier != null) {
+        if ((giving != null && identifier != null) || (remainder != null && identifier != null)) {
             checkNumericalType(identifier)
         }
 
@@ -314,41 +327,12 @@ class Checker(private val errors: MutableList<FaultInstance>, private val warnin
         checkNumericalType(leftAtomic)
         checkNumericalType(rightAtomic)
         checkEqualType(leftAtomic, rightAtomic, false)
-    }
-
-    /**
-     * On the exit of an DispOption token in the parse tree, check if it is a valid statement.
-     */
-    override fun exitDispOptions(ctx: BabyCobol.DispOptionsContext) {
-        val delimited = ctx.DELIMITED() != null
-        val by = ctx.BY() != null
-        val space = ctx.SPACE() != null
-        val size = ctx.SIZE() != null
-        val lit = ctx.literal() != null
 
-        // Both DELIMITED and BY must be present or both not.
-        if ((delimited && !by) || (!delimited && by)) {
-            ctx.atomic().getStart().addError(InvalidDisplay) {
-                "Missing one or multiple parts of the DELIMITED BY-clause in DISPLAY statement"
-            }
-        }
-
-        // If both DELIMITED and BY are present, exactly one of SPACE, SIZE and literal must be present
-        if (delimited && by && ctx.childCount != 4) {
-            ctx.atomic().getStart().addError(InvalidDisplay) {
-                "The DELIMITED BY-clause in DISPLAY statement requires exactly one of SPACE, SIZE or literal to be present"
-            }
-        }
-
-        // If both DELIMITED and BY are not present, none of SPACE, SIZE and literal must be present
-        if (!delimited && !by && (space || size || lit)) {
-            ctx.atomic().getStart().addError(InvalidDisplay) {
-                "Unexpected token in DISPLAY statement, add DELIMITED BY-clause or remove token"
-            }
+        if (remainderIdentifier != null) {
+            checkNumericalType(remainderIdentifier)
         }
     }
 
-
     /**
      * {@inheritDoc}
      *
diff --git a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDivide.kt b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDivide.kt
index 2216573..5948d1a 100644
--- a/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDivide.kt
+++ b/src/main/kotlin/com/gitlab/legoatoom/babycobolcompiler/ir/IRDivide.kt
@@ -32,8 +32,7 @@ class IRDivide(
 
         } else if(givingRemainder != null){
             val id = givingRemainder.convert()
-            "$leftOp.setValue(($leftVal.div($rightVal)).toString())" + "\n" +
-                    "$id.setValue(($leftVal.mod($rightVal)).toString())"
+            "$id.setValue(($leftVal.mod($rightVal)).toString())"
         } else {
             "$leftOp.setValue(($leftVal.div($rightVal)).toString())"
         }
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/DivideOutputTest.kt b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/DivideOutputTest.kt
index 819182b..aadfede 100644
--- a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/DivideOutputTest.kt
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/DivideOutputTest.kt
@@ -1,38 +1,47 @@
 package com.gitlab.legoatoom.babycobolcompiler.output
 
-import kotlin.test.Ignore
 import kotlin.test.Test
 import kotlin.test.assertContains
 import kotlin.test.assertEquals
 
 internal class DivideOutputTest : OutputTestSetup() {
     @Test
-    @Ignore
     fun simpleDivide() {
         assertEquals("00015\n", getOutput("$outputDir/simpleDivide"))
     }
 
     @Test
-    @Ignore
     fun multipleDivides() {
         assertEquals("00005\n", getOutput("$outputDir/multipleDivides"))
     }
 
     @Test
-    @Ignore
+    fun divideWithRemainder() {
+        assertEquals("00010\n", getOutput("$outputDir/divideWithRemainder"))
+    }
+
+    @Test
+    fun divideWithGivingAndRemainder() {
+        assertEquals("00005\n010\n", getOutput("$outputDir/divideWithGivingAndRemainder"))
+    }
+
+    @Test
     fun divideMissingGiving() {
         assertContains(getError("$outputDir/divideNoGiving"), "MissingGivingError")
     }
 
     @Test
-    @Ignore
     fun divideIncorrectTypes() {
         assertContains(getError("$outputDir/divideIncorrectTypes"), "TypeError")
     }
 
     @Test
-    @Ignore
     fun unknownIdentifier() {
         assertContains(getError("$outputDir/divideUnknownIdentifier"), "UnresolvedReferenceError")
     }
+
+    @Test
+    fun invalidRemainderIdentifier() {
+        assertContains(getError("$outputDir/invalidRemainderIdentifier"), "UnresolvedReferenceError")
+    }
 }
\ No newline at end of file
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/divideWithGivingAndRemainder.bcl b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/divideWithGivingAndRemainder.bcl
new file mode 100644
index 0000000..7f84662
--- /dev/null
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/divideWithGivingAndRemainder.bcl
@@ -0,0 +1,8 @@
+       IDENTIFICATION DIVISION.
+           PROGRAM-ID. TEST.
+       DATA DIVISION.
+           01 BAR PICTURE IS 99999.
+           01 T PICTURE IS 999.
+       PROCEDURE DIVISION.
+           DIVIDE 90 INTO 16 GIVING BAR REMAINDER T.
+           DISPLAY BAR T.
\ No newline at end of file
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/divideWithRemainder.bcl b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/divideWithRemainder.bcl
new file mode 100644
index 0000000..776f918
--- /dev/null
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/divideWithRemainder.bcl
@@ -0,0 +1,7 @@
+       IDENTIFICATION DIVISION.
+           PROGRAM-ID. TEST.
+       DATA DIVISION.
+           01 BAR PICTURE IS 99999.
+       PROCEDURE DIVISION.
+           DIVIDE 90 INTO 16 REMAINDER BAR.
+           DISPLAY BAR.
\ No newline at end of file
diff --git a/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/invalidRemainderIdentifier.bcl b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/invalidRemainderIdentifier.bcl
new file mode 100644
index 0000000..1f42d89
--- /dev/null
+++ b/src/test/kotlin/com/gitlab/legoatoom/babycobolcompiler/output/bclfiles/invalidRemainderIdentifier.bcl
@@ -0,0 +1,7 @@
+       IDENTIFICATION DIVISION.
+           PROGRAM-ID. TEST.
+       DATA DIVISION.
+           01 BAR PICTURE IS 99999.
+       PROCEDURE DIVISION.
+           DIVIDE 90 INTO 16 GIVING BAR REMAINDER C.
+           DISPLAY BAR.
\ No newline at end of file
-- 
GitLab