yui0 / catc

a simple tiny C Compiler using Lex & Yacc

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

catc

This is a simple tiny C Compiler using Lex & Yacc.

Usage

$ dnf install byacc flex
$ make
$ ./catc -S ./test/hello.c
	.section	.rodata
.LC0:
	.string	"Hello! tiny c world!!\n"
	.text
	.align	4
	.global	main
	.type	main,@function
main:
	pushl	%ebp
	movl	%esp,%ebp
	subl	$24,%esp
	movl	%ebx,-4(%ebp)
	lea	.LC0,%eax
	pushl	%eax
	call	printf
	movl	$0,%eax
	jmp	.L1
.L1:	movl	-4(%ebp),%ebx
	leave
	ret
$ ./catc -S ./test/hello.c > ./test/hello.asm
$ as ./test/hello.asm -o ./test/hello.o
$ gcc ./test/hello.o -o ./test/hello
$ ./test/hello
Hello! tiny c world!!
$ ./catc ./test/test01.c
$ ./test/test01
Hello world.
100+23=123

Refrence

About

a simple tiny C Compiler using Lex & Yacc


Languages

Language:C 51.3%Language:Yacc 34.2%Language:Lex 10.6%Language:C++ 2.6%Language:Makefile 1.0%Language:Shell 0.4%