-
Notifications
You must be signed in to change notification settings - Fork 0
Grammar and Subgrammar Structure
Crodox uses a file-based grammar structure where files can include subgrammars to compose complex language definitions.
The grammar follows a top-to-bottom hierarchy. Objects defined higher up are inherited by all subgrammars below. Objects inside a subgrammar are not counted additionally at the parent level.
graph TD
MAIN["<b>File.xy</b><br/><~ "FROM1".xy ~>"] --> OA["objectA"]
MAIN --> OB["objectB"]
MAIN --> SERVICE["<b>File.service.xy</b><br/><~ "FROM2".service.xy ~>"]
MAIN --> OE["objectE"]
MAIN --> MODULE["<b>File.module.xy</b><br/><~ "FROM3".module.xy ~>"]
SERVICE -.->|"inherits"| OA
SERVICE -.->|"inherits"| OB
SERVICE --> OC["objectC"]
SERVICE --> OD["objectD"]
SERVICE -.->|"inherits"| OE
MODULE -.->|"inherits"| OA
MODULE -.->|"inherits"| OB
MODULE -.->|"inherits"| OE
MODULE --> OF["objectF"]
MODULE --> OG["objectG"]
style MAIN fill:#4a90d9,color:#fff
style SERVICE fill:#7b68ee,color:#fff
style MODULE fill:#7b68ee,color:#fff
style OC fill:#7b68ee,color:#fff
style OD fill:#7b68ee,color:#fff
style OF fill:#7b68ee,color:#fff
style OG fill:#7b68ee,color:#fff
Files can nest subgrammars using the file syntax. Each subgrammar inherits objects from its parent scope and adds its own definitions.
<~"FROM1".xy~>
<*objectA*> objectA <*>
<*objectB*> objectB <*>
<~"FROM2".service.xy~>
<*objectC*> objectC <*>
<*objectD*> objectD <*>
<~>
<*objectE*> objectE <*>
<~"FROM3".module.xy~>
<*objectF*> objectF <*>
<*objectG*> objectG <*>
<~>
<~>
| File | Visible Objects |
|---|---|
File.xy |
objectA, objectB, objectE |
File.service.xy |
objectA, objectB, objectC, objectD, objectE |
File.module.xy |
objectA, objectB, objectE, objectF, objectG |
Rule: Objects defined at the top level are visible in all subgrammars. Objects defined within a subgrammar are only visible within that subgrammar's scope.
When two object definitions match the same input, the upper definition takes priority. Objects are matched in the order they are defined - top to bottom.
See also: Dependency Structure - How objects form dependency trees.
- 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