Lets make a Programming Language! | Create Programming Language #2

preview_player
Показать описание


INSTALL FLEX & BISON

SYNTAX HIGHLIGHT FOR SUBLIME TEXT

NOTES

In this video, we are going to create our own little compiler to validate the declaration and initialization section of a C program. We’ll use 2 language tools: Lex and Yacc (or flex and bison) to accomplish this.

In this video, we are going to
1. install flex and bison
2. install syntax highlighting for flex and bison in sublime
3. Explain the code files
4. and run this output on a sample file.

The lex file has 3 main parts, separated by “double percentage signs”:
The first part is a list of harder files and function definitions encapsulated in “percentage-curly braces”. The second part has the list of acceptable tokens and the final is for some C user defined functions.

Like the lex file, yacc file also consists of 3 sections. The first part is a list of harder files and function definitions encapsulated in “percentage-curly braces”. In between the first and second sections, we define the nature of the error message generated by YACC. The second section has the Context free Grammar and the 3rd has User defined functions.

Langfunctions.h :
Data_Type : character array that holds the data_type for the current declaration statement.
noOfIdentifiers : number of identifiers in the input file.

clearBuffers() : to clear the value of the datatype stored.
storeDataType() : to store the datatype of the current declaration statement.
retrieveDataType(): Created to make things look uniform.
isDuplicate() : checks if the newly encountered identifier has already been declared before.
extractIdentifier() : extracts the name of the array.
storeIdentifier() : add the encountered identifier to the list of identifiers.
AssignmentError() is called in case an invalid assignment is made
DuplicateIdentifierError() is called if the isDuplicate() function returns True in the yacc file.

validators.h :
isValidAssignment() : checks if the datatype which we pass in from the later part of the yacc file is the same as the current datatype of the identifier.

itoa, ftoa and ctoa are used to convert integers, floating point numbers and characters into ascii type.

Run the Program:
To execute this code, Go to your terminal, enter your working directory and type 4 commands.

$ yacc -d syntax2.y
$ lex semantics.l
$ ./output [angle bracket] sample

Now that we have the brains of the program setup, I’m gonna try to create a cool GUI in the next video so that it'll actually look like an application. Keep an eye out for that video.

If you are new to the channel hit that subscribe button on your way out. Lets see if we can get 10 likes on this video (cmon!!!). PLEEEESSSSEEE. I’ll be a happy dude.
:)
Рекомендации по теме
Комментарии
Автор

I reached my goal of 10 likes for this video. It was a long journey, but I finally got there. Thanks for watching guys. Couldn't have done it without you!

CodeEmporium
Автор

I didn't quite get how this helps you make a NEW language as it seems that you created a language that you already know.

id
Автор

this is great !:) keep up the good work

tajrinkashem
Автор

how one can create a programming language without using a priorly established programming language to built the new programming language

kentheengineer
Автор

About 5 minutes in and I'm a bit confused. Did I miss like 10 steps?
How did we get from "I'll teach you how to install Flex and syntax highlighting" to "Here's a set of completed files"?

I downloaded Flex and managed to get the syntax highlighting to work on Windows (it's a lot more manual than on Mac), then checked back to the video, pressed Play and all of a sudden you had completed files there. Where did those come from?

morphman
Автор

learn about the variety of archectures that are available to circuit designers and google digital and read 1. and google signal definition

kentheengineer
Автор

How do I clone the git hub code on windows

NotWumpus
Автор

your designing the circuit for electricity which using polarization and magnetics to guide electrons through the circuits that are built from conductive material you can learn more about the material by researching material science, your welcome

kentheengineer
welcome to shbcf.ru