Slide 1

Slide 1 text

GET TO THE CHOPVAR @mattdsteele

Slide 2

Slide 2 text

No content

Slide 3

Slide 3 text

ArnoldC

Slide 4

Slide 4 text

ArnoldC +

Slide 5

Slide 5 text

ArnoldC + JavaScript

Slide 6

Slide 6 text

No content

Slide 7

Slide 7 text

@lhartikk

Slide 8

Slide 8 text

IT'S SHOWTIME TALK TO THE HAND "hello world" YOU HAVE BEEN TERMINATED Hello World

Slide 9

Slide 9 text

HEY CHRISTMAS TREE foo YOU SET US UP 0 HEY CHRISTMAS TREE bar YOU SET US UP 1 foo = 0 bar = 1

Slide 10

Slide 10 text

HEY CHRISTMAS TREE foo YOU SET US UP @I LIED HEY CHRISTMAS TREE bar YOU SET US UP @NO PROBLEMO foo = false bar = true

Slide 11

Slide 11 text

a = (4 + b) * 2 GET TO THE CHOPPER a HERE IS MY INVITATION 4 GET UP b YOU'RE FIRED 2 ENOUGH TALK

Slide 12

Slide 12 text

GET UP GET DOWN YOU'RE FIRED HE HAD TO SPLIT I LET HIM GO + - * / %

Slide 13

Slide 13 text

BECAUSE I'M GOING TO SAY PLEASE value [statements] YOU HAVE NO RESPECT FOR LOGIC Conditionals

Slide 14

Slide 14 text

BECAUSE I'M GOING TO SAY PLEASE value [statements] BULLSHIT [statements] YOU HAVE NO RESPECT FOR LOGIC Conditionals

Slide 15

Slide 15 text

LISTEN TO ME VERY CAREFULLY fn TALK TO THE HAND "inside a function" HASTA LA VISTA, BABY DO IT NOW fn Functions

Slide 16

Slide 16 text

LISTEN TO ME VERY CAREFULLY addFive I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE num GET TO THE CHOPPER sum HERE IS MY INVITATION num GET UP 5 ENOUGH TALK TALK TO THE HAND sum HASTA LA VISTA, BABY DO IT NOW addFive 8

Slide 17

Slide 17 text

LISTEN TO ME VERY CAREFULLY addFive I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE num GIVE THESE PEOPLE AIR GET TO THE CHOPPER sum HERE IS MY INVITATION sum GET UP 5 ENOUGH TALK I'll BE BACK sum HASTA LA VISTA, BABY GET YOUR ASS TO MARS result DO IT NOW addFive 8 TALK TO THE HAND result

Slide 18

Slide 18 text

STICK AROUND value [statements] CHILL While Loops

Slide 19

Slide 19 text

No content

Slide 20

Slide 20 text

Classes

Slide 21

Slide 21 text

Classes Modules

Slide 22

Slide 22 text

Classes Modules Decimals

Slide 23

Slide 23 text

Classes Modules Decimals Strings

Slide 24

Slide 24 text

No content

Slide 25

Slide 25 text

No content

Slide 26

Slide 26 text

No content

Slide 27

Slide 27 text

No content

Slide 28

Slide 28 text

No content

Slide 29

Slide 29 text

No content

Slide 30

Slide 30 text

No content

Slide 31

Slide 31 text

Compilers

Slide 32

Slide 32 text

#include int main() { printf("Hello World\n"); return 0; }

Slide 33

Slide 33 text

#include int main() { printf("Hello World\n"); return 0; } GCC

Slide 34

Slide 34 text

#include int main() { printf("Hello World\n"); return 0; } .section __TEXT,__text,regular,pure_instructions .macosx_version_min 10, 10 .globl _main .align 4, 0x90 _main: ## @main .cfi_startproc ## BB#0: pushq %rbp Ltmp0: .cfi_def_cfa_offset 16 Ltmp1: .cfi_offset %rbp, -16 movq %rsp, %rbp Ltmp2: .cfi_def_cfa_register %rbp leaq L_str(%rip), %rdi callq _puts xorl %eax, %eax popq %rbp retq .cfi_endproc .section __TEXT,__cstring,cstring_literals L_str: ## @str .asciz "Hello World" .subsections_via_symbols GCC

Slide 35

Slide 35 text

math = root: Math.sqrt square: square cube: (x) -> x * square x

Slide 36

Slide 36 text

☕ math = root: Math.sqrt square: square cube: (x) -> x * square x

Slide 37

Slide 37 text

☕ math = root: Math.sqrt square: square cube: (x) -> x * square x math = { root: Math.sqrt, square: square, cube: function(x) { return x * square(x); } };

Slide 38

Slide 38 text

No content

Slide 39

Slide 39 text

http://chsi.harvard.edu/markone/

Slide 40

Slide 40 text

[ . ; +a ; E introducinga - new 'language: i forautomatic 2 c- programming 5 f J ! 2 - 1' F m G-'- i m m d - D I V I S I O N OF SPERRY RAND CORPORATION http://www.computerhistory.org/collections/catalog/102646140

Slide 41

Slide 41 text

UNIQUE SAVINGS f &he vm "FLOW-MATXC Virtually Eliminates Your Cading Load Your skilled programmers are freed from olerialstrudgery tcs do more creative work. FLOW-Mamc M t o smpbis'of the p r o g r m k g effort from detailed coding to problem definitionandsystem*amlysh,Slashesdrasticallythe time required to program new or aItered UNIVAC applications. Drastically Reduces Training Time In just a few days, users can be trained in the basic characteristics of the UNIVAC system and in the FLOW- MATIC method of ~roaamrnin~. - - With 0 FLOW-MATIC, it is not necessary to have a large staff of trained program- mers. The more complicated, time-con- suming training in techniques of com- puter coding need be taught only to those few people selected to become highly skilled career programmers.

Slide 42

Slide 42 text

UNIQUE SAVINGS f &he vm "FLOW-MATXC Virtually Eliminates Your Cading Load Your skilled programmers are freed from olerialstrudgery tcs do more creative work. FLOW-Mamc M t o smpbis'of the p r o g r m k g effort from detailed coding to problem definitionandsystem*amlysh,Slashesdrasticallythe time required to program new or aItered UNIVAC applications. Drastically Reduces Training Time In just a few days, users can be trained in the basic characteristics of the UNIVAC system and in the FLOW- MATIC method of ~roaamrnin~. - - With 0 FLOW-MATIC, it is not necessary to have a large staff of trained program- mers. The more complicated, time-con- suming training in techniques of com- puter coding need be taught only to those few people selected to become highly skilled career programmers. SAVINGS f &he vm W-MATXC Virtually Eliminates Your Cading Load Your skilled programmers are freed from olerialstrudgery tcs do more creative work. FLOW-Mamc M t o smpbis'of the p r o g r m k g effort from detailed coding to problem definitionandsystem*amlysh,Slashesdrasticallythe time required to program new or aItered UNIVAC applications.

Slide 43

Slide 43 text

UNIQUE SAVINGS f &he vm "FLOW-MATXC Virtually Eliminates Your Cading Load Your skilled programmers are freed from olerialstrudgery tcs do more creative work. FLOW-Mamc M t o smpbis'of the p r o g r m k g effort from detailed coding to problem definitionandsystem*amlysh,Slashesdrasticallythe time required to program new or aItered UNIVAC applications. Drastically Reduces Training Time In just a few days, users can be trained in the basic characteristics of the UNIVAC system and in the FLOW- MATIC method of ~roaamrnin~. - - With 0 FLOW-MATIC, it is not necessary to have a large staff of trained program- mers. The more complicated, time-con- suming training in techniques of com- puter coding need be taught only to those few people selected to become highly skilled career programmers.

Slide 44

Slide 44 text

UNIQUE SAVINGS f &he vm "FLOW-MATXC Virtually Eliminates Your Cading Load Your skilled programmers are freed from olerialstrudgery tcs do more creative work. FLOW-Mamc M t o smpbis'of the p r o g r m k g effort from detailed coding to problem definitionandsystem*amlysh,Slashesdrasticallythe time required to program new or aItered UNIVAC applications. Drastically Reduces Training Time In just a few days, users can be trained in the basic characteristics of the UNIVAC system and in the FLOW- MATIC method of ~roaamrnin~. - - With 0 FLOW-MATIC, it is not necessary to have a large staff of trained program- mers. The more complicated, time-con- suming training in techniques of com- puter coding need be taught only to those few people selected to become highly skilled career programmers. Drastically Reduces Training Time In just a few days, users can be trained in the basic characteristics of the UNIVAC system and in the FLOW- MATIC method of ~roaamrnin~. - - With 0 FLOW-MATIC, it is not necessary to have a large staff of trained program- mers. The more complicated, time-con- suming training in techniques of com- puter coding need be taught only to those few people selected to become highly skilled career programmers.

Slide 45

Slide 45 text

Compiler Construction

Slide 46

Slide 46 text

Lexer Parser Translate

Slide 47

Slide 47 text

Lexer Parser Translate

Slide 48

Slide 48 text

Lexical Analysis GET TO THE CHOPPER a HERE IS MY INVITATION 4 GET UP b YOU'RE FIRED 2 ENOUGH TALK

Slide 49

Slide 49 text

Lexical Analysis GET TO THE CHOPPER a HERE IS MY INVITATION 4 GET UP b YOU'RE FIRED 2 ENOUGH TALK

Slide 50

Slide 50 text

GET TO THE CHOPPER a HERE IS MY INVITATION 4 GET UP b YOU'RE FIRED 2 ENOUGH TALK KEYWORD_ASSIGN_VARIABLE VARIABLE KEYWORD_SET_VALUE INTEGER KEYWORD_PLUS_OPERATOR VARIABLE KEYWORD_MULTIPLICATION_OPERATOR INTEGER KEYWORD_END_ASSIGN_VARIABLE

Slide 51

Slide 51 text

Lexer Parser Translate

Slide 52

Slide 52 text

GET TO THE CHOPPER a HERE IS MY INVITATION 4 GET UP b YOU'RE FIRED 2 ENOUGH TALK

Slide 53

Slide 53 text

GET TO THE CHOPPER a HERE IS MY INVITATION 4 GET UP b YOU'RE FIRED 2

Slide 54

Slide 54 text

GET TO THE CHOPPER a 4 HERE IS MY INVITATION assignment operation GET UP b YOU'RE FIRED 2 initial value operation

Slide 55

Slide 55 text

VARIABLE INTEGER SET_VALUE assignment operation PLUS_ OPERATOR VARIABLE MULTIPLICATION_ OPERATOR INTEGER initial value operation ASSIGN_VARIABLE

Slide 56

Slide 56 text

VARIABLE INTEGER SET_VALUE assignment operation PLUS_ OPERATOR VARIABLE MULTIPLICATION_ OPERATOR INTEGER initial value operation Abstract Syntax Tree ASSIGN_VARIABLE

Slide 57

Slide 57 text

Lexer Parser Translate

Slide 58

Slide 58 text

ASSIGN_VARIABLE VARIABLE INTEGER SET_VALUE assignment operation PLUS_ OPERATOR VARIABLE MULTIPLICATION_ OPERATOR INTEGER initial value operation

Slide 59

Slide 59 text

var VARIABLE INTEGER = assignment operation + VARIABLE * INTEGER initial value operation

Slide 60

Slide 60 text

var VARIABLE = INTEGER VARIABLE = VARIABLE + VARIABLE VARIABLE = VARIABLE * INTEGER

Slide 61

Slide 61 text

var VARIABLE = INTEGER; VARIABLE = VARIABLE + VARIABLE; VARIABLE = VARIABLE * INTEGER;

Slide 62

Slide 62 text

var a = 4; a = a + b; a + a * 2;

Slide 63

Slide 63 text

var a = 4; a = a + b; a + a * 2; let a = ((4 + b) * 2);

Slide 64

Slide 64 text

Lexer Parser Translate

Slide 65

Slide 65 text

Lexer Parser Translate Tokenize Abstract Syntax Tree Generate Sources

Slide 66

Slide 66 text

Optimization Semantic Analysis

Slide 67

Slide 67 text

No content

Slide 68

Slide 68 text

coursera.org/course/compilers

Slide 69

Slide 69 text

coursera.org/course/compilers

Slide 70

Slide 70 text

Writing a Compiler

Slide 71

Slide 71 text

Flex & Bison

Slide 72

Slide 72 text

Bison

Slide 73

Slide 73 text

No content

Slide 74

Slide 74 text

No content

Slide 75

Slide 75 text

No content

Slide 76

Slide 76 text

No content

Slide 77

Slide 77 text

No content

Slide 78

Slide 78 text

@zaach

Slide 79

Slide 79 text

$ npm i jison

Slide 80

Slide 80 text

var fs = require("fs"); var jison = require("jison"); var bnf = fs.readFileSync("grammar.jison", "utf8"); var parser = new jison.Parser(bnf); var transpiled = parser.parse(input);

Slide 81

Slide 81 text

var fs = require("fs"); var jison = require("jison"); var bnf = fs.readFileSync("grammar.jison", "utf8"); var parser = new jison.Parser(bnf); var transpiled = parser.parse(input); "grammar.jison"

Slide 82

Slide 82 text

grammar.jison %lex /* lexical grammar */ %% /* Lexer */ /lex %% /* language grammar */ /* Parser / Translate */

Slide 83

Slide 83 text

Lexer "IF" return 'KEYWORD_IF'; "ELSE" return 'KEYWORD_ELSE'; "{" return 'LEFT_BRACE'; "}" return 'RIGHT_BRACE'; Token Name

Slide 84

Slide 84 text

Lexer [0-9]+("."[0-9]+)?\b return 'NUMBER'; [a-zA-Z0-9_]+ return 'VARIABLE'; Token Name

Slide 85

Slide 85 text

Lexer \s+ /* skip whitespace */ <> return 'EOF'; Token Name

Slide 86

Slide 86 text

%lex %% \s+ /* skip whitespaces */ "IT'S SHOWTIME" return 'BEGIN_MAIN' "YOU HAVE BEEN TERMINATED" return 'END_MAIN' \-?[0-9]+ return 'NUMBER' "TALK TO THE HAND" return 'PRINT' "@I LIED" return 'FALSE' "@NO PROBLEMO" return 'TRUE' "HEY CHRISTMAS TREE" return 'DECLARE_INT' "YOU SET US UP" return 'SET_INITIAL_VALUE' "GET TO THE CHOPPER" return 'BEGIN_ASSIGN' "ENOUGH TALK" return 'END_ASSIGN' "HERE IS MY INVITATION" return 'SET_VALUE' "GET UP" return 'PLUS' "GET DOWN" return 'MINUS' "YOU'RE FIRED" return 'MULTIPLY' "HE HAD TO SPLIT" return 'DIVIDE' "I LET HIM GO" return 'MODULO' "YOU ARE NOT YOU YOU ARE ME" return 'EQUAL' "LET OFF SOME STEAM BENNET" return 'GREATER' "CONSIDER THAT A DIVORCE" return 'OR' "KNOCK KNOCK" return 'AND'

Slide 87

Slide 87 text

Language Grammar %start program %% Expression : TOKEN TOKEN TOKEN TOKEN { CodeToExecute(); } ;

Slide 88

Slide 88 text

Expression : Expression PLUS Expression | Expression MINUS Expression | Expression TIMES Expression | Expression DIVIDE Expression | Expression EXP Expression | LEFT_PAREN Expression RIGHT_PAREN | NUMBER | E | PI ; Language Grammar

Slide 89

Slide 89 text

Translating to JavaScript Expression : Expression PLUS Expression { js code to execute } | Expression MINUS Expression { js code to execute } | Expression TIMES Expression { js code to execute } | Expression DIVIDE Expression { js code to execute } | LEFT_PAREN Expression RIGHT_PAREN { js code to execute }

Slide 90

Slide 90 text

Translating to JavaScript Expression : Expression PLUS Expression { $$ = $1 + $3; } | Expression MINUS Expression { $$ = new MinusOperator($1, $3); } | Expression TIMES Expression { $$ = new Operator($1, '*', $3); } | Expression DIVIDE Expression { $$ = new Operator($2, $1, $3); } | LEFT_PAREN Expression RIGHT_PAREN { $$ = $2; }

Slide 91

Slide 91 text

Translating to JavaScript Expression : Expression PLUS Expression { $$ = $1 + $3; } | Expression MINUS Expression { $$ = new MinusOperator($1, $3); } | Expression TIMES Expression { $$ = new Operator($1, '*', $3); } | Expression DIVIDE Expression { $$ = new Operator($2, $1, $3); } | LEFT_PAREN Expression RIGHT_PAREN { $$ = $2; }

Slide 92

Slide 92 text

Translating to JavaScript Expression : Expression PLUS Expression { $$ = $1 + $3; } | Expression MINUS Expression { $$ = new MinusOperator($1, $3); } | Expression TIMES Expression { $$ = new Operator($1, '*', $3); } | Expression DIVIDE Expression { $$ = new Operator($2, $1, $3); } | LEFT_PAREN Expression RIGHT_PAREN { $$ = $2; }

Slide 93

Slide 93 text

Translating to JavaScript Expression : Expression PLUS Expression { $$ = $1 + $3; } | Expression MINUS Expression { $$ = new MinusOperator($1, $3); } | Expression TIMES Expression { $$ = new Operator($1, '*', $3); } | Expression DIVIDE Expression { $$ = new Operator($2, $1, $3); } | LEFT_PAREN Expression RIGHT_PAREN { $$ = $2; }

Slide 94

Slide 94 text

Expression : Expression MINUS Expression { $$ = new yy.MinusOperator($1, $3); } ; bnf.jison

Slide 95

Slide 95 text

Expression : Expression MINUS Expression { $$ = new yy.MinusOperator($1, $3); } ; bnf.jison var yy = { MinusOperator: function(first, second) { return first + ' - ' + second; } }; module.exports = yy; ast.js

Slide 96

Slide 96 text

Expression : Expression MINUS Expression { $$ = new yy.MinusOperator($1, $3); } ; bnf.jison var yy = { MinusOperator: function(first, second) { return first + ' - ' + second; } }; module.exports = yy; ast.js var parser = new jison.Parser(bnf); parser.yy = require('./ast'); transpiler.js

Slide 97

Slide 97 text

No content

Slide 98

Slide 98 text

The Yacc parser uses only names beginning in ‘‘yy’’; the user should avoid such names.

Slide 99

Slide 99 text

program : methods BEGIN_MAIN statements END_MAIN methods EOF { return $1 .concat($5) .concat(new yy.MainExpression($3, @2, @4)); } ; statements : statements statement { $$ = $1.concat($2); } | { $$ = []; } ;

Slide 100

Slide 100 text

program : methods BEGIN_MAIN statements END_MAIN methods EOF { return $1 .concat($5) .concat(new yy.MainExpression($3, @2, @4)); } ; statements : statements statement { $$ = $1.concat($2); } | { $$ = []; } ;

Slide 101

Slide 101 text

program : methods BEGIN_MAIN statements END_MAIN methods EOF { return $1 .concat($5) .concat(new yy.MainExpression($3, @2, @4)); } ; statements : statements statement { $$ = $1.concat($2); } | { $$ = []; } ;

Slide 102

Slide 102 text

program : methods BEGIN_MAIN statements END_MAIN methods EOF { return $1 .concat($5) .concat(new yy.MainExpression($3, @2, @4)); } ; statements : statements statement { $$ = $1.concat($2); } | { $$ = []; } ;

Slide 103

Slide 103 text

statement : PRINT integer { $$ = new yy.PrintExpression(@1, $2); } | DECLARE_INT variable SET_INITIAL_VALUE integer { $$ = new yy.IntDeclarationExpression(@1, $2, $4); } | BEGIN_ASSIGN variable SET_VALUE integer END_ASSIGN { $$ = new yy.AssignmentExpression(@1, $2, $4, []);} | BEGIN_ASSIGN variable SET_VALUE integer ops END_ASSIGN { $$ = new yy.AssignmentExpression(@1, $2, $4, $5);} | IF integer statements END_IF { $$ = new yy.IfExpression(@1, $2, $3, [], @4); } | IF integer statements else statements END_IF { $$ = new yy.IfExpression(@1, $2, $3, $5, @6, $4); } | WHILE variable statements END_WHILE { $$ = new yy.WhileExpression(@1, $2, $3, @4); } | method_call { $$ = $1; } | ASSIGN_FROM_CALL variable method_call { $$ = new yy.AssignmentFromCallExpression(@1, $2, $3); } | RETURN integer { $$ = new yy.ReturnExpression(@1, $2); } ;

Slide 104

Slide 104 text

statement : PRINT integer { $$ = new yy.PrintExpression(@1, $2); } | DECLARE_INT variable SET_INITIAL_VALUE integer { $$ = new yy.IntDeclarationExpression(@1, $2, $4); } | BEGIN_ASSIGN variable SET_VALUE integer END_ASSIGN { $$ = new yy.AssignmentExpression(@1, $2, $4, []);} | BEGIN_ASSIGN variable SET_VALUE integer ops END_ASSIGN { $$ = new yy.AssignmentExpression(@1, $2, $4, $5);} | IF integer statements END_IF { $$ = new yy.IfExpression(@1, $2, $3, [], @4); } | IF integer statements else statements END_IF { $$ = new yy.IfExpression(@1, $2, $3, $5, @6, $4); } | WHILE variable statements END_WHILE { $$ = new yy.WhileExpression(@1, $2, $3, @4); } | method_call { $$ = $1; } | ASSIGN_FROM_CALL variable method_call { $$ = new yy.AssignmentFromCallExpression(@1, $2, $3); } | RETURN integer { $$ = new yy.ReturnExpression(@1, $2); } ;

Slide 105

Slide 105 text

class PrintExpression extends AstNode { constructor(position, value) { super(position.first_line, position.first_column); this.value = value; } compile() { return 'console.log( ' + this.value.compile() + ' );\n'; } }

Slide 106

Slide 106 text

class AstNode { constructor(line, column) { this.line = line; this.column = column; } compile() { //Abstract } } class PrintExpression extends AstNode { constructor(position, value) { super(position.first_line, position.first_column); this.value = value; } compile() { return 'console.log( ' + this.value.compile() + ' );\n'; } }

Slide 107

Slide 107 text

class AstNode { constructor(line, column) { this.line = line; this.column = column; } compile() { //Abstract } } class PrintExpression extends AstNode { constructor(position, value) { super(position.first_line, position.first_column); this.value = value; } compile() { return 'console.log( ' + this.value.compile() + ' );\n'; } }

Slide 108

Slide 108 text

class PrintExpression extends AstNode { constructor(position, value) { super(position.first_line, position.first_column); this.value = value; } compile() { return 'console.log( ' + this.value.compile() + ' );\n'; } }

Slide 109

Slide 109 text

class AstNode { constructor(line, column) { this.line = line; this.column = column; } compile() { //Abstract } } class PrintExpression extends AstNode { constructor(position, value) { super(position.first_line, position.first_column); this.value = value; } compile() { return 'console.log( ' + this.value.compile() + ' );\n'; } }

Slide 110

Slide 110 text

Statements IfStatement WhileStatements PrintStatement MainExpression INTEGER Statements String

Slide 111

Slide 111 text

Statements IfStatement WhileStatements PrintStatement MainExpression INTEGER Statements String .compile() .compile() .compile() .compile() .compile() .compile() .compile()

Slide 112

Slide 112 text

class MainExpression extends AstNode { constructor(statements, startPosition, endPosition) { // etc etc } compile(indent, fileName) { return this._sn('(function() {\n') .add(this.statements.map(function (child) { return child.compile(); })) .add('}());\n')); } }

Slide 113

Slide 113 text

var fs = require("fs"); var jison = require("jison"); var bnf = fs.readFileSync("grammar.jison", "utf8"); var parser = new jison.Parser(bnf); return parser.parse(input); CLI

Slide 114

Slide 114 text

var fs = require("fs"); var jison = require("jison"); var bnf = fs.readFileSync("grammar.jison", "utf8"); var parser = new jison.Parser(bnf); return parser.parse(input); CLI

Slide 115

Slide 115 text

TALK TO THE HAND "demo"

Slide 116

Slide 116 text

Source Maps

Slide 117

Slide 117 text

var multiple = divisible(n, 3); if (multiple) { console.log( "Fizz" ); } else { var multiple = divisible(n, 5); if (multiple) { console.log( "Buzz" ); } else { console.log( n ); } } } } }()); }()); //# sourceMappingURL=fizzbuzz.arnoldc.js.map

Slide 118

Slide 118 text

var multiple = divisible(n, 3); if (multiple) { console.log( "Fizz" ); } else { var multiple = divisible(n, 5); if (multiple) { console.log( "Buzz" ); } else { console.log( n ); } } } } }()); }()); //# sourceMappingURL=fizzbuzz.arnoldc.js.map

Slide 119

Slide 119 text

{"version":3,"sources":["fizzbuzz.arnoldc"],"names": [],"mappings":";;CA2CA,SAA4B,MAA5B,EACqD,QADrD,EAEqD,OAFrD;GAII,IAAmB,QAAnB,GACgB,CADhB;GAEA,IAAmB,SAAnB,GACgB,CADhB;GAEA,IAAm B,OAAnB,GACgB,CADhB;GAEA,IAAmB,QAAnB,KACwB,QACtB,GAAgB,OAFlB;GAAA,UAAmB,QAAnB,mBAAmB,QAAnB,GAAmB,QAAnB;GAAmB,QAAnB,cAAmB,QAAnB ;GAIA,IAAmB,OAAnB,KACwB,OACtB,GAAa,QAFf;GAAA,UAAmB,OAAnB,mBAAmB,OAAnB,GAAmB,OAAnB;GAAmB,OAAnB,cAAmB,OAAnB;GAIA,IAAmB,SAAnB,KAC wB,QACxB,GAAS,OAFT;GAAA,UAAmB,SAAnB,mBAAmB,SAAnB,GAAmB,SAAnB;GAAmB,SAAnB,cAAmB,SAAnB;GAIF,OAAa,SAAb;CACF;CAEA,SAA4B,SAA5B,EACm D,QADnD,EAEmD,OAFnD;GAKA,IAAmB,MAAnB,GACc,CADd;GAEA,IAAqB,MAArB,GACU,MAAV,CAAiB,QAAjB,EAA0B,OAA1B;GAEA,IAAmB,MAAnB,GACc,CADd;G AEA,IAAmB,MAAnB,KACsB,MACtB,IAA2B,CAF3B;GAAA,UAAmB,MAAnB,mBAAmB,MAAnB,GAAmB,MAAnB;GAAmB,MAAnB,cAAmB,MAAnB;GAKA,OAAa,MAAb;CACA; CAtFA;GAEA,IAAmB,aAAnB,GACc,IADd;GAEA,IAAmB,CAAnB,GACc,CADd;GAEA,IAAmB,QAAnB,GACc,IADd;GAGA,OAAa,aAAb;KACA,IAAmB,CAAnB,KACsB,C ACtB,GAAO,CAFP;KAAA,UAAmB,CAAnB,mBAAmB,CAAnB,GAAmB,CAAnB;KAAmB,CAAnB,cAAmB,CAAnB;KAKA,IAAmB,aAAnB,KACsB,GACtB,GAA0B,CAF1B;KAAA ,UAAmB,aAAnB,mBAAmB,aAAnB,GAAmB,aAAnB;KAAmB,aAAnB,cAAmB,aAAnB;KAKA,IAAqB,QAArB,GACU,SAAV,CAAoB,CAApB,EAAsB,EAAtB;KACA,IAAgC,QA AhC;OACA,aAAiB,UAAjB;KADA;KAEA;OACA,IAAqB,QAArB,GACU,SAAV,CAAoB,CAApB,EAAsB,CAAtB;OACA,IAAgC,QAAhC;SACA,aAAiB,MAAjB;OADA;OAEA; SACA,IAAqB,QAArB,GACU,SAAV,CAAoB,CAApB,EAAsB,CAAtB;SACA,IAAgC,QAAhC;WACA,aAAiB,MAAjB;SADA;SAEA;WACA,aAAiB,CAAjB;SACA;OACA;KACA ;GACA;CAEA","file":"fizzbuzz.arnoldc.js.map","sourcesContent":["IT'S SHOWTIME\n\nHEY CHRISTMAS TREE isLessThan100\nYOU SET US UP @NO PROBLEMO\nHEY CHRISTMAS TREE n\nYOU SET US UP 0\nHEY CHRISTMAS TREE multiple\nYOU SET US UP @NO PROBLEMO\n\nSTICK AROUND isLessThan100\nGET TO THE CHOPPER n\nHERE IS MY INVITATION n\nGET UP 1\nENOUGH TALK\n\nGET TO THE CHOPPER isLessThan100\nHERE IS MY INVITATION 100\nLET OFF SOME STEAM BENNET n\nENOUGH TALK\n\nGET YOUR ASS TO MARS multiple\nDO IT NOW divisible n 15\nBECAUSE I'M GOING TO SAY PLEASE multiple\nTALK TO THE HAND \"FizzBuzz\"\nBULLSHIT\nGET YOUR ASS TO MARS multiple\nDO IT NOW divisible n 3\nBECAUSE I'M GOING TO SAY PLEASE multiple\nTALK TO THE HAND \"Fizz\"\nBULLSHIT\nGET YOUR ASS TO MARS multiple\nDO IT NOW divisible n 5\nBECAUSE I'M GOING TO SAY PLEASE multiple\nTALK TO THE HAND \"Buzz\"\nBULLSHIT\nTALK TO THE HAND n\nYOU HAVE NO RESPECT FOR LOGIC\nYOU HAVE NO RESPECT FOR LOGIC\nYOU HAVE NO RESPECT FOR LOGIC\nCHILL\n\nYOU HAVE BEEN TERMINATED\n\nLISTEN TO ME VERY CAREFULLY modulo\n I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE dividend\n I NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE divisor\n GIVE THESE PEOPLE AIR\n HEY CHRISTMAS TREE quotient\n YOU SET US UP 0\n HEY CHRISTMAS TREE remainder\n YOU SET US UP 0\n HEY CHRISTMAS TREE product\n YOU SET US UP 0\n GET TO THE CHOPPER quotient\n HERE IS MY INVITATION dividend\n HE HAD TO SPLIT divisor\n ENOUGH TALK\n GET TO THE CHOPPER product\n HERE IS MY INVITATION divisor\n YOU'RE FIRED quotient\n ENOUGH TALK\n GET TO THE CHOPPER remainder\n HERE IS MY INVITATION dividend\n GET DOWN product\n ENOUGH TALK\n I'LL BE BACK remainder\nHASTA LA VISTA, BABY\n\nLISTEN TO ME VERY CAREFULLY divisible\nI NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE dividend\nI NEED YOUR CLOTHES YOUR BOOTS AND YOUR MOTORCYCLE divisor\nGIVE THESE PEOPLE AIR\n\nHEY CHRISTMAS TREE result\nYOU SET US UP 0\nGET YOUR ASS TO MARS result\nDO IT NOW modulo dividend divisor\n\nHEY CHRISTMAS TREE isZero\nYOU SET US UP 0\nGET TO THE CHOPPER isZero \nHERE IS MY INVITATION result\nYOU ARE NOT YOU YOU ARE ME 0\nENOUGH TALK\n\nI'LL BE BACK isZero\nHASTA LA VISTA, BABY\n"]}

Slide 120

Slide 120 text

$ npm i source-map

Slide 121

Slide 121 text

@fitzgen

Slide 122

Slide 122 text

var sourceNode = require('source-map').SourceNode; var AdditionOperation = function(first, second) { return new SourceNode( line, column, source, `${first} + ${second}` ); }; ast.js

Slide 123

Slide 123 text

class AstNode { _sn(indent, fileName, chunk) { return new SourceNode(this.line, this.column, fileName, '') .add(indentNode(indent)) .add(chunk); } compile(indent, fileName) { //Abstract } }

Slide 124

Slide 124 text

class AstNode { _sn(indent, fileName, chunk) { return new SourceNode(this.line, this.column, fileName, '') .add(indentNode(indent)) .add(chunk); } compile(indent, fileName) { //Abstract } } class MainExpression extends AstNode { compile(indent, fileName) { return this._sn(indent, fileName, '(function() {\n') .add(this.statements.map(function (child) { return child.compile(indent + 1, fileName); })) .add(indentNode(indent)) .add(new SourceNode(this.endLine, this.endColumn, fileName, '}());\n')); } }

Slide 125

Slide 125 text

Statements IfStatement WhileStatements PrintStatement MainExpression INTEGER Statements String

Slide 126

Slide 126 text

Statements IfStatement WhileStatements PrintStatement MainExpression INTEGER Statements String .compile() .compile() .compile() .compile() .compile() .compile() .compile()

Slide 127

Slide 127 text

SourceNode SourceNode SourceNode SourceNode SourceNode SourceNode SourceNode SourceNode .compile() .compile() .compile() .compile() .compile() .compile() .compile()

Slide 128

Slide 128 text

11+ Source Maps

Slide 129

Slide 129 text

GET TO THE CHOPPER visualize http://sokra.github.io/source-map-visualization/

Slide 130

Slide 130 text

ENTERPRISE GRADE ARNOLDC

Slide 131

Slide 131 text

In Browser Compiler

Slide 132

Slide 132 text

Gulp Plugin

Slide 133

Slide 133 text

Webpack Loader

Slide 134

Slide 134 text

ArnoldC Speaker

Slide 135

Slide 135 text

Build Your Own Compiler /mattdsteele/arnoldc.js

Slide 136

Slide 136 text

@mattdsteele http://steele.blue