Curated from: medium.com
Ideas, facts & insights covering these topics:
11 ideas
·840 reads
3
Explore the World's Best Ideas
Join today and uncover 100+ curated journeys from 50+ topics. Unlock access to our mobile app with extensive features.
There are two major types of languages: compiled and interpreted:
15
128 reads
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.
13
170 reads
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.
14
132 reads
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.
14
104 reads
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.
13
67 reads
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.
13
46 reads
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.
13
38 reads
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.
13
38 reads
13
34 reads
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.
13
31 reads
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.
13
52 reads
IDEAS CURATED BY
Learn more about computerscience with this collection
Understanding machine learning models
Improving data analysis and decision-making
How Google uses logic in machine learning
Related collections
Similar ideas
5 ideas
Top 7 Programming Languages for Fintech and Finance in 2021
analyticsinsight.net
7 ideas
Learn these 5 Highest-Paying Programming Languages to Get a Hike
analyticsinsight.net
10 ideas
Read & Learn
20x Faster
without
deepstash
with
deepstash
with
deepstash
Personalized microlearning
—
100+ Learning Journeys
—
Access to 200,000+ ideas
—
Access to the mobile app
—
Unlimited idea saving
—
—
Unlimited history
—
—
Unlimited listening to ideas
—
—
Downloading & offline access
—
—
Supercharge your mind with one idea per day
Enter your email and spend 1 minute every day to learn something new.
I agree to receive email updates