Setting Up
September 20, 2024
I still can't narrow down what I want my programming language to do/why it is unique but I figured starting is better than stalling because of a lack of idea. I can always change things later but for right now I am going to be making a standard functional language. I have also decided to make an interpretted language to start with and if I feel up for it make it compilable since both require a lexer and a parser regardless.
I am writing my language in C. This was the first language I learned and where I learned a lot of fundamentals. Today, I downloaded GCC. I also went over how C takes source code and actually runs it. C takes the source code and runs it through a preprocessor (which outputs an ".i" file), then through a compiler (outputs a ".s" file which is assembly), then through an assembler (outputs an object file ".o"), and finally uses a linker to produce an executable. The generalized process is source code -> assembly -> machine code.
Now I'm following along this YouTube video which first prompts me to make a Makefile. I remember how hard it was for me to grasp what a Makefile does when I was in my first year at uni. I couldn't grasp the concept of having to tell the computer how to run code since I didn't understand how a computer turned code into action. Some notes about Makefiles:
- if you run 'make' with no arguments then it runs the first rule in the file
- $@ = name of the target being generated (in my makefile it would be pnat.out)
- $< = first prerequisite (usually a source file or in my makefile it would be main.c)
I ran into an issue that was printing
cc -c -o main.o main.cprocess_begin: CreateProcess(NULL, cc -c -o main.o main.c, ...) failed.
make (e=2): The system cannot find the file specified.
make: *** [<builtin>: main.o] Error 2
This was fixed with adding a variable CC = gcc to run the commands. I have to look up why this would break the script in the first place as I don't really understand why it wasn't running that without storing it in a variable? The tutorial had a set of instructions of installing the program but it was written in unix commands to add the executable to the bin folder but in Windows when I tried to replace with
runas /user:Administrator "setx /M path \"%path%;.\pnat.exe\""it asked me for a password which I just don't have so I just manually added the language to the path. I don't think I'll need a Makefile for this project but we'll see at the end of the project if it would help with distribution/installation. Although, I haven't decided what the purpose of this project will be other than simply learning about how languages are created.