![[personal profile]](https://www.dreamwidth.org/img/silk/identity/user.png)
Парсер теперь можно вызывать из командной строки. Фактически это первый проход будущего компилятора. Сейчас он умеет выгружать синтаксическое дерево AST в форматах YAML или Grapviz DOT.
Соберём:

Соберём:
Возьмём классический Hello World и перепрём в YAML:$ git clone https://github.com/besm6/c-compiler.git $ cd c-compiler $ make $ cd build $ ./cast Usage: cast [options] input-filename [output-filename] Options: --ast Emit AST in binary format (default) --yaml Emit YAML format --dot Emit Graphviz DOT script -v, --verbose Enable verbose mode -D, --debug Print debug information -h, --help Show this help message
Нарисуем картинку:$ cat hello.c int main() { printf("Hello, World!\n"); } $ ./cast --yaml hello.c - program: - external_decl: kind: function type: kind: function return_type: kind: int signedness: signed variadic: false name: main body: kind: compound body: - stmt: kind: expr expr: - expr: kind: call func: - expr: kind: var name: printf args: - expr: kind: literal kind: string value: "Hello, World!\n"
Смотрим hello.pdf:$ ./cast --dot hello.c hello.dot $ dot hello.dot -Tpdf -ohello.pdf

no subject
Date: 2025-05-21 10:01 (UTC)no subject
Date: 2025-05-21 10:10 (UTC)