Skip to content

Repo Analysis

Benedict Albrecht edited this page Jun 2, 2026 · 1 revision

Repo Analysis

This page walks through how Crodox parses the Test_Repo using the Basics grammar. It shows the object trees Crodox builds, how variables resolve, and how cross-file dependencies form.

Work in progress: This analysis is based on the Basics grammar, which is not complete. It is a starting point meant to be extended and adapted to your needs.


File Discovery

The grammar starts with:

<~"FROM".txt~>

Crodox scans the repository and matches all .txt files. Each file gets a path variable FROM storing its relative path:

File FROM value
testFile.txt ./testFile
bridgeTest2.txt ./bridgeTest2
refFile.txt ./refFile
folder/bridgeTest.txt ./folder/bridgeTest

Parsed Object Trees

Crodox parses each file and builds a tree of recognized objects.

testFile.txt

FILE (FROM = ./testFile)
 |- import      name = C2  (:up)       FROM = ./bridgeTest2
 |- import      name = F5  (:up)       FROM = ./folder/bridgeTest
 |- variable    NAME = aaa
 |- variable    NAME = bbb
 |- variable    NAME = ccc
 |- class       NAME = C1  (:up)       params: a, b, c (:down)
 |   |- variable    NAME = hhh
 |   |- variable    NAME = zzz
 |   |- function    NAME = F1  (:up)   param: V1 (:down)
 |   |   |- variable    NAME = xxx     ref = 'zzz'
 |   |   |- variable    NAME = yyy
 |   |- function    NAME = F2  (:up)   param: V2 (:down)
 |       |- variable    NAME = zzz     ref = 'bbb'
 |       |- variable    NAME = yyy     ref = 'hhh'
 |- refference  'C1' . ![class|function] F1 ( 'aaa' )
 |- refference  'C1' . ![class|function] F2 ( 'ccc' )
 |- refference  'C2' . ![class|function] F3 ( )
 |- refference  'C2' . ![class|function] F4 ( )

bridgeTest2.txt

FILE (FROM = ./bridgeTest2)
 |- class       NAME = C2  (:up)       params: (none)
 |   |- variable    NAME = ddd
 |   |- variable    NAME = eee
 |   |- function    NAME = F3  (:up)   param: Q3 (:down)
 |   |   |- variable    NAME = ccc
 |   |   |- variable    NAME = ddd
 |   |- function    NAME = F4  (:up)   params: eee, aaa, bbb (:down)
 |       |- variable    NAME = xxx     ref = 'ddd'
 |       |- variable    NAME = yyy     ref = 'eee'

Note: F2(); at the end of bridgeTest2.txt does not match the refference object pattern (<<'name'>> . <<![class|function]name!>>) because there is no dot. Crodox will skip this line during parsing.

folder/bridgeTest.txt

FILE (FROM = ./folder/bridgeTest)
 |- import      name = C3  (:up)       FROM = ./refFile
 |- function    NAME = F5  (:up)       params: (none)
     |- variable    NAME = ccc
     |- variable    NAME = ddd

refFile.txt

FILE (FROM = ./refFile)
 |- class       NAME = C3  (:up)       params: (none)

The comment lines inside C3 are plain text. The Basics grammar has no comment object, so Crodox does not parse them. To capture comments, you would add a jump instruction (see Jump Instructions).


Variable Resolution

Reference variables (<<'name'>>) create dependencies. Crodox resolves each reference by searching upward through the scope tree.

testFile.txt - function F1

Reference Search path Resolves to
'zzz' in let xxx = zzz F1 scope -> C1 scope variable zzz in C1

testFile.txt - function F2

Reference Search path Resolves to
'bbb' in let zzz = bbb F2 scope -> C1 scope -> file scope variable bbb at file level
'hhh' in let yyy = hhh F2 scope -> C1 scope variable hhh in C1

testFile.txt - refferences

Reference Resolves to
'C1' class C1 (same file, :up scope)
![class|function] F1 function F1 inside C1 (dependency selection limits to class or function types)
![class|function] F2 function F2 inside C1
'aaa' variable aaa at file level
'ccc' variable ccc at file level
'C2' import C2 (same file, :up scope) - which links to bridgeTest2.txt
![class|function] F3 function F3 inside C2 in bridgeTest2.txt
![class|function] F4 function F4 inside C2 in bridgeTest2.txt

bridgeTest2.txt - function F4

Reference Search path Resolves to
'ddd' in let xxx = ddd F4 scope -> C2 scope variable ddd in C2
'eee' in let yyy = eee F4 scope (param) parameter eee of F4 (:down)

'eee' resolves to the parameter eee (:down scope) because :down parameters are visible inside the function body. The class-level variable eee is shadowed.


Cross-file Dependencies

Path variables (<<"FROM".txt>>) in import objects create links between files.

testFile.txt
  |- imports C2 from ----> bridgeTest2.txt
  |- imports F5 from ----> folder/bridgeTest.txt
                              |- imports C3 from ----> refFile.txt

How it works

  1. The import object matches from './bridgeTest2.txt'
  2. <<"FROM".txt>> extracts the path ./bridgeTest2
  3. Crodox looks for a file where the FROM path variable equals ./bridgeTest2
  4. bridgeTest2.txt matches - the files are now linked
  5. The imported name C2 (:up scope) becomes visible in testFile.txt
  6. References to C2 in testFile.txt can now resolve into bridgeTest2.txt

Dependency Graph

graph LR
    subgraph testFile.txt
        imp1[import C2]
        imp2[import F5]
        aaa[var aaa]
        bbb[var bbb]
        ccc[var ccc]
        C1[class C1]
        F1[function F1]
        F2[function F2]
        ref1[C1.F1]
        ref2[C1.F2]
        ref3[C2.F3]
        ref4[C2.F4]
    end

    subgraph bridgeTest2.txt
        C2[class C2]
        F3[function F3]
        F4[function F4]
    end

    subgraph folder/bridgeTest.txt
        impC3[import C3]
        F5[function F5]
    end

    subgraph refFile.txt
        C3[class C3]
    end

    imp1 -->|path| C2
    imp2 -->|path| F5
    impC3 -->|path| C3

    ref1 -->|ref| C1
    ref1 -->|dep select| F1
    ref1 -->|ref| aaa
    ref2 -->|ref| C1
    ref2 -->|dep select| F2
    ref2 -->|ref| ccc
    ref3 -->|ref| C2
    ref3 -->|dep select| F3
    ref4 -->|ref| C2
    ref4 -->|dep select| F4
Loading

Clone this wiki locally