Hacking Ruby
It’s limited in it’s simplicity by the inherent complexity of it’s aim.
A parser turns a list of tokens into an Abstract Syntax Tree (AST).
For example: If we wanted to evaluate: avg = (min + max) / 2
We know the order of the operations is something like this: Let’s use a tree to describe it (insert tree diagram here)
We need to evaluate the subtrees first, and work our way up from the leaves to the root - a post order traversal.
The grammatical structure of the language. We move one level up the Chomsky hierarchy.
Turning characters into tokens –> Regular language. We need a bigger hammer -> Context free Grammar (CFG).
Can’t write down an infinite number of valid strings. Instead, we create a finite set of rules.
A subset of the language. A handful of expressions.
Here’s our grammar for those:
expression -> literal | unary | binary | grouping;
literal -> NUMBER | STRING | "true" | "false" | "nil";
unary -> ( "-" | "!" ) expression;
binary -> expression operator expression;
operator -> "==" | "!=" | "<" | "<=" | ">" | ">=" | "+" | "-" | "*" | "/";
grouping -> "(" expression ")";
Remove ambiguity:
expression -> equality ;
equality -> comparison ( ("!=" | "==") comparison)* ;
comparison -> term ( (">" | ">=" | "<" | "<=") term)* ;
term -> factor ( ("-" | "+") factor)* ;
factor -> unary ( ("/" | "*") unary)* ;
unary -> ("!" | "-" ) unary | primary;
primary -> NUMBER | STRING | "true" | "false" | "nil" | "(" expression ")" ;
It’s limited in it’s simplicity by the inherent complexity of it’s aim.
C is the foundational language of Computer Science.
Deleting all files with a certain pattern in the filename rm *.c # This deletes all the .c files
Cpython is the official implementation of Python. It is written in C (hence the name).
The goal is to gain a better understanding of computer systems and become a better hacker.
The x86 architecture is the most popular architecture for desktop and laptop computers.
Getting started with Jekyll First install bundler and jekyll. gem install jekyll bundler
Lisp is the greatest single programming language ever designed - Alan Kay
You go onto your computer, open a browser and type www.google.com and hit enter. What happens?
This is a collection of links to some of the interesting articles I found on the internet
A parser turns a list of tokens into an Abstract Syntax Tree (AST).