Programming Langauages
Programming Langauages
Unit 1
General overview and history
Compilation and interpretation
https://stackoverflow.com/questions/3265357/compiled-vs-interpreted-languages
The process of translating the entire source code of a program into machine code (binary
executable) before execution.
https://courses.cs.washington.edu/courses/cse390b/22wi/readings/
compiler_scanner_parser.html
A scanner is a program that takes a sequence of characters (the source file of the program)
and produces a sequence of tokens that will be used to feed the compiler's parser.
A Scanner simply turns an input String (say a file) into a list of tokens. These tokens
represent things like identifiers, parentheses, operators etc.
A parser converts this list of tokens into a Tree-like object to represent how the tokens fit
together to form a cohesive whole (sometimes referred to as a sentence).
A parser does not give the nodes any meaning beyond structural cohesion. The next
thing to do is extract meaning from this structure (sometimes called contextual analysis).
Parsing (in a general sense) is about turning the symbols (characters, digits, left parens,
etc) into sentences of your grammar.
The lexical analyzer (the "lexer") parses individual symbols from the source code file into
tokens. From there, the "parser" proper turns those whole tokens into sentences of your
grammar.
Put another way, the lexer combines symbols into tokens, and the parser combines
tokens to form sentences.
Compilation involves several stages, each handling different aspects of translating the
source code into a form that can be executed by the machine. The main stages are:
1. Lexical Analysis (Scanning): The source code is converted into tokens, which
are the smallest units of meaningful text.
2. Syntax Analysis (Parsing): The sequence of tokens is analyzed against the
grammar of the language to form a parse tree, which represents the syntactic
structure of the program.
3. Semantic Analysis: Checks for semantic errors (like type mismatches) and
performs variable declarations and type-checking.
4. Optimization: The intermediate code is optimized for performance.
5. Code Generation: The optimized intermediate representation is translated into
machine code.
6. Code Linking: The compiled code is linked with other libraries or modules to
produce an executable.
These notes provide a foundational understanding of various data type concepts, crucial for
designing and implementing programs across different programming languages.
Unit 8: Concurrency
Terminology Issues
Thread creation
Synchronisation