AST Edge is an Edge type that represents programming language ASTs (Abstract Syntax Trees) as GEUL graphs.

PropertyDescription
Multi-language support64 languages in 6 bits
Common AST nodesSame concept across languages uses the same code
Lineage-based classificationSupports graceful degradation
PathGEUL integrationIncludes GEUL graph traversal language

Packet Structure

1st WORD (16 bits)
┌─────────────────────┬────────────────────┐
│       Prefix        │     Language       │
│       10bit         │        6bit        │
└─────────────────────┴────────────────────┘

2nd WORD (16 bits)
┌─────────────────────────┬───────────────────┐
│     AST Node Type       │     Reserved      │
│         8bit            │       8bit        │
└─────────────────────────┴───────────────────┘

3rd WORD (16 bits)
┌─────────────────────────────────────────────┐
│                  Edge TID                   │
│                   16bit                     │
└─────────────────────────────────────────────┘

4th+ WORD: Child TIDs (variable, terminated by 0x0000)
FieldBitsSizeDescription
Prefix1-10100001 000 001 (AST Edge)
Language11-166Programming language code
AST Node Type17-248Node kind (3+5 split)
Reserved25-328For future extension (currently 0x00)
Edge TID33-4816Unique identifier for this Edge
Child TIDs49+16xNChild node references

Word count: minimum 3 words (leaf node) ~ typical 4-8 words ~ unlimited

Language Codes (6 bits)

Lineage-based classification. Bits 1-2 are the major category (paradigm), bits 3-6 are the specific language.

System/Low-level (00xxxx)

CodeLanguageDescription
000000AbstractCommon AST for all languages
000001CSystem language archetype
000010C++C extension
000011RustModern systems
000100GoModern systems
000101ZigModern systems
000110AssemblyLowest level
000111DSystems
001000NimSystems

Application/VM (01xxxx)

CodeLanguageDescription
010000JavaVM family archetype
010001C#.NET
010010KotlinJVM
010011ScalaJVM+functional
010100SwiftApple
010101DartFlutter
010110GroovyJVM
010111ClojureJVM+Lisp

Scripting/Dynamic (10xxxx)

CodeLanguageDescription
100000PythonGeneral-purpose script archetype
100001JavaScriptWeb
100010TypeScriptJS+types
100011RubyGeneral-purpose
100100PHPWeb server
100101LuaEmbedded
100110PerlText processing
100111RStatistics
101000JuliaScientific computing
101001MATLABNumerical analysis

Declarative/Functional/Other (11xxxx)

CodeLanguageDescription
110000SQLQuery
110001HaskellPure functional
110010OCamlML family
110011F#.NET functional
110100ElixirBEAM
110101ErlangBEAM
110110ShellBash/Zsh
110111PowerShellWindows
111000WASMBytecode
111001LLVM IRIntermediate representation
111010HTMLMarkup
111011CSSStyling
111100JSONData
111101YAMLData
111110PathGEULGEUL graph traversal language
111111Extension wordAdditional languages (specified in 3rd word)

Graceful degradation: On bit loss, converges to a parent lineage → ultimately falls back to Abstract (000000).

AST Node Types (8 bits)

Split into 3-bit major category + 5-bit subtype.

Major Categories

CodeCategoryDescription
000DeclarationDeclarations (function, variable, type)
001StatementStatements (control flow, loops)
010ExpressionExpressions (operations, calls)
011TypeType expressions
100PatternPattern matching
101ModifierModifiers (access control, async)
110StructureStructure (block, module)
111Language-specificLanguage-specific nodes

Declaration (000xxxxx)

CodeNodeGoPythonC
000 00000FuncDeclFuncDeclFunctionDefFunctionDecl
000 00001VarDeclGenDecl(var)AssignVarDecl
000 00010ConstDeclGenDecl(const)-VarDecl(const)
000 00011TypeDeclTypeSpec-TypedefDecl
000 00100StructDeclStructTypeClassDefRecordDecl
000 00101InterfaceDeclInterfaceTypeClassDef(ABC)-
000 00110EnumDecl-EnumEnumDecl
000 00111ParamDeclFieldargParmVarDecl
000 01000MethodDeclFuncDecl(recv)FunctionDefCXXMethodDecl
000 01001ImportDeclImportSpecImport#include
000 01010PackageDeclpackage--
000 01011FieldDeclField-FieldDecl
000 01100LabelDeclLabeledStmt-LabelDecl

Statement (001xxxxx)

CodeNodeMeaning
001 00000IfStmtConditional
001 00001ForStmtFor loop
001 00010RangeStmtIterator loop
001 00011WhileStmtWhile loop
001 00100SwitchStmtSwitch/match
001 00101CaseClauseCase clause
001 00110ReturnStmtReturn
001 00111BreakStmtBreak
001 01000ContinueStmtContinue
001 01001GotoStmtGoto
001 01010BlockStmtBlock { }
001 01011ExprStmtExpression statement
001 01100AssignStmtAssignment
001 01101DeclStmtDeclaration statement
001 01110TryStmtException handling
001 01111ThrowStmtThrow exception
001 10000DeferStmtDefer
001 10001GoStmtGo
001 10010SelectStmtSelect
001 10011WithStmtWith
001 10100AssertStmtAssert
001 10101PassStmtPass

Expression (010xxxxx)

CodeNodeMeaning
010 00000BinaryExprBinary operation
010 00001UnaryExprUnary operation
010 00010CallExprFunction call
010 00011IndexExprIndex access a[i]
010 00100SliceExprSlice a[i:j]
010 00101SelectorExprField access a.b
010 00110IdentIdentifier
010 00111BasicLitBasic literal
010 01000CompositeLitComposite literal
010 01001FuncLitLambda/anonymous function
010 01010ParenExprParentheses (a)
010 01011StarExprPointer *a
010 01100UnaryAddrAddress &a
010 01101TypeAssertExprType assertion
010 01110KeyValueExprkey: value
010 01111TernaryExprTernary operation
010 10000ListCompList comprehension
010 10001DictCompDict comprehension
010 10010GeneratorExprGenerator
010 10011AwaitExprAwait
010 10100YieldExprYield
010 10101SendExprChannel send <-
010 10110RecvExprChannel receive <-ch

Type (011xxxxx)

CodeNodeMeaning
011 00000IdentTypeNamed type
011 00001PointerTypePointer *T
011 00010ArrayTypeArray [N]T
011 00011SliceTypeSlice []T
011 00100MapTypeMap map[K]V
011 00101ChanTypeChannel chan T
011 00110FuncTypeFunction type
011 00111StructTypeStruct type
011 01000InterfaceTypeInterface type
011 01001UnionTypeUnion A | B
011 01010OptionalTypeOptional T?
011 01011GenericTypeGeneric T[U]
011 01100TupleTypeTuple (A, B)

Pattern (100xxxxx)

CodeNodeMeaning
100 00000WildcardPattern_
100 00001IdentPatternName binding
100 00010LiteralPatternLiteral matching
100 00011TuplePatternTuple (a, b)
100 00100ListPatternList [a, b]
100 00101StructPatternStruct {a, b}
100 00110OrPatterna | b
100 00111GuardPatternGuard condition

Modifier (101xxxxx)

CodeNodeMeaning
101 00000Publicpublic/exported
101 00001Privateprivate
101 00010Protectedprotected
101 00011Staticstatic
101 00100Constconst
101 00101Asyncasync
101 00110Volatilevolatile
101 00111Inlineinline
101 01000Virtualvirtual
101 01001Abstractabstract
101 01010Finalfinal

Structure (110xxxxx)

CodeNodeMeaning
110 00000FileFile (top-level)
110 00001ModuleModule
110 00010PackagePackage
110 00011NamespaceNamespace
110 00100BlockBlock
110 00101CommentGroupComment group
110 00110CommentComment
110 00111DirectiveDirective (#pragma)

Language-specific (111xxxxx)

Language-specific nodes. 32 slots available.

PathGEUL (111110)

PathGEUL is a query language for traversing GEUL graphs. Just as XPath traverses XML, PathGEUL traverses GEUL graphs.

When the language code is 111110, the 8-bit AST node type is reinterpreted as query operators.

CodeOperationXPath equivalentDescription
00000000Root/Root node
00000001Child/childDirect child
00000010Descendant//All descendants
00000011Parent..Parent
00000100Ancestorancestor::All ancestors
00000101Siblingsibling::Siblings
00010000FilterType[type=…]Type filter
00100000FilterProp[@prop=…]Property filter
01000000Union|Union
01000001Intersect&Intersection

Examples

Go Function Declaration

func Add(a, b int) int {
    return a + b
}
AST Edge (FuncDecl):
  1st: [Prefix 10bit] [000100]       - Prefix + Go
  2nd: [000 00000] [00000000]        - FuncDecl + Reserved
  3rd: [TID: 0x0010]                 - This Edge TID
  4th: [TID: 0x0011]                 - Name "Add"
  5th: [TID: 0x0012]                 - Params
  6th: [TID: 0x0013]                 - Results
  7th: [TID: 0x0014]                 - Body
  8th: [0x0000]                      - Terminator

Total: 8 words

Python Function Definition

def greet(name: str) -> str:
    return f"Hello, {name}"
AST Edge (FuncDecl):
  1st: [Prefix 10bit] [100000]       - Prefix + Python
  2nd: [000 00000] [00000000]        - FuncDecl + Reserved
  3rd: [TID: 0x0020]                 - This Edge TID
  4th: [TID: 0x0021]                 - Name "greet"
  5th: [TID: 0x0022]                 - Params
  6th: [TID: 0x0023]                 - Returns
  7th: [TID: 0x0024]                 - Body
  8th: [0x0000]                      - Terminator

Total: 8 words

Leaf Node (Identifier)

AST Edge (Ident):
  1st: [Prefix 10bit] [000100]       - Prefix + Go
  2nd: [010 00110] [00000000]        - Ident + Reserved
  3rd: [TID: 0x0030]                 - This Edge TID
  4th: [0x0000]                      - Terminator (no children)

Total: 4 words