Bison - Deepstash

Bison

The predominant parsing library is Bison. Bison works a lot like Flex. You write a file in a custom format that stores the grammar information, then Bison uses that to generate a C program that will do your parsing. I did not choose to use Bison. 

6 STASHED

1 LIKE

MORE IDEAS FROM THEARTICLE

If you are writing an interpreted language, it makes a lot of sense to write it in a compiled one (like C, C++ or swift).

 If you plan to compile, a slower language (like python or Javascript) is more acceptable.

6 STASHED

1 LIKE

Put simply, the action tree is the AST with context. That context is info such as what type a function returns, or that two places in which a variable is used are in fact using the same variable. 

Because it needs to figure out and remember all this context, the code that generates the action tree needs lots of namespace lookup tables and other thingamabobs. 

6 STASHED

1 LIKE

A programming language is generally structured as a pipeline. That is, it has several stages. 

Each stage has data formatted in a specific, well defined way. It also has functions to transform data from each stage to the next. 

6 STASHED

1 LIKE

  • Minimize context switching in workflow: context switching between C++ and Pinecone is bad enough without throwing in Bison’s grammar grammar
  • Every time grammar changes bison has to be run before the build.
  • A custom Parser is completely doable.

6 STASHED

1 LIKE

Compiled vs Interpreted

There are two major types of languages: compiled and interpreted: 

  • A compiler figures out everything a program will do, turns it into “machine code”, then saves that to be executed later. 
  • An interpreter steps through the source code line by line, figuring out what it’s doing as it goes.  

6 STASHED

1 LIKE

Once we have the action tree, running the code is easy. Each action node has a function ‘execute’ which takes some input, does whatever the action should (including possibly calling sub action) and returns the action’s output. This is the interpreter in action. 

6 STASHED

1 LIKE

The parser adds structure to to the ordered list of tokens the lexer produces. To stop ambiguities, the parser must take into account parenthesis and the order of operations. 

Simply parsing operators isn’t terribly difficult, but as more language constructs get added, parsing can become very complex. 

6 STASHED

1 LIKE

The parser turns a list of tokens into a tree of nodes. A tree used for storing this type of data is known as an Abstract Syntax Tree, or AST. 

At least in Pinecone, the AST does not have any info about types or which identifiers are which. It is simply structured tokens. 

6 STASHED

1 LIKE

A token is a small unit of a language

A token might be a variable or function name (AKA an identifier), an operator or a number. 

6 STASHED

1 LIKE

The first step in most programming languages is lexing, or tokenizing. ‘Lex’ is short for lexical analysis, a very fancy word for splitting a bunch of text into tokens. 

The word ‘tokenizer’ makes a lot more sense, but ‘lexer’ is so much fun to say that I use it anyway. 

6 STASHED

1 LIKE

Deepstash helps you become inspired, wiser and productive, through bite-sized ideas from the best articles, books and videos out there.

GET THE APP:

RELATED IDEAS

High Paying Computer Languages.

Software developers choose the highest-paying programming languages to set an extraordinary career.

16 STASHED

4 LIKES

Why learn python

Python is a huge deal as a programming language in 2021. From automation scripts to Artificial Intelligence, Python supports everything. I am sure, even if you are a newbie in the programming world, you have heard of Python. If you do not know Python, do not feel disappointed. There are many great articles and blogs that will tell you about the popularity of Python. In this article, I will try to convince you, why you should learn Python. Take it easy, it is up to you, whether you want to start with Python or not. You will not regret learning Python.

When you are learning a new programming language, syntax becomes a huge deal. If syntax does not make sense, the main idea does not click. For example, when I was learning C in high school, the printf() function did not make sense. I knew that print means that we are showing something on the screen but what is the point of f ?

The great thing about Python is that the syntax makes sense. It is simple and not hard to learn. If you are thinking of teaching programming to 10-year-olds then Python is a great tool. If you are someone who does not want to dive too deep in programming, Python is still a good option. You can learn the fundamentals of programming by learning Python.

If you are convinced on learning Python then, first of all, Congratulations for thinking about doing something new. It's always fun to learn something new as a developer.

A book is always a good option when you want to learn something. As your well-wisher, I have compiled a list of Best Python Books that you can get a head start from. You can check out the article, it is easy to go through.

You will find books that will help you as a complete beginner. A book that will teach you the automation and all of the advance stuff. If you are interested in web development, I have a book for that.

I hope you have a good journey in learning Python. Thank you for reading the article to the end. Cheers!!!

8 STASHED

7 LIKES

Mathematics: The Language Of Science
  • According to Galileo Galilei, mathematics is the language in which God scripted the universe.
  • A language, as defined by linguist Noam Chomsky, is a set of sentences constructed using a finite set of elements, being able to represent events and abstract concepts.
  • Mathematics is considered a bona-fide language by many linguists though there are others who disagree and say that it is mostly in written format only.

163 STASHED

13 LIKES