cobrix icon indicating copy to clipboard operation
cobrix copied to clipboard

Improve AST post-parsing transformations

Open yruslan opened this issue 6 years ago • 0 comments

Background

CopybookParser is too big and becomes harder to maintain over time. This is because the object contains every post-parsing method it applies to the parsed AST. Example:

    val newTrees = if (dropGroupFillers) {
      calculateNonFillerSizes(setSegmentParents(markSegmentRedefines(processGroupFillers(markDependeeFields(
        addNonTerminals(calculateBinaryProperties(schemaANTLR), nonTerms, enc, stringTrimmingPolicy, ebcdicCodePage, floatingPointFormat)
      )), segmentRedefines), correctedFieldParentMap))
    } else {
      calculateNonFillerSizes(setSegmentParents(markSegmentRedefines(renameGroupFillers(markDependeeFields(
        addNonTerminals(calculateBinaryProperties(schemaANTLR), nonTerms, enc, stringTrimmingPolicy, ebcdicCodePage, floatingPointFormat)
      )), segmentRedefines), correctedFieldParentMap))
    }

Task

Extract and isolate AST transformers and replace this chain of method calls into a builder, for example.

yruslan avatar Oct 11 '19 14:10 yruslan