@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
@kangax created a new interesting quiz, this time devoted to ES6 (aka ES2015). I found this quiz very interesting and quite hard (made myself 3 mistakes on first pass).
Here we go with the explanations:
(function(x, f = () => x) {
/** | |
* Shunting yard algorithm | |
* See: http://en.wikipedia.org/wiki/Shunting_yard_algorithm | |
* | |
* Converts infix notation to postfix notation | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style License | |
* | |
* (C) 2011, updated on 2020 |
# -------- | |
# Hardware | |
# -------- | |
# Opcode - operational code | |
# Assebly mnemonic - abbreviation for an operation | |
# Instruction Code Format (IA-32) | |
# - Optional instruction prefix | |
# - Operational code |
<!DOCTYPE html> | |
<html> | |
<head> | |
<title>Sierpiński triangle</title> | |
</head> | |
<body> | |
<canvas id="area" width="600" height="600"></canvas> | |
<script type="text/javascript"> | |
// Sierpiński_triangle: |
/** | |
* Event loop. | |
* | |
* Read details here: | |
* http://dmitrysoshnikov.com/ecmascript/javascript-the-core-2nd-edition/#job | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
*/ | |
/** |
/** | |
* Educational "Free-list" memory allocator. | |
* | |
* Maintains explicit list of free memory blocks, reuses blocks on free. | |
* Implements "first-fit" strategy. Uses pre-allocated heap of 64 bytes, | |
* with 32-bit machine word size. | |
* | |
* TODO: | |
* | |
* - Implement "best-fit" strategy |
A full parsing table is not needed, only the canonical collection. In the canonical collection, find all final items (and only final items), and see if:
If none of these is true, there are no conflicts, even in LR(0). If there are some of the above, SLR(1) still may solve it.
/** | |
* Educational Stack-based VM. | |
* | |
* See also: | |
* - More complex example with recursion: https://gist.github.com/DmitrySoshnikov/afda459222e96e6002ac | |
* - Register-based VM example: https://gist.github.com/DmitrySoshnikov/6407781 | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* http://dmitrysoshnikov.com | |
* MIT Stye License (C) 2015 |
/** | |
* LL(1) parser. Building parsing table, part 1: First and Follow sets. | |
* | |
* NOTICE: see full implementation in the Syntax tool, here: | |
* https://github.com/DmitrySoshnikov/syntax/blob/master/src/sets-generator.js | |
* | |
* by Dmitry Soshnikov <dmitry.soshnikov@gmail.com> | |
* MIT Style License | |
* | |
* An LL(1)-parser is a top-down, fast predictive non-recursive parser, |