-
Notifications
You must be signed in to change notification settings - Fork 0
Example Basics
Benedict Albrecht edited this page Jun 2, 2026
·
5 revisions
A minimal Crodox grammar using pseudo-code with .txt files. This example is designed as a simple starting point to learn the core concepts before moving to real-world grammars.
Work in progress: This grammar is not complete. It is a starting point meant to be extended and adapted to your needs.
<~"FROM".txt~>
<:import:>
import <| <<name:up>> <||> { <<name:up>> } |> from <<"FROM".txt>> <| ; <||> \n |>
<:>
<:class:>
class <<NAME:up>> ( <? <| , <||> <<NAME:down>> |> ?> ) { <-function, class, refference, variable-> }
<:>
<:function:>
function <<NAME:up>> ( <? <| , <||> <<NAME:down>> |> ?> ) { <-function_-> }
<:>
<:variable:>
let <<NAME>> <? = <<'name'>> ?> ;
<:>
<:refference:>
<<'name'>> . <<![class|function]name!>> ( <? <| , <||> |> <<'name'>> ?> ) ;
<:>
<~>
| Element | Description |
|---|---|
<~"FROM".txt~> |
Matches all .txt files. "FROM" is the path variable for cross-file linking. |
| Object | Description |
|---|---|
import |
Imports a name or destructured name from another file. Uses :up scope so the imported name is visible to all siblings. <<"FROM".txt>> creates a path dependency to the referenced file. |
class |
Class with an uppercase variable <<NAME:up>> (overwrites, no dependency). Parameters use <<NAME:down>> to pass names into the class body. Body allows nested functions, classes, references, and variables. |
function |
Function with <<NAME:up>>. Parameters with <<NAME:down>>. Body uses <-function_-> - the underscore means it accepts any object type as children (wildcard sub-body). |
variable |
let declaration. Optional initializer = <<'name'>> uses a reference variable - creates a dependency without overwriting. |
refference |
Method call on an object. <<![class|function]name!>> uses dependency selection - only links to objects of type class or function. Parameters repeat with <<'name'>> references. |
| Concept | Where | What it does |
|---|---|---|
Path variable <<"FROM".txt>>
|
import |
Links files to each other |
:up scope |
import, class, function
|
Makes names visible to parent and older siblings |
:down scope |
class, function
|
Passes names into child objects (parameters) |
Uppercase variable <<NAME>>
|
class, function, variable
|
Overwrites the value, does not create a dependency |
Reference variable <<'name'>>
|
variable, refference
|
Creates a dependency, does not overwrite |
Dependency selection <<![class|function]name!>>
|
refference |
Limits which object types the reference can link to |
Or statement <| ... <||> ... |>
|
import, class, function
|
Alternative patterns (e.g., direct import vs destructured) |
Repeat <? ?>
|
class, function, refference
|
Repeats parameters separated by commas |
Sub-body <-...->
|
class |
Named sub-body - only listed object types allowed as children |
Wildcard sub-body <-name_->
|
function |
Underscore suffix - accepts any object type |
A matching test repository is available at test_repo with the following structure:
testFile.txt - imports, class C1 with functions F1/F2, references
bridgeTest2.txt - class C2 with functions F3/F4
refFile.txt - class C3 (minimal)
folder/
bridgeTest.txt - imports C3, function F5
import { C2 } from './bridgeTest2.txt';
import { F5 } from './folder/bridgeTest.txt';
let aaa ;
let bbb ;
let ccc ;
class C1 (a , b , c ) {
let hhh ;
let zzz ;
function F1 ( V1 ) {
let xxx = zzz;
let yyy;
}
function F2 ( V2 ) {
let zzz = bbb;
let yyy = hhh;
}
}
C1.F1(aaa);
C1.F2(ccc);
C2.F3();
C2.F4();
class C2 () {
let ddd ;
let eee ;
function F3 ( Q3 ) {
let ccc ;
let ddd ;
}
function F4 ( eee, aaa, bbb ) {
let xxx = ddd;
let yyy = eee;
}
F2();
}
import { C3 } from '../refFile.txt';
function F5 ( ) {
let ccc ;
let ddd ;
}
class C3 () {
// hello world
// dfkjljf K
}
See also: Angular Example - C# Example - Python Example - Syntax Overview
- Getting Started
- Sign-Up
- Home Screen
- Creating Your First Template
- Template Editor
- Application Navigation
- Syntax Overview
- Workflow: End-to-End
- Workflow: Test with simpleDemo
- Workflow: Build Template from angularTemp
- Demo Repositories
- Template
- Workbench
- GitHub Integration
- GitHub App Installation
- GitHub Repository Setup
- GitHub Re-linking
- Settings
- Overview
- Declarations
- Types
- Scoping