AST Edge μ½λλΆ β νλ‘κ·Έλλ° μΈμ΄ ASTλ₯Ό GEULλ‘ νννκΈ° μν Edge μΈμ½λ
Author: λ°μ€μ° (mail@parkjunwoo.com )
License: MIT
AST Edgeλ **νλ‘κ·Έλλ° μΈμ΄μ AST(Abstract Syntax Tree)**λ₯Ό GEUL κ·Έλνλ‘ νννλ Edge νμ
μ΄λ€.
λ€μ€ μΈμ΄ μ§μ: 6λΉνΈλ‘ 64κ° μΈμ΄ νν
κ³΅ν΅ AST λ
Έλ: μΈμ΄ κ° λμΌ κ°λ
μ λμΌ μ½λ
κ³ν΅ κΈ°λ° λΆλ₯: μ°μν μ΄ν(graceful degradation) μ§μ
PathGEUL ν΅ν©: GEUL κ·Έλν νμ μΈμ΄ ν¬ν¨
1st WORD (16λΉνΈ)
βββββββββββββββββββββββ¬βββββββββββββββββββββ
β Prefix β μΈμ΄ β
β 10bit β 6bit β
βββββββββββββββββββββββ΄βββββββββββββββββββββ
2nd WORD (16λΉνΈ)
βββββββββββββββββββββββββββ¬ββββββββββββββββββββ
β AST λ
Έλ νμ
β μμ½ β
β 8bit β 8bit β
βββββββββββββββββββββββββββ΄ββββββββββββββββββββ
3rd WORD (16λΉνΈ)
βββββββββββββββββββββββββββββββββββββββββββββββ
β Edge TID β
β 16bit β
βββββββββββββββββββββββββββββββββββββββββββββββ
4th+ WORD: μμ TIDλ€ (κ°λ³, μ’
κ²° λ§μ»€ 0x0000μΌλ‘ λ)
νλ
λΉνΈ
μμΉ
μ€λͺ
Prefix
10
1st[15:6]
1100 000 000 (Standard) / 1100 000 110 (Proposal)
μΈμ΄
6
1st[5:0]
νλ‘κ·Έλλ° μΈμ΄ μ½λ
AST λ
Έλ νμ
8
2nd[15:8]
λ
Έλ μ’
λ₯ (3+5 λΆν )
μμ½
8
2nd[7:0]
λ―Έλ νμ₯μ© (νμ¬ 0x00)
Edge TID
16
3rd
μ΄ Edgeμ κ³ μ μλ³μ
μμ TID
16ΓN
4th+
μμ λ
Έλ μ°Έμ‘°
μλ μ: μ΅μ 3μλ(리ν λ
Έλ) ~ μΌλ° 4β8μλ ~ μ ν μμ
κ³ν΅ κΈ°λ° λΆλ₯. bit1-2κ° λλΆλ₯(ν¨λ¬λ€μ), bit3-6μ΄ μΈλΆ μΈμ΄.
μμ€ν
/μ μμ€ (00xxxx)
μ½λ
μΈμ΄
μ€λͺ
000000
Abstract
λͺ¨λ μΈμ΄μ κ³΅ν΅ AST
000001
C
μμ€ν
μΈμ΄ μν
000010
C++
C νμ₯
000011
Rust
νλ μμ€ν
000100
Go
νλ μμ€ν
000101
Zig
νλ μμ€ν
000110
Assembly
μ΅μ μμ€
000111
D
μμ€ν
001000
Nim
μμ€ν
μ½λ
μΈμ΄
μ€λͺ
010000
Java
VM κ³μ΄ μν
010001
C#
.NET
010010
Kotlin
JVM
010011
Scala
JVM+ν¨μν
010100
Swift
Apple
010101
Dart
Flutter
010110
Groovy
JVM
010111
Clojure
JVM+Lisp
μ€ν¬λ¦½νΈ/λμ (10xxxx)
μ½λ
μΈμ΄
μ€λͺ
100000
Python
λ²μ© μ€ν¬λ¦½νΈ μν
100001
JavaScript
μΉ
100010
TypeScript
JS+νμ
100011
Ruby
λ²μ©
100100
PHP
μΉ μλ²
100101
Lua
μλ² λλ
100110
Perl
ν
μ€νΈ μ²λ¦¬
100111
R
ν΅κ³
101000
Julia
κ³Όν κ³μ°
101001
MATLAB
μμΉ ν΄μ
μ μΈμ /ν¨μν/κΈ°ν (11xxxx)
μ½λ
μΈμ΄
μ€λͺ
110000
SQL
쿼리
110001
Haskell
μμ ν¨μν
110010
OCaml
ML κ³μ΄
110011
F#
.NET ν¨μν
110100
Elixir
BEAM
110101
Erlang
BEAM
110110
Shell
Bash/Zsh
110111
PowerShell
Windows
111000
WASM
λ°μ΄νΈμ½λ
111001
LLVM IR
μ€κ° νν
111010
HTML
λ§ν¬μ
111011
CSS
μ€νμΌ
111100
JSON
λ°μ΄ν°
111101
YAML
λ°μ΄ν°
111110
PathGEUL
GEUL κ·Έλν νμ μΈμ΄
111111
νμ₯ μλ
μΆκ° μΈμ΄ (3rd μλμ λͺ
μ)
μ°μν μ΄ν: λΉνΈ μμ€ μ μμ κ³ν΅μΌλ‘ μλ ΄ β μ΅μ’
μ μΌλ‘ Abstract(000000)λ‘ ν΄λ°±.
AST λ
Έλ νμ
(8λΉνΈ)
3λΉνΈ λλΆλ₯ + 5λΉνΈ μΈλΆνμ
μΌλ‘ λΆν .
μ½λ
λλΆλ₯
μ€λͺ
000
Declaration
μ μΈ (ν¨μ, λ³μ, νμ
)
001
Statement
λ¬Έμ₯ (μ μ΄λ¬Έ, λ°λ³΅λ¬Έ)
010
Expression
ννμ (μ°μ°, νΈμΆ)
011
Type
νμ
νν
100
Pattern
ν¨ν΄ λ§€μΉ
101
Modifier
μμμ΄ (μ κ·Όμ μ΄, async)
110
Structure
ꡬ쑰 (λΈλ‘, λͺ¨λ)
111
Language-specific
μΈμ΄ κ³ μ λ
Έλ
μ½λ
λ
Έλ
Go
Python
C
000 00000
FuncDecl
FuncDecl
FunctionDef
FunctionDecl
000 00001
VarDecl
GenDecl(var)
Assign
VarDecl
000 00010
ConstDecl
GenDecl(const)
-
VarDecl(const)
000 00011
TypeDecl
TypeSpec
-
TypedefDecl
000 00100
StructDecl
StructType
ClassDef
RecordDecl
000 00101
InterfaceDecl
InterfaceType
ClassDef(ABC)
-
000 00110
EnumDecl
-
Enum
EnumDecl
000 00111
ParamDecl
Field
arg
ParmVarDecl
000 01000
MethodDecl
FuncDecl(recv)
FunctionDef
CXXMethodDecl
000 01001
ImportDecl
ImportSpec
Import
#include
000 01010
PackageDecl
package
-
-
000 01011
FieldDecl
Field
-
FieldDecl
000 01100
LabelDecl
LabeledStmt
-
LabelDecl
μ½λ
λ
Έλ
μλ―Έ
001 00000
IfStmt
쑰건문
001 00001
ForStmt
for 루ν
001 00010
RangeStmt
μ΄ν°λ μ΄ν° 루ν
001 00011
WhileStmt
while 루ν
001 00100
SwitchStmt
switch/match
001 00101
CaseClause
case μ
001 00110
ReturnStmt
λ°ν
001 00111
BreakStmt
νμΆ
001 01000
ContinueStmt
κ³μ
001 01001
GotoStmt
goto
001 01010
BlockStmt
λΈλ‘ { }
001 01011
ExprStmt
ννμ λ¬Έμ₯
001 01100
AssignStmt
λμ
001 01101
DeclStmt
μ μΈ λ¬Έμ₯
001 01110
TryStmt
μμΈ μ²λ¦¬
001 01111
ThrowStmt
μμΈ λ°μ
001 10000
DeferStmt
defer
001 10001
GoStmt
go
001 10010
SelectStmt
select
001 10011
WithStmt
with
001 10100
AssertStmt
assert
001 10101
PassStmt
pass
μ½λ
λ
Έλ
μλ―Έ
010 00000
BinaryExpr
μ΄ν μ°μ°
010 00001
UnaryExpr
λ¨ν μ°μ°
010 00010
CallExpr
ν¨μ νΈμΆ
010 00011
IndexExpr
μΈλ±μ€ μ κ·Ό a[i]
010 00100
SliceExpr
μ¬λΌμ΄μ€ a[i:j]
010 00101
SelectorExpr
νλ μ κ·Ό a.b
010 00110
Ident
μλ³μ
010 00111
BasicLit
κΈ°λ³Έ 리ν°λ΄
010 01000
CompositeLit
λ³΅ν© λ¦¬ν°λ΄
010 01001
FuncLit
λλ€/μ΅λͺ
ν¨μ
010 01010
ParenExpr
κ΄νΈ (a)
010 01011
StarExpr
ν¬μΈν° *a
010 01100
UnaryAddr
μ£Όμ &a
010 01101
TypeAssertExpr
νμ
λ¨μΈ
010 01110
KeyValueExpr
key: value
010 01111
TernaryExpr
μΌν μ°μ°
010 10000
ListComp
리μ€νΈ μ»΄ν리ν¨μ
010 10001
DictComp
λνΈ μ»΄ν리ν¨μ
010 10010
GeneratorExpr
μ λλ μ΄ν°
010 10011
AwaitExpr
await
010 10100
YieldExpr
yield
010 10101
SendExpr
μ±λ μ‘μ <-
010 10110
RecvExpr
μ±λ μμ <-ch
μ½λ
λ
Έλ
μλ―Έ
011 00000
IdentType
μ΄λ¦ νμ
011 00001
PointerType
ν¬μΈν° *T
011 00010
ArrayType
λ°°μ΄ [N]T
011 00011
SliceType
μ¬λΌμ΄μ€ []T
011 00100
MapType
λ§΅ map[K]V
011 00101
ChanType
μ±λ chan T
011 00110
FuncType
ν¨μ νμ
011 00111
StructType
ꡬ쑰체 νμ
011 01000
InterfaceType
μΈν°νμ΄μ€ νμ
011 01001
UnionType
μ λμ¨ A | B
011 01010
OptionalType
μ΅μ
λ T?
011 01011
GenericType
μ λ€λ¦ T[U]
011 01100
TupleType
νν (A, B)
μ½λ
λ
Έλ
μλ―Έ
100 00000
WildcardPattern
_
100 00001
IdentPattern
μ΄λ¦ λ°μΈλ©
100 00010
LiteralPattern
리ν°λ΄ λ§€μΉ
100 00011
TuplePattern
νν (a, b)
100 00100
ListPattern
리μ€νΈ [a, b]
100 00101
StructPattern
ꡬ쑰체 {a, b}
100 00110
OrPattern
a | b
100 00111
GuardPattern
κ°λ 쑰건
μ½λ
λ
Έλ
μλ―Έ
101 00000
Public
public/exported
101 00001
Private
private
101 00010
Protected
protected
101 00011
Static
static
101 00100
Const
const
101 00101
Async
async
101 00110
Volatile
volatile
101 00111
Inline
inline
101 01000
Virtual
virtual
101 01001
Abstract
abstract
101 01010
Final
final
μ½λ
λ
Έλ
μλ―Έ
110 00000
File
νμΌ (μ΅μμ)
110 00001
Module
λͺ¨λ
110 00010
Package
ν¨ν€μ§
110 00011
Namespace
λ€μμ€νμ΄μ€
110 00100
Block
λΈλ‘
110 00101
CommentGroup
μ£Όμ κ·Έλ£Ή
110 00110
Comment
μ£Όμ
110 00111
Directive
μ§μμ΄ (#pragma)
Language-specific (111xxxxx)
κ° μΈμ΄ κ³ μ λ
Έλ. 32κ° μ¬μ .
PathGEULμ GEUL κ·Έλνλ₯Ό νμνλ 쿼리 μΈμ΄λ€. XPathκ° XMLμ νμνλ―, PathGEULμ GEUL κ·Έλνλ₯Ό νμνλ€.
μΈμ΄ μ½λ 111110μΌ λ, 8λΉνΈ AST λ
Έλ νμ
μ 쿼리 μ°μ°μ λ‘ μ¬ν΄μλλ€.
μ½λ
μ°μ°
XPath λμ
μ€λͺ
00000000
Root
/
λ£¨νΈ λ
Έλ
00000001
Child
/child
μ§μ μμ
00000010
Descendant
//
λͺ¨λ νμ
00000011
Parent
..
λΆλͺ¨
00000100
Ancestor
ancestor::
λͺ¨λ μ‘°μ
00000101
Sibling
sibling::
νμ
00010000
FilterType
[type=...]
νμ
νν°
00100000
FilterProp
[@prop=...]
μμ± νν°
01000000
Union
|
ν©μ§ν©
01000001
Intersect
&
κ΅μ§ν©
func Add (a , b int ) int {
return a + b
}
AST Edge (FuncDecl):
1st: [1100 000 000] [000100] - Prefix + Go
2nd: [000 00000] [00000000] - FuncDecl + μμ½
3rd: [TID: 0x0010] - μ΄ Edge TID
4th: [TID: 0x0011] - Name "Add"
5th: [TID: 0x0012] - Params
6th: [TID: 0x0013] - Results
7th: [TID: 0x0014] - Body
8th: [0x0000] - μ’
κ²°
μ΄: 8μλ
def greet (name : str ) -> str :
return f"Hello, { name } "
AST Edge (FuncDecl):
1st: [1100 000 000] [100000] - Prefix + Python
2nd: [000 00000] [00000000] - FuncDecl + μμ½
3rd: [TID: 0x0020] - μ΄ Edge TID
4th: [TID: 0x0021] - Name "greet"
5th: [TID: 0x0022] - Params
6th: [TID: 0x0023] - Returns
7th: [TID: 0x0024] - Body
8th: [0x0000] - μ’
κ²°
μ΄: 8μλ
리ν λ
Έλ (μλ³μ)
AST Edge (Ident):
1st: [1100 000 000] [000100] - Prefix + Go
2nd: [010 00110] [00000000] - Ident + μμ½
3rd: [TID: 0x0030] - μ΄ Edge TID
4th: [0x0000] - μ’
κ²° (μμ μμ)
μ΄: 4μλ
GEUL μνκ³ λ΄ μμΉ
GEUL Edge 체κ³:
μ§μ/κ°μ²΄:
βββ Entity Node (κ°μ²΄ μ μΈ)
βββ Triple Edge (μμ±/κ΄κ³)
μμ /μ¬κ±΄:
βββ Verb Edge (μμ )
βββ Event6 Edge (6νμμΉ μ¬κ±΄)
λ
Όλ¦¬/λ΄ν:
βββ Clause Edge (μ κ΄κ³)
μλ:
βββ Quantity Node (물리λ/μμΉ)
λ§₯λ½:
βββ Context Edge (μΆμ²/μ λ’°λ)
μ½λ/νμ:
βββ AST Edge (AST νν)
βββ PathGEUL (κ·Έλν νμ)
λ ν¬
κ΄κ³
geul
λ¬Έλ² λͺ
μΈ + SIDX ν‘λ¨ λ¬Έμ
geul-entity
Entity SIDX 48λΉνΈ μ½λλΆ
geul-verb
λμ¬ SIDX 16λΉνΈ μ½λλΆ