summaryrefslogtreecommitdiff
path: root/miniany/doc/stackoverflow.com_questions_1669_learning-to-write-a-compiler.txt
blob: 58411a4fb61862fc806694ce567c94bf1885e918 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
1016
1017
1018
1019
1020
1021
1022
1023
1024
1025
1026
1027
1028
1029
1030
1031
1032
1033
1034
1035
1036
1037
1038
1039
1040
1041
1042
1043
1044
1045
1046
1047
1048
1049
1050
1051
1052
1053
1054
1055
1056
1057
1058
1059
1060
1061
1062
1063
1064
1065
1066
1067
1068
1069
1070
1071
1072
1073
1074
1075
1076
1077
1078
1079
1080
1081
1082
1083
1084
1085
1086
1087
1088
1089
1090
1091
1092
1093
1094
1095
1096
1097
1098
1099
1100
1101
1102
1103
1104
1105
1106
1107
1108
1109
1110
1111
1112
1113
1114
1115
1116
1117
1118
1119
1120
1121
1122
1123
1124
1125
1126
1127
1128
1129
1130
1131
1132
1133
1134
1135
1136
1137
1138
1139
1140
1141
1142
1143
1144
1145
1146
1147
1148
1149
1150
1151
1152
1153
1154
1155
1156
1157
1158
1159
1160
1161
1162
1163
1164
1165
1166
1167
1168
1169
1170
1171
1172
1173
1174
1175
1176
1177
1178
1179
1180
1181
1182
1183
1184
1185
1186
1187
1188
1189
1190
1191
1192
1193
1194
1195
1196
1197
1198
1199
1200
1201
1202
1203
1204
1205
1206
1207
1208
1209
1210
1211
1212
1213
1214
1215
1216
1217
1218
1219
1220
1221
1222
1223
1224
1225
1226
1227
1228
1229
1230
1231
1232
1233
1234
1235
1236
1237
1238
1239
1240
1241
1242
1243
1244
1245
1246
1247
1248
1249
1250
1251
1252
1253
1254
1255
1256
1257
1258
1259
1260
1261
1262
1263
1264
1265
1266
1267
1268
1269
1270
1271
1272
1273
1274
1275
1276
1277
1278
1279
1280
1281
1282
1283
1284
1285
1286
1287
1288
1289
1290
1291
1292
1293
1294
1295
1296
1297
1298
1299
1300
1301
1302
1303
1304
1305
1306
1307
1308
1309
1310
1311
1312
1313
1314
1315
1316
1317
1318
1319
1320
1321
1322
1323
1324
1325
1326
1327
1328
1329
1330
1331
1332
1333
1334
1335
1336
1337
1338
1339
1340
1341
1342
1343
1344
1345
1346
1347
1348
1349
1350
1351
1352
1353
1354
1355
1356
1357
1358
1359
1360
1361
1362
1363
1364
1365
1366
1367
1368
1369
1370
1371
1372
1373
1374
1375
1376
1377
1378
1379
1380
1381
1382
1383
1384
1385
1386
1387
1388
1389
1390
1391
1392
1393
1394
1395
1396
1397
1398
1399
1400
1401
1402
1403
1404
1405
1406
1407
1408
1409
1410
1411
1412
1413
1414
1415
1416
1417
1418
1419
1420
1421
1422
1423
1424
1425
1426
1427
1428
1429
1430
1431
1432
1433
1434
1435
1436
1437
1438
1439
1440
1441
1442
1443
1444
1445
1446
1447
1448
1449
1450
1451
1452
1453
1454
1455
1456
1457
1458
1459
1460
1461
1462
1463
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
1500
1501
1502
1503
1504
1505
1506
1507
1508
1509
1510
1511
1512
1513
1514
1515
1516
1517
1518
1519
1520
1521
1522
1523
1524
1525
1526
1527
1528
1529
1530
1531
1532
1533
1534
1535
1536
1537
1538
1539
1540
1541
1542
1543
1544
1545
1546
1547
1548
1549
1550
1551
1552
1553
1554
1555
1556
1557
1558
1559
1560
1561
1562
1563
1564
1565
1566
1567
1568
1569
1570
1571
1572
1573
1574
1575
1576
1577
1578
1579
1580
1581
1582
1583
1584
1585
1586
1587
1588
1589
1590
1591
1592
1593
1594
1595
1596
1597
1598
1599
1600
1601
1602
1603
1604
1605
1606
1607
1608
1609
1610
1611
1612
1613
1614
1615
1616
1617
1618
1619
1620
1621
1622
1623
1624
1625
1626
1627
1628
1629
1630
1631
1632
1633
1634
1635
1636
1637
1638
1639
1640
1641
1642
1643
1644
1645
1646
1647
1648
1649
1650
1651
1652
1653
1654
1655
1656
1657
1658
1659
1660
1661
1662
1663
1664
1665
1666
1667
1668
1669
1670
1671
1672
1673
1674
1675
1676
1677
1678
1679
1680
1681
1682
1683
1684
1685
1686
1687
1688
1689
1690
1691
1692
1693
1694
1695
1696
1697
1698
1699
1700
1701
1702
1703
1704
1705
1706
1707
1708
1709
1710
1711
1712
1713
1714
1715
1716
1717
1718
1719
1720
1721
1722
1723
1724
1725
1726
1727
1728
1729
1730
1731
1732
1733
1734
1735
1736
1737
1738
1739
1740
1741
1742
1743
1744
1745
1746
1747
1748
1749
1750
1751
1752
1753
1754
1755
1756
1757
1758
1759
1760
1761
1762
1763
1764
1765
1766
1767
1768
1769
1770
1771
1772
1773
1774
1775
1776
1777
1778
1779
1780
1781
1782
1783
1784
1785
1786
1787
1788
1789
1790
1791
1792
1793
1794
1795
1796
1797
1798
1799
1800
1801
1802
1803
1804
1805
1806
1807
1808
1809
1810
1811
1812
1813
1814
1815
1816
1817
1818
1819
1820
1821
1822
1823
1824
1825
1826
1827
1828
1829
1830
1831
1832
1833
1834
1835
1836
1837
1838
1839
1840
1841
1842
1843
1844
1845
1846
1847
1848
1849
1850
1851
1852
1853
1854
1855
1856
1857
1858
1859
1860
1861
1862
1863
1864
1865
1866
1867
1868
1869
1870
1871
1872
1873
1874
1875
1876
1877
1878
1879
1880
1881
1882
1883
1884
1885
1886
1887
1888
1889
1890
1891
1892
1893
1894
1895
   #[1]Stack Overflow

   [2]Stack Overflow
    1. [3]About
    2. [4]Products
    3. [5]For Teams

    1. [6]Stack Overflow Public questions & answers
    2. [7]Stack Overflow for Teams Where developers & technologists share
       private knowledge with coworkers
    3. [8]Talent Build your employer brand
    4. [9]Advertising Reach developers & technologists worldwide
    5. [10]Labs The future of collective knowledge sharing
    6. [11]About the company

   ____________________
   Loading...

    1.

[12]current community
       (BUTTON)
          + Stack Overflow
            [13]help [14]chat
          + Meta Stack Overflow

your communities
       [15]Sign up or [16]log in to customize your list.

[17]more stack exchange communities
       [18]company blog
    2. (BUTTON)
    3. [19]Log in
    4. [20]Sign up

    1.
         1. [21]Home
         2. [22]Questions
         3. [23]Tags
         4.
         5. [24]Users
         6. [25]Companies
         7. Collectives
         8. [26]Explore Collectives
         9. Labs
        10. [27]Discussions
    2. Teams
       Stack Overflow for Teams - Start collaborating and sharing
       organizational knowledge. [28]Create a free Team [29]Why Teams?
    3. Teams
    4. Create free Team

Collectives(TM) on Stack Overflow

   Find centralized, trusted content and collaborate around the
   technologies you use most.
   [30]Learn more about Collectives

   Teams

   Q&A for work

   Connect and share knowledge within a single location that is structured
   and easy to search.
   [31]Learn more about Teams

   Get early access and see previews of new features.
   [32]Learn more about Labs

[33]Learning to write a compiler [closed]

   [34]Ask Question
   Asked 15 years, 5 months ago
   Modified [35]2 years, 5 months ago
   Viewed 360k times
   (BUTTON)
   697
   (BUTTON) (BUTTON)

   Closed. This question does not meet [36]Stack Overflow guidelines. It
   is not currently accepting answers.
     __________________________________________________________________

   Questions asking us to recommend or find a tool, library or favorite
   off-site resource are off-topic for Stack Overflow as they tend to
   attract opinionated answers and spam. Instead, [37]describe the problem
   and what has been done so far to solve it.

   Closed 9 years ago.

   This question's answers are a [38]community effort. Edit existing
   answers to improve this post. It is not currently accepting new answers
   or interactions.

   Preferred languages: C/C++, Java, and Ruby.

   I am looking for some helpful books/tutorials on how to write your own
   compiler simply for educational purposes. I am most familiar with
   C/C++, Java, and Ruby, so I prefer resources that involve one of those
   three, but any good resource is acceptable.
     * [39]compiler-construction
     * [40]language-agnostic

   [41]Share
   (BUTTON) Follow
   [42]edited Feb 28, 2014 at 23:45
   community wiki
   [43]20 revs, 10 users 47%
   [44]Anton
   4
     * ANTLR all the way. All the resources proposed below looks like an
       overkill to me. ANTLR is always a compiler designer best friend. A
       - [45]A_Var
       Dec 19, 2010 at 4:25
     * If your main focus is to learn how compiling ideas work in general
       - you can check and SICP short for Structured Interpretation of
       Computer program based in Scheme ( List) but teaches the general
       principles . [46]mitpress.mit.edu/sicp . I was recommended this
       book by a veteran who works for a company and does these works
       compilation and interpretation for a living !
       - [47]Nishant
       Apr 27, 2011 at 15:32
     * A shameless plug: [48]my answer on a similar question.
       - [49]9000
       Mar 1, 2014 at 0:21
     * I wrote an article on creating a compiler on my blog:
       [50]orangejuiceliberationfront.com/how-to-write-a-compiler It
       focuses on the very basics and getting started, really. There's a
       bunch more compiler/codegen/parser/language design-related articles
       on there.
       - [51]uliwitness
       Mar 8, 2014 at 12:33

   Comments disabled on deleted / locked posts / reviews  |

38 Answers 38

   Sorted by: [52]Reset to default
   [Highest score (default)___________]
   1
   [53]2 [54]Next
   (BUTTON)
   1193
   (BUTTON) (BUTTON)

Big List of Resources:

     * [55]A Nanopass Framework for Compiler Education ¶
     * [56]Advanced Compiler Design and Implementation $
     * [57]An Incremental Approach to Compiler Construction ¶
     * [58]ANTLR 3.x Video Tutorial
     * [59]Basics of Compiler Design
     * [60]Building a Parrot Compiler
     * [61]Compiler Basics
     * [62]Compiler Construction $
     * [63]Compiler Design and Construction $
     * [64]Crafting a Compiler with C $
     * [65]Crafting Interpreters
     * [Compiler Design in C] [66]12 ¶
     * [67]Compilers: Principles, Techniques, and Tools $ -- aka [68]"The
       Dragon Book"; widely considered "the book" for compiler writing.
     * [69]Engineering a Compiler $
     * [70]Essentials of Programming Languages
     * [71]Flipcode Article Archive (look for "Implementing A Scripting
       Engine by Jan Niestadt")
     * [72]Game Scripting Mastery $
     * [73]How to build a virtual machine from scratch in C# ¶
     * [74]Implementing Functional Languages
     * [75]Implementing Programming Languages (with BNFC)
     * [76]Implementing Programming Languages using C# 4.0
     * [77]Interpreter pattern (described in [78]Design Patterns $)
       specifies a way to evaluate sentences in a language
     * [79]Language Implementation Patterns: Create Your Own
       Domain-Specific and General Programming Languages $
     * [80]Let's Build a Compiler by Jack Crenshaw -- The [81]PDF ¶
       version (examples are in Pascal, but the information is generally
       applicable)
     * [82]Linkers and Loaders $ (Google Books)
     * [83]Lisp in Small Pieces (LiSP) $
     * [84]LLVM Tutorial
     * [85]Modern Compiler Implementation in ML $ -- There is a [86]Java $
       and [87]C $ version as well - widely considered a very good book
     * [88]Object-Oriented Compiler Construction $
     * [89]Parsing Techniques - A Practical Guide
     * [90]Project Oberon ¶ - Look at chapter 13
     * [91]Programming a Personal Computer $
     * [92]Programing Languages: Application and Interpretation
     * [93]Rabbit: A Compiler for Scheme¶
     * [94]Reflections on Trusting Trust -- A quick guide
     * [95]Roll Your Own Compiler for the .NET framework -- A quick
       tutorial from MSDN
     * [96]Structure and Interpretation of Computer Programs
     * [97]Types and Programming Languages
     * [98]Want to Write a Compiler? - a quick guide
     * [99]Writing a Compiler in Ruby Bottom Up
     * [100]Compiling a Lisp -- compile directly to x86-64

   Legend:
     * ¶ Link to a PDF file
     * $ Link to a printed book

   [101]Share
   (BUTTON) Follow
   [102]edited Jul 30, 2021 at 22:04
   community wiki
   [103]40 revs, 29 users 26%
   [104]Anton
   4
     * 28
       I've read Let's Build a Compiler
       [[105]compilers.iecc.com/crenshaw/] series, it is really nice
       writeup and is a good starting point.
       - [106]TheVillageIdiot
       May 31, 2010 at 4:35
     * 6
       I think one worth mentioning is Coursera's compilers course. It has
       nice videos and walks through creating a java like language /
       simple compiler. [107]Coursera Compilers Link
       - [108]QuantumKarl
       Feb 24, 2016 at 15:25
     * 2
       I wanted to keep this answer posted to being as original as
       possible so I decided to post this reference here:
       [109]tutorialspoint.com/compiler_design/index.htm What I liked
       about this site is that it doesn't get involved with actually
       writing any code to create a compiler, but it does break down the
       compiler into its parts: phases and stages. It does describe the
       logic and algorithmic design approach without any specific language
       paradigm as it expresses the notations of an arbitrary language and
       alphabet. It is a quick read, but gives you the concepts of what is
       needed for each part.
       - [110]Francis Cugler
       Dec 8, 2016 at 11:55
     * 3
       The link by @TheVillageIdiot is broken (due to a formatting error
       in the comment), this works: [111]compilers.iecc.com/crenshaw
       - [112]dimitar.bogdanov
       Feb 20, 2021 at 14:33

   [113]Add a comment  |
   (BUTTON)
   75
   (BUTTON) (BUTTON)

   This is a pretty vague question, I think; just because of the depth of
   the topic involved. A compiler can be decomposed into two separate
   parts, however; a top-half and a bottom-one. The top-half generally
   takes the source language and converts it into an intermediate
   representation, and the bottom half takes care of the platform specific
   code generation.

   Nonetheless, one idea for an easy way to approach this topic (the one
   we used in my compilers class, at least) is to build the compiler in
   the two pieces described above. Specifically, you'll get a good idea of
   the entire process by just building the top-half.

   Just doing the top half lets you get the experience of writing the
   lexical analyzer and the parser and go to generating some "code" (that
   intermediate representation I mentioned). So it will take your source
   program and convert it to another representation and do some
   optimization (if you want), which is the heart of a compiler. The
   bottom half will then take that intermediate representation and
   generate the bytes needed to run the program on a specific
   architecture. For example, the the bottom half will take your
   intermediate representation and generate a PE executable.

   Some books on this topic that I found particularly helpful was
   [114]Compilers Principles and Techniques (or the Dragon Book, due to
   the cute dragon on the cover). It's got some great theory and
   definitely covers Context-Free Grammars in a really accessible manner.
   Also, for building the lexical analyzer and parser, you'll probably use
   the *nix tools lex and yacc. And uninterestingly enough, the book
   called "[115]lex and yacc" picked up where the Dragon Book left off for
   this part.
   [116]Share
   (BUTTON) Follow
   answered [117]Jul 20, 2009 at 23:01
   community wiki
   [118]mrduclaw

   [119]Add a comment  |
   (BUTTON)
   61
   (BUTTON) (BUTTON)

   I think [120]Modern Compiler Implementation in ML is the best
   introductory compiler writing text. There's a [121]Java version and a
   [122]C version too, either of which might be more accessible given your
   languages background. The book packs a lot of useful basic material
   (scanning and parsing, semantic analysis, activation records,
   instruction selection, RISC and x86 native code generation) and various
   "advanced" topics (compiling OO and functional languages, polymorphism,
   garbage collection, optimization and single static assignment form)
   into relatively little space (~500 pages).

   I prefer Modern Compiler Implementation to the Dragon book because
   Modern Compiler implementation surveys less of the field--instead it
   has really solid coverage of all the topics you would need to write a
   serious, decent compiler. After you work through this book you'll be
   ready to tackle research papers directly for more depth if you need it.

   I must confess I have a serious soft spot for Niklaus Wirth's
   [123]Compiler Construction. It is [124]available online as a PDF. I
   find Wirth's programming aesthetic simply beautiful, however some
   people find his style too minimal (for example Wirth favors recursive
   descent parsers, but most CS courses focus on parser generator tools;
   Wirth's language designs are fairly conservative.) Compiler
   Construction is a very succinct distillation of Wirth's basic ideas, so
   whether you like his style or not or not, I highly recommend reading
   this book.
   [125]Share
   (BUTTON) Follow
   [126]edited Dec 4, 2019 at 14:42
   community wiki
   [127]2 revs, 2 users 96%
   [128]Dominic Cooney
   2
     * Compiler Construction PDF
       [129]ethoberon.ethz.ch/WirthPubl/CBEAll.pdf
       - [130]matepal297
       Oct 21, 2015 at 22:00
     * I strongly recommend against the C version of "Modern Compiler
       Implementation", it's crippled by low-level details due to C. It
       completely clutters the book. Java 1st is not too good as its OO
       design is poor, Java 2nd ed is no longer about the Tiger language.
       So I strongly recommend the ML one: it is not necessary to be
       fluent in ML to understand it. ML is definitely well suited for the
       job.
       - [131]akim
       Jul 26, 2016 at 17:52

   [132]Add a comment  |
   (BUTTON)
   47
   (BUTTON) (BUTTON)

   I concur with the Dragon Book reference; IMO, it is the definitive
   guide to compiler construction. Get ready for some hardcore theory,
   though.

   If you want a book that is lighter on theory, [133]Game Scripting
   Mastery might be a better book for you. If you are a total newbie at
   compiler theory, it provides a gentler introduction. It doesn't cover
   more practical parsing methods (opting for non-predictive recursive
   descent without discussing LL or LR parsing), and as I recall, it
   doesn't even discuss any sort of optimization theory. Plus, instead of
   compiling to machine code, it compiles to a bytecode that is supposed
   to run on a VM that you also write.

   It's still a decent read, particularly if you can pick it up for cheap
   on Amazon. If you only want an easy introduction into compilers, Game
   Scripting Mastery is not a bad way to go. If you want to go hardcore up
   front, then you should settle for nothing less than the Dragon Book.
   [134]Share
   (BUTTON) Follow
   answered [135]Aug 4, 2008 at 23:08
   community wiki
   [136]user316
   2
     * 2
       Game Scripting Mastery is a great learning resource because when
       you're done you will have a playable, scriptable 2D adventure game.
       This makes every exercise focused on a specific purpose, and keeps
       the reader motivated.
       - [137]Dour High Arch
       Dec 9, 2008 at 17:58
     * 1
       Dragon is a bit overly focussed on grammar based parsing. If you
       are not trying to parse something sheer impossible like C++ or so
       using parser generators, but can use e.g. a handcrafted LL grammar
       you might want to look out for something that treats a higher
       percentage compiler fields other than grammar transformation and
       proving
       - [138]Marco van de Voort
       Jun 26, 2009 at 21:36

   [139]Add a comment  |
   (BUTTON)
   32
   (BUTTON) (BUTTON)

   [140]"Let's Build a Compiler" is awesome, but it's a bit outdated. (I'm
   not saying it makes it even a little bit less valid.)

   Or check out [141]SLANG. This is similar to "Let's Build a Compiler"
   but is a much better resource especially for beginners. This comes with
   a pdf tutorial which takes a 7 step approach at teaching you a
   compiler. Adding the quora link as it have the links to all the various
   ports of SLANG, in C++, Java and JS, also interpreters in python and
   java, originally written using C# and the .NET platform.
   [142]Share
   (BUTTON) Follow
   [143]edited Aug 16, 2016 at 5:55
   community wiki
   [144]4 revs, 4 users 40%
   [145]RBz
   1
     * 5
       I agree that this series is a bit outdated, although it is still
       useful. However, my biggest gripe with it is the fact that it tries
       to output straight to assembly language rather than building any
       type of parse tree, which means (contrary to what is stated in the
       first article) that it isn't very useful for writing an
       interpreter.
       - [146]a_m0d
       Sep 16, 2010 at 6:58

   [147]Add a comment  |
   (BUTTON)
   26
   (BUTTON) (BUTTON)

   If you're looking to use powerful, higher level tools rather than
   building everything yourself, going through the projects and readings
   for [148]this course is a pretty good option. It's a languages course
   by the author of the Java parser engine ANTLR. You can get the book for
   the course as a PDF from [149]the Pragmatic Programmers.

   The course goes over the standard compiler compiler stuff that you'd
   see elsewhere: parsing, types and type checking, polymorphism, symbol
   tables, and code generation. Pretty much the only thing that isn't
   covered is optimizations. The final project is a program that
   [150]compiles a subset of C. Because you use tools like ANTLR and LLVM,
   it's feasible to write the entire compiler in a single day (I have an
   existence proof of this, though I do mean ~24 hours). It's heavy on
   practical engineering using modern tools, a bit lighter on theory.

   LLVM, by the way, is simply fantastic. Many situations where you might
   normally compile down to assembly, you'd be much better off compiling
   to [151]LLVM's Intermediate Representation instead. It's higher level,
   cross platform, and LLVM is quite good at generating optimized assembly
   from it.
   [152]Share
   (BUTTON) Follow
   [153]edited Aug 4, 2008 at 23:25
   community wiki
   [154]2 revs
   [155]Peter Burns
   1
     * 8
       The first link is dead.
       - [156]Lynn
       Mar 24, 2017 at 13:31

   [157]Add a comment  |
   (BUTTON)
   23
   (BUTTON) (BUTTON)

   If you have little time, I recommend [158]Niklaus Wirth's "Compiler
   Construction" (Addison-Wesley. 1996), a tiny little booklet that you
   can read in a day, but it explains the basics (including how to
   implement lexers, recursive descent parsers, and your own stack-based
   virtual machines). After that, if you want a deep dive, there's no way
   around the Dragon book as other commenters suggest.
   [159]Share
   (BUTTON) Follow
   [160]edited Oct 18, 2011 at 13:55
   community wiki
   [161]2 revs, 2 users 67%
   [162]Matthieu
   1
     * If you have not much time, don' write a compiler.
       - [163]Ingo
       Jan 6, 2012 at 23:56

   [164]Add a comment  |
   (BUTTON)
   19
   (BUTTON) (BUTTON)

   You might want to look into Lex/Yacc (or Flex/Bison, whatever you want
   to call them). Flex is a lexical analyzer, which will parse and
   identify the semantic components ("tokens") of your language, and Bison
   will be used to define what happens when each token is parsed. This
   could be, but is definitely not limited to, printing out C code, for a
   compiler that would compile to C, or dynamically running the
   instructions.

   [165]This FAQ should help you, and [166]this tutorial looks quite
   useful.
   [167]Share
   (BUTTON) Follow
   answered [168]Jul 20, 2009 at 22:47
   community wiki
   [169]Zachary Murray

   [170]Add a comment  |
   (BUTTON)
   17
   (BUTTON) (BUTTON)

   Generally speaking, there's no five minutes tutorial for compilers,
   because it's a complicated topic and writing a compiler can take
   months. You will have to do your own search.

   Python and Ruby are usually interpreted. Perhaps you want to start with
   an interpreter as well. It's generally easier.

   The first step is to write a formal language description, the grammar
   of your programming language. Then you have to transform the source
   code that you want to compile or interpret according to the grammar
   into an abstract syntax tree, an internal form of the source code that
   the computer understands and can operate on. This step is usually
   called parsing and the software that parses the source code is called a
   parser. Often the parser is generated by a parser generator which
   transform a formal grammar into source oder machine code. For a good,
   non-mathematical explanation of parsing I recommend Parsing Techniques
   - A Practical Guide. Wikipedia has a comparison of parser generators
   from which you can choose that one that is suitable for you. Depending
   on the parser generator you chose, you will find tutorials on the
   Internet and for really popular parser generators (like GNU bison)
   there are also books.

   Writing a parser for your language can be really hard, but this depends
   on your grammar. So I suggest to keep your grammar simple (unlike C++);
   a good example for this is LISP.

   In the second step the abstract syntax tree is transformed from a tree
   structure into a linear intermediate representation. As a good example
   for this Lua's bytecode is often cited. But the intermediate
   representation really depends on your language.

   If you are building an interpreter, you will simply have to interpret
   the intermediate representation. You could also just-in-time-compile
   it. I recommend LLVM and libjit for just-in-time-compilation. To make
   the language usable you will also have to include some input and output
   functions and perhaps a small standard library.

   If you are going to compile the language, it will be more complicated.
   You will have to write backends for different computer architectures
   and generate machine code from the intermediate representation in those
   backends. I recommend LLVM for this task.

   There are a few books on this topic, but I can recommend none of them
   for general use. Most of them are too academic or too practical.
   There's no "Teach yourself compiler writing in 21 days" and thus, you
   will have to buy several books to get a good understanding of this
   entire topic. If you search the Internet, you will come across some
   some online books and lecture notes. Maybe there's a university library
   nearby you where you can borrow books on compilers.

   I also recommend a good background knowledge in theoretical computer
   science and graph theory, if you are going to make your project
   serious. A degree in computer science will also be helpful.
   [171]Share
   (BUTTON) Follow
   answered [172]Jul 21, 2009 at 10:37
   community wiki
   [173]user141335
   1
     * ++ You're right that it's good to know all those things, and it can
       be a big job, but I also learned from some experts how not to make
       things a big deal. It's good to know things, and it's even better
       to know when not to use them, which is most of the time.
       - [174]Mike Dunlavey
       Jul 21, 2009 at 16:00

   [175]Add a comment  |
   (BUTTON)
   14
   (BUTTON) (BUTTON)

   Take a look at the book below. The author is the creator of [176]ANTLR.

   [177]Language Implementation Patterns: Create Your Own Domain-Specific
   and General Programming Languages.

   alt text
   [178]Share
   (BUTTON) Follow
   [179]edited Dec 27, 2014 at 12:39
   community wiki
   [180]2 revs, 2 users 95%
   [181]Taylor Leese

   [182]Add a comment  |
   (BUTTON)
   12
   (BUTTON) (BUTTON)

   One book not yet suggested but very important is [183]"Linkers and
   Loaders" by John Levine. If you're not using an external assembler,
   you'll need a way to output a object file that can be linked into your
   final program. Even if you're using an external assembler, you'll
   probably need to understand relocations and how the whole program
   loading process works to make a working tool. This book collects a lot
   of the random lore around this process for various systems, including
   Win32 and Linux.
   [184]Share
   (BUTTON) Follow
   answered [185]Aug 18, 2008 at 20:18
   community wiki
   [186]Ben Combee

   [187]Add a comment  |
   (BUTTON)
   11
   (BUTTON) (BUTTON)

   [188]The Dragon Book is definitely the "building compilers" book, but
   if your language isn't quite as complicated as the current generation
   of languages, you may want to look at the Interpreter pattern from
   [189]Design Patterns.

   The example in the book designs a regular expression-like language and
   is well thought through, but as they say in the book, it's good for
   thinking through the process but is effective really only on small
   languages. However, it is much faster to write an Interpreter for a
   small language with this pattern than having to learn about all the
   different types of parsers, yacc and lex, et cetera...
   [190]Share
   (BUTTON) Follow
   answered [191]Aug 5, 2008 at 16:16
   community wiki
   [192]Chris Bunch

   [193]Add a comment  |
   (BUTTON)
   11
   (BUTTON) (BUTTON)

   If you're willing to use LLVM, check this out:
   [194]http://llvm.org/docs/tutorial/. It teaches you how to write a
   compiler from scratch using LLVM's framework, and doesn't assume you
   have any knowledge about the subject.

   The tutorial suggest you write your own parser and lexer etc, but I
   advise you to look into bison and flex once you get the idea. They make
   life so much easier.
   [195]Share
   (BUTTON) Follow
   answered [196]Aug 20, 2008 at 10:01
   community wiki
   [197]wvdschel
   1
     * But the documentation for setting it up of Visual Studio is badly
       written, plus no examples
       - user868935
       Oct 2, 2014 at 9:17

   [198]Add a comment  |
   (BUTTON)
   11
   (BUTTON) (BUTTON)

   I found the Dragon book much too hard to read with too much focus on
   language theory that is not really required to write a compiler in
   practice.

   I would add the [199]Oberon book which contains the full source of an
   amazingly fast and simple Oberon compiler [200]Project Oberon.

   Alt text
   [201]Share
   (BUTTON) Follow
   [202]edited Dec 27, 2014 at 12:39
   community wiki
   [203]3 revs, 3 users 73%
   [204]Lothar

   [205]Add a comment  |
   (BUTTON)
   11
   (BUTTON) (BUTTON)

   The LCC compiler ([206]wikipedia) ([207]project homepage)
   ([208]github.com/drh/lcc) of Fraser and Hanson is described in their
   book "A Retargetable C Compiler: Design and Implementation". It is
   quite readable and explains the whole compiler, down to code
   generation.
   [209]Share
   (BUTTON) Follow
   [210]edited Dec 4, 2019 at 14:40
   community wiki
   [211]2 revs, 2 users 75%
   [212]mfx
   1
     * This seems like an extremely good resource thanks.
       - [213]gideon
       Aug 11, 2016 at 15:26

   [214]Add a comment  |
   (BUTTON)
   10
   (BUTTON) (BUTTON)

   I am looking into the same concept, and found this promising article by
   Joel Pobar,

   [215]Create a Language Compiler for the .NET Framework - not sure where
   this has gone

   [216]Create a Language Compiler for the .NET Framework - pdf copy of
   the original doc

   he discusses a high level concept of a compiler and proceeds to invent
   his own langauge for the .Net framework. Although its aimed at the .Net
   Framework, many of the concepts should be able to be reproduced. The
   Article covers:
    1. Langauge definition
    2. Scanner
    3. Parser (the bit im mainly interested in)
    4. Targeting the .Net Framework The
    5. Code Generator

   there are other topics, but you get the just.

   Its aimed to people starting out, written in C# (not quite Java)

   HTH

   bones
   [217]Share
   (BUTTON) Follow
   [218]edited Dec 15, 2018 at 1:04
   community wiki
   [219]2 revs
   [220]dbones
   2
     * What does "not quite Java" mean?
       - [221]Hejazzman
       Apr 25, 2009 at 21:53
     * haha, sorry, i meant its written for .Net, which in principal is
       similar to java. Both are JIT in style. :)
       - [222]dbones
       Apr 28, 2009 at 10:48

   [223]Add a comment  |
   (BUTTON)
   10
   (BUTTON) (BUTTON)

   I remember asking this question about seven years ago when I was rather
   new to programming.

   I was very careful when I asked and surprisingly I didn't get as much
   criticism as you are getting here. They did however point me in the
   direction of the "[224]Dragon Book" which is in my opinion, a really
   great book that explains everything you need to know to write a
   compiler (you will of course have to master a language or two. The more
   languages you know, the merrier.).

   And yes, many people say reading that book is crazy and you won't learn
   anything from it, but I disagree completely with that.

   Many people also say that writing compilers is stupid and pointless.
   Well, there are a number of reasons why compiler development are
   useful:
     * Because it's fun.
     * It's educational, when learning how to write compilers you will
       learn a lot about computer science and other techniques that are
       useful when writing other applications.
     * If nobody wrote compilers the existing languages wouldn't get any
       better.

   I didn't write my own compiler right away, but after asking I knew
   where to start. And now, after learning many different languages and
   reading the Dragon Book, writing isn't that much of a problem. (I'm
   also studying computer engineering atm, but most of what I know about
   programming is self taught.)

   In conclusion, The Dragon Book is a great "tutorial". But spend some
   time mastering a language or two before attempting to write a compiler.
   Don't expect to be a compiler guru within the next decade or so though.

   The book is also good if you want to learn how to write
   parsers/interpreters.
   [225]Share
   (BUTTON) Follow
   [226]edited May 26, 2019 at 23:00
   community wiki
   [227]6 revs, 5 users 68%
   [228]Pandafox
   1
     * We were taught Compilers subject in college with Dragon Book, and i
       can vouch for it, it was one of the best books I've came through
       - [229]cosmoloc
       Sep 12, 2021 at 14:41

   [230]Add a comment  |
   (BUTTON)
   9
   (BUTTON) (BUTTON)

     "... Let's Build a Compiler ..."

   I'd second [231]http://compilers.iecc.com/crenshaw/ by [232]@sasb.
   Forget buying more books for the moment.

   Why? Tools & language.

   The language required is Pascal and if I remember correctly is based on
   Turbo-Pascal. It just so happens if you go to
   [233]http://www.freepascal.org/ and download the Pascal compiler all
   the examples work straight from the page ~
   [234]http://www.freepascal.org/download.var The beaut thing about Free
   Pascal is you can use it almost whatever processor or OS you can care
   for.

   Once you have mastered the lessons then try the more advanced
   "[235]Dragon Book" ~ [236]http://en.wikipedia.org/wiki/Dragon_book
   [237]Share
   (BUTTON) Follow
   [238]edited May 23, 2017 at 11:54
   community wiki
   [239]3 revs
   [240]bootload

   [241]Add a comment  |
   (BUTTON)
   8
   (BUTTON) (BUTTON)

   An easy way to create a compiler is to use bison and flex (or similar),
   build a tree (AST) and generate code in C. With generating C code being
   the most important step. By generating C code, your language will
   automatically work on all platforms that have a C compiler.

   Generating C code is as easy as generating HTML (just use print, or
   equivalent), which in turn is much easier than writing a C parser or
   HTML parser.
   [242]Share
   (BUTTON) Follow
   answered [243]Aug 20, 2008 at 9:56
   community wiki
   [244]Peter Stuifzand

   [245]Add a comment  |
   (BUTTON)
   8
   (BUTTON) (BUTTON)

   From the [246]comp.compilers FAQ:

   "Programming a Personal Computer" by Per Brinch Hansen Prentice-Hall
   1982 ISBN 0-13-730283-5

   This unfortunately-titled book explains the design and creation of a
   single-user programming environment for micros, using a Pascal-like
   language called Edison. The author presents all source code and
   explanations for the step-by-step implementation of an Edison compiler
   and simple supporting operating system, all written in Edison itself
   (except for a small supporting kernel written in a symbolic assembler
   for PDP 11/23; the complete source can also be ordered for the IBM PC).

   The most interesting things about this book are: 1) its ability to
   demonstrate how to create a complete, self-contained, self-maintaining,
   useful compiler and operating system, and 2) the interesting discussion
   of language design and specification problems and trade-offs in Chapter
   2.

   "Brinch Hansen on Pascal Compilers" by Per Brinch Hansen Prentice-Hall
   1985 ISBN 0-13-083098-4

   Another light-on-theory heavy-on-pragmatics here's-how-to-code-it book.
   The author presents the design, implementation, and complete source
   code for a compiler and p-code interpreter for Pascal- (Pascal
   "minus"), a Pascal subset with boolean and integer types (but no
   characters, reals, subranged or enumerated types), constant and
   variable definitions and array and record types (but no packed,
   variant, set, pointer, nameless, renamed, or file types), expressions,
   assignment statements, nested procedure definitions with value and
   variable parameters, if statements, while statements, and begin-end
   blocks (but no function definitions, procedural parameters, goto
   statements and labels, case statements, repeat statements, for
   statements, and with statements).

   The compiler and interpreter are written in Pascal* (Pascal "star"), a
   Pascal subset extended with some Edison-style features for creating
   software development systems. A Pascal* compiler for the IBM PC is sold
   by the author, but it's easy to port the book's Pascal- compiler to any
   convenient Pascal platform.

   This book makes the design and implementation of a compiler look easy.
   I particularly like the way the author is concerned with quality,
   reliability, and testing. The compiler and interpreter can easily be
   used as the basis for a more involved language or compiler project,
   especially if you're pressed to quickly get something up and running.
   [247]Share
   (BUTTON) Follow
   [248]edited Jun 27, 2010 at 19:00
   community wiki
   [249]2 revs
   [250]joe snyder

   [251]Add a comment  |
   (BUTTON)
   8
   (BUTTON) (BUTTON)

   You should check out Darius Bacon's "[252]ichbins", which is a compiler
   for a small Lisp dialect, targeting C, in just over 6 pages of code.
   The advantage it has over most toy compilers is that the language is
   complete enough that the compiler is written in it. (The tarball also
   includes an interpreter to bootstrap the thing.)

   There's more stuff about what I found useful in learning to write a
   compiler on my [253]Ur-Scheme web page.
   [254]Share
   (BUTTON) Follow
   [255]edited Dec 1, 2010 at 12:50
   community wiki
   [256]2 revs, 2 users 89%
   Kragen Javier Sitaker

   [257]Add a comment  |
   (BUTTON)
   7
   (BUTTON) (BUTTON)

   Python comes bundled with a python compiler written in Python. You can
   see the source code, and it includes all phases, from parsing, abstract
   syntax tree, emitting code, etc. Hack it.
   [258]Share
   (BUTTON) Follow
   answered [259]Aug 12, 2008 at 11:25
   community wiki
   [260]yeruham

   [261]Add a comment  |
   (BUTTON)
   7
   (BUTTON) (BUTTON)

   Sorry, it is in Spanish, but this is the bibliography of a course
   called "Compiladores e Intérpretes" (Compilers and Interpreters) in
   Argentina.

   The course was from formal language theory to compiler construction,
   and these are the topics you need to build, at least, a simple
   compiler:

     * Compilers Design in C.
       Allen I. Holub
       Prentice-Hall. 1990.
     * Compiladores. Teoría y Construcción.
       Sanchís Llorca, F.J. , Galán Pascual, C. Editorial Paraninfo. 1988.
     * Compiler Construction.
       Niklaus Wirth
       Addison-Wesley. 1996.
     * Lenguajes, Gramáticas y Autómatas. Un enfoque práctico.
       Pedro Isasi Viñuela, Paloma Martínez Fernández, Daniel Borrajo
       Millán. Addison-Wesley Iberoamericana (España). 1997.
     * The art of compiler design. Theory and practice.
       Thomas Pittman, James Peters.
       Prentice-Hall. 1992.
     * Object-Oriented Compiler Construction.
       Jim Holmes.
       Prentice Hall, Englewood Cliffs, N.J. 1995
     * Compiladores. Conceptos Fundamentales.
       B. Teufel, S. Schmidt, T. Teufel.
       Addison-Wesley Iberoamericana. 1995.
     * Introduction to Automata Theory, Languages, and Computation.
       John E. Hopcroft. Jeffref D. Ullman.
       Addison-Wesley. 1979.
     * Introduction to formal languages.
       György E. Révész.
       Mc Graw Hill. 1983.
     * Parsing Techniques. A Practical Guide.
       Dick Grune, Ceriel Jacobs.
       Impreso por los autores. 1995
       [262]http://www.cs.vu.nl/~dick/PTAPG.html
     * Yacc: Yet Another Compiler-Compiler.
       Stephen C. Johnson
       Computing Science Technical Report Nº 32, 1975. Bell Laboratories.
       Murray Hill, New
       Jersey.
     * Lex: A Lexical Analyzer Generator.
       M. E. Lesk, E. Schmidt. Computing Science Technical Report Nº 39,
       1975. Bell Laboratories. Murray Hill, New Jersey.
     * lex & yacc.
       John R. Levine, Tony Mason, Doug Brown.
       O'Reilly & Associates. 1995.
     * Elements of the theory of computation.
       Harry R. Lewis, Christos H. Papadimitriou. Segunda Edición.
       Prentice Hall. 1998.
     * Un Algoritmo Eficiente para la Construcción del Grafo de
       Dependencia de Control.
       Salvador V. Cavadini.
       Trabajo Final de Grado para obtener el Título de Ingeniero en
       Computación.
       Facultad de Matemática Aplicada. U.C.S.E. 2001.

   [263]Share
   (BUTTON) Follow
   [264]edited Feb 28, 2014 at 23:52
   community wiki
   [265]2 revs, 2 users 98%
   [266]eKek0

   [267]Add a comment  |
   (BUTTON)
   7
   (BUTTON) (BUTTON)
    1. This is a vast subject. Do not underestimate this point. And do not
       underestimate my point to not underestimate it.
    2. I hear the [268]Dragon Book is a (the?) place to start, along with
       searching. :) Get better at searching, eventually it will be your
       life.
    3. Building your own programming language is absolutely a good
       exercise! But know that it will never be used for any practical
       purpose in the end. Exceptions to this are few and very far
       between.

   [269]Share
   (BUTTON) Follow
   [270]edited Feb 28, 2014 at 23:54
   community wiki
   [271]2 revs, 2 users 73%
   [272]280Z28
   9
     * 5
       If you haven't read the Dragon book. Please don't recommend it. In
       fact, have you ever implemented a compiler?
       - anon
       Jul 20, 2009 at 22:46
     * Yeah, as the name implies, the Dragon Book is a monster. Very
       in-depth, but a very good resource nonetheless. I wouldn't
       recommend it for beginners, though...
       - [273]Zachary Murray
       Jul 20, 2009 at 22:47
     * 2
       @Neil: You haven't google'd me, have you? lol. [274]blog.280z28.org
       But no, I haven't read that book.
       - [275]Sam Harwell
       Jul 20, 2009 at 22:49
     * I'm reading it (the dragon book) presently, and also Lex/Yacc at
       the same time, I'm finding the book quite good. Personally.
       - [276]Simeon Pilgrim
       Jul 20, 2009 at 22:58
     * 1
       To be fair, I prefaced it with "I hear...". :) #1 and #3 are the
       points I feel are extremely important to know going in but aren't
       mentioned as often.
       - [277]Sam Harwell
       Jul 20, 2009 at 23:07

    |  [278]Show 4 more comments
   (BUTTON)
   6
   (BUTTON) (BUTTON)

   Not a book, but a technical paper and an enormously fun learning
   experience if you want to know more about compilers (and
   metacompilers)... This website walks you through building a completely
   self-contained compiler system that can compile itself and other
   languages:

   [279]Tutorial: Metacompilers Part 1

   This is all based on an amazing little 10-page technical paper:

   Val Schorre META II: A Syntax-Oriented Compiler Writing Language

   from honest-to-god 1964. I learned how to build compilers from this
   back in 1970. There's a mind-blowing moment when you finally grok how
   the compiler can regenerate itself....

   I know the website author from my college days, but I have nothing to
   do with the website.
   [280]Share
   (BUTTON) Follow
   [281]edited Mar 1, 2014 at 0:09
   community wiki
   [282]4 revs, 2 users 77%
   [283]Ira Baxter
   2
     * As others say, is BIG argument, I think sushi a task is a final
       work for bachelor, it requires to know a LOT of concepts of math,
       computer science and so on.
       - [284]ingconti
       Jun 18, 2014 at 6:10
     * If you don't know these topics, you shouldn't really be trying to
       build a serious compiler. However, if you have 2-3 years
       undergraduate computer science education (programming, data
       structures, assembly language), the MetaII paper will work for you.
       - [285]Ira Baxter
       Jun 18, 2014 at 12:23

   [286]Add a comment  |
   (BUTTON)
   6
   (BUTTON) (BUTTON)

   There's a lot of good answers here, so i thought I'd just add one more
   to the list:

   I got a book called Project Oberon more than a decade ago, which has
   some very well written text on the compiler. The book really stands out
   in the sense that the source and explanations is very hands on and
   readable. The complete text (the 2005 edition) has been made available
   in pdf, so you can download right now. The compiler is discussed in
   chapter 12:

   [287]http://www.ethoberon.ethz.ch/WirthPubl/ProjectOberon.pdf

   Niklaus Wirth, Jürg Gutknecht

   (The treatment is not as extensive as his book on compilers)

   I've read several books on compilers, and i can second the dragon book,
   time spent on this book is very worthwhile.
   [288]Share
   (BUTTON) Follow
   [289]edited Dec 4, 2019 at 14:38
   community wiki
   [290]3 revs, 2 users 96%
   [291]tovare

   [292]Add a comment  |
   (BUTTON)
   5
   (BUTTON) (BUTTON)

   I liked the [293]Crenshaw tutorial too, because it makes it absolutely
   clear that a compiler is just another program that reads some input and
   writes some out put.

   Read it.

   Work it if you want, but then look at another reference on how bigger
   and more complete compilers are really written.

   And read [294]On Trusting Trust, to get a clue about the unobvious
   things that can be done in this domain.
   [295]Share
   (BUTTON) Follow
   [296]edited Sep 2, 2008 at 4:52
   community wiki
   [297]2 revs
   [298]dmckee

   [299]Add a comment  |
   (BUTTON)
   5
   (BUTTON) (BUTTON)

   If you are interested in writing a compiler for a functional language
   (rather than a procedural one) Simon Peyton-Jones and David Lester's
   "[300]Implementing functional languages: a tutorial" is an excellent
   guide.

   The conceptual basics of how functional evaluation works is guided by
   examples in a simple but powerful functional language called "Core".
   Additionally, each part of the Core language compiler is explained with
   code examples in Miranda (a pure functional language very similar to
   Haskell).

   Several different types of compilers are described but even if you only
   follow the so-called template compiler for Core you will have an
   excellent understanding of what makes functional programming tick.
   [301]Share
   (BUTTON) Follow
   answered [302]Oct 1, 2008 at 9:30
   community wiki
   [303]Mark Reid

   [304]Add a comment  |
   (BUTTON)
   5
   (BUTTON) (BUTTON)

   You can use [305]BCEL by the Apache Software Foundation. With this tool
   you can generate assembler-like code, but it's Java with the BCEL API.
   You can learn how you can generate intermediate language code (in this
   case byte code).

Simple example

    1. Create a Java class with this function:
public String maxAsString(int a, int b) {
    if (a > b) {
        return Integer.valueOf(a).toString();
    } else if (a < b) {
        return Integer.valueOf(b).toString();
    } else {
        return "equals";
    }
}

   Now run BCELifier with this class
BCELifier bcelifier = new BCELifier("MyClass", System.out);
bcelifier.start();

   You can see the result on the console for the whole class (how to build
   byte code MyClass.java). The code for the function is this:
private void createMethod_1() {
  InstructionList il = new InstructionList();
  MethodGen method = new MethodGen(ACC_PUBLIC, Type.STRING, new Type[] { Type.IN
T, Type.INT }, new String[] { "arg0", "arg1" }, "maxAsString", "MyClass", il, _c
p);

  il.append(InstructionFactory.createLoad(Type.INT, 1)); // Load first parameter
 to address 1
  il.append(InstructionFactory.createLoad(Type.INT, 2)); // Load second paramete
r to adress 2
    BranchInstruction if_icmple_2 = InstructionFactory.createBranchInstruction(C
onstants.IF_ICMPLE, null); // Do if condition (compare a > b)
  il.append(if_icmple_2);
  il.append(InstructionFactory.createLoad(Type.INT, 1)); // Load value from addr
ess 1 into the stack
  il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType
("java.lang.Integer"), new Type[] { Type.INT }, Constants.INVOKESTATIC));
  il.append(_factory.createInvoke("java.lang.Integer", "toString", Type.STRING,
Type.NO_ARGS, Constants.INVOKEVIRTUAL));
  il.append(InstructionFactory.createReturn(Type.OBJECT));
  InstructionHandle ih_13 = il.append(InstructionFactory.createLoad(Type.INT, 1)
);
  il.append(InstructionFactory.createLoad(Type.INT, 2));
    BranchInstruction if_icmpge_15 = InstructionFactory.createBranchInstruction(
Constants.IF_ICMPGE, null); // Do if condition (compare a < b)
  il.append(if_icmpge_15);
  il.append(InstructionFactory.createLoad(Type.INT, 2));
  il.append(_factory.createInvoke("java.lang.Integer", "valueOf", new ObjectType
("java.lang.Integer"), new Type[] { Type.INT }, Constants.INVOKESTATIC));
  il.append(_factory.createInvoke("java.lang.Integer", "toString", Type.STRING,
Type.NO_ARGS, Constants.INVOKEVIRTUAL));
  il.append(InstructionFactory.createReturn(Type.OBJECT));
  InstructionHandle ih_26 = il.append(new PUSH(_cp, "equals")); // Return "equal
s" string
  il.append(InstructionFactory.createReturn(Type.OBJECT));
  if_icmple_2.setTarget(ih_13);
  if_icmpge_15.setTarget(ih_26);
  method.setMaxStack();
  method.setMaxLocals();
  _cg.addMethod(method.getMethod());
  il.dispose();
}

   [306]Share
   (BUTTON) Follow
   [307]edited Mar 1, 2014 at 0:06
   community wiki
   [308]2 revs, 2 users 82%
   [309]timaschew

   [310]Add a comment  |
   (BUTTON)
   4
   (BUTTON) (BUTTON)

   I'm surprised it hasn't been mentioned, but Donald Knuth's The Art of
   Computer Programming was originally penned as a sort of tutorial on
   compiler writing.

   Of course, Dr. Knuth's propensity for going in-depth on topics has led
   to the compiler-writing tutorial being expanded to an estimated 9
   volumes, only three of which have actually been published. It's a
   rather complete exposition on programming topics, and covers everything
   you would ever need to know about writing a compiler, in minute detail.
   [311]Share
   (BUTTON) Follow
   answered [312]Jul 21, 2009 at 0:20
   community wiki
   [313]greyfade

   [314]Add a comment  |
   1
   [315]2 [316]Next

   Not the answer you're looking for? Browse other questions tagged
     * [317]compiler-construction
     * [318]language-agnostic

   or [319]ask your own question.
     * The Overflow Blog
     * [320]Maximum Glitch: How to break Tetris
     * [321]How to build a role-playing video game in 24 hours
     * Featured on Meta
     * [322]Update to our Advertising Guidelines
     * [323]Sites can now request to enable a banner to warn about their
       policy on...
     * [324]Temporary policy: Generative AI (e.g., ChatGPT) is banned

Linked

   37
   [325]create my own programming language
   33
   [326]How to go about making your own programming language?
   15
   [327]How to write a simple compiler in C/++?
   13
   [328]Parsers and Compilers for Dummies. Where to start?
   5
   [329]compiler design
   6
   [330]How would you go about writing a simple programming language?
   7
   [331]What is the process of creating an interpreted language?
   7
   [332]Where to start if I want to understand how compilers and
   programming languages are made
   2
   [333]How can I write a quick and dirty interpreter?
   5
   [334]Help with Compiler Design
   [335]See more linked questions

Related

   639
   [336]What does a just-in-time (JIT) compiler do?
   100
   [337]How to approach creating a JVM programming language?
   7
   [338]Can Coco/R turn a parsed file into bytecode?
   9
   [339]How is a lattice used by a compiler
   4
   [340]Microsoft CCI - resources, references for writing compilers

[341]Hot Network Questions

     * [342]Algorithm needed to find optimum area of 2-dimensional data
       set
     * [343]What happened to Jazz in 1980?
     * [344]What was the standard time in the Principality of Lippe?
     * [345]Conveying 'Get a life'
     * [346]On solving the minimally clued 8x8 Sudoku
     * [347]Is George a dishwasher?
     * [348]How is dividend good for stock/share investors?
     * [349]Do the senses themselves (not what they deceptively reveal)
       exist in some form?
     * [350]Why did my coworker see a "painting-ified" version of my
       background image on a Zoom call?
     * [351]"Perfect" an array
     * [352]Autocommutator subgroup is a characteristic subgroup
     * [353]How to notate free time in MuseScore
     * [354]How to scan pencil drawings to get good dynamic range?
     * [355]Virtualbox 6 stopped working After kernel upgrade in Ubuntu
       22.04
     * [356]Asking a professor for materials before the course
     * [357]Why would I put an ASI into Con instead of taking the Tough
       feat?
     * [358]Why do some journals want to send the manuscript to arXiv
       before submission?
     * [359]If everyone in the Senate is drunk, does that invalidate their
       actions?
     * [360]Professor gets funding and does not give to student
     * [361]Why does Musescore interpret Westergaard's A-flat as G?
       Seeking Clarification on Pitch Spelling
     * [362]Convention: Comma and period in an enumeration
     * [363]How to get coworkers to stop giving me ChatGPT-generated
       suggestions
     * [364]Creating a product integration symbol which behaves as the
       standard integration symbol
     * [365]At what velocity would an object have to fall in order to
       become weightless?

   [366]more hot questions

[367]Stack Overflow

     * [368]Questions
     * [369]Help

[370]Products

     * [371]Teams
     * [372]Advertising
     * [373]Collectives
     * [374]Talent

[375]Company

     * [376]About
     * [377]Press
     * [378]Work Here
     * [379]Legal
     * [380]Privacy Policy
     * [381]Terms of Service
     * [382]Contact Us
     * [383]Cookie Settings
     * [384]Cookie Policy

[385]Stack Exchange Network

     * [386]Technology
     * [387]Culture & recreation
     * [388]Life & arts
     * [389]Science
     * [390]Professional
     * [391]Business
     * [392]API
     * [393]Data

     * [394]Blog
     * [395]Facebook
     * [396]Twitter
     * [397]LinkedIn
     * [398]Instagram

   Site design / logo © 2024 Stack Exchange Inc; user contributions
   licensed under [399]CC BY-SA. rev 2024.1.10.3270

   Your privacy

   By clicking "Accept all cookies", you agree Stack Exchange can store
   cookies on your device and disclose information in accordance with our
   [400]Cookie Policy.
   (BUTTON) Accept all cookies (BUTTON) Necessary cookies only
   (BUTTON) Customize settings

References

   Visible links:
   1. https://stackoverflow.com/opensearch.xml
   2. https://stackoverflow.com/
   3. https://stackoverflow.co/
   4. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
   5. https://stackoverflow.co/teams/
   6. https://stackoverflow.com/questions
   7. https://stackoverflow.co/teams/
   8. https://stackoverflow.co/talent/
   9. https://stackoverflow.co/advertising/
  10. https://stackoverflow.co/labs/
  11. https://stackoverflow.co/
  12. https://stackoverflow.com/
  13. https://stackoverflow.com/help
  14. https://chat.stackoverflow.com/?tab=site&host=stackoverflow.com
  15. https://stackoverflow.com/users/signup?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler
  16. https://stackoverflow.com/users/login?ssrc=site_switcher&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler
  17. https://stackexchange.com/sites
  18. https://stackoverflow.blog/
  19. https://stackoverflow.com/users/login?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler
  20. https://stackoverflow.com/users/signup?ssrc=head&returnurl=https%3a%2f%2fstackoverflow.com%2fquestions%2f1669%2flearning-to-write-a-compiler
  21. https://stackoverflow.com/
  22. https://stackoverflow.com/questions
  23. https://stackoverflow.com/tags
  24. https://stackoverflow.com/users
  25. https://stackoverflow.com/jobs/companies?so_medium=stackoverflow&so_source=SiteNav
  26. https://stackoverflow.com/collectives
  27. https://stackoverflow.com/collectives/beta/discussions
  28. https://try.stackoverflow.co/why-teams/?utm_source=so-owned&utm_medium=side-bar&utm_campaign=campaign-38&utm_content=cta
  29. https://stackoverflow.co/teams/
  30. https://stackoverflow.com/collectives
  31. https://stackoverflow.co/teams/
  32. https://stackoverflow.co/labs/
  33. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
  34. https://stackoverflow.com/questions/ask
  35. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler?lastactivity
  36. https://stackoverflow.com/help/closed-questions
  37. http://meta.stackoverflow.com/q/254394/
  38. https://stackoverflow.com/help/privileges/edit-community-wiki
  39. https://stackoverflow.com/questions/tagged/compiler-construction
  40. https://stackoverflow.com/questions/tagged/language-agnostic
  41. https://stackoverflow.com/q/1669
  42. https://stackoverflow.com/posts/1669/revisions
  43. https://stackoverflow.com/posts/1669/revisions
  44. https://stackoverflow.com/users/340
  45. https://stackoverflow.com/users/293821/a-var
  46. http://mitpress.mit.edu/sicp/
  47. https://stackoverflow.com/users/452102/nishant
  48. http://programmers.stackexchange.com/a/165558/11732
  49. https://stackoverflow.com/users/223424/9000
  50. http://orangejuiceliberationfront.com/how-to-write-a-compiler/
  51. https://stackoverflow.com/users/242278/uliwitness
  52. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler?answertab=scoredesc#tab-top
  53. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler?page=2&tab=scoredesc#tab-top
  54. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler?page=2&tab=scoredesc#tab-top
  55. http://www.cs.indiana.edu/%7Edyb/pubs/nano-jfp.pdf
  56. http://www.amazon.com/gp/offer-listing/1558603204?tag=thecompilerconne&camp=14573&creative=327641&linkCode=am1&creativeASIN=1558603204&adid=1ZQWN5FGBA1JM6MNQ2ZV&
  57. http://scheme2006.cs.uchicago.edu/11-ghuloum.pdf
  58. http://javadude.com/articles/antlr3xtut
  59. http://www.diku.dk/%7Etorbenm/Basics/
  60. http://web.archive.org/web/20160731061607/http://www.onlamp.com/pub/a/onlamp/2004/04/15/parrot_compiler_construction.html
  61. http://www.cs.man.ac.uk/%7Epjj/farrell/compmain.html
  62. https://rads.stackoverflow.com/amzn/click/com/0201403536
  63. https://rads.stackoverflow.com/amzn/click/com/0442275366
  64. https://rads.stackoverflow.com/amzn/click/com/0805321667
  65. http://craftinginterpreters.com/
  66. http://www.holub.com/software/compiler.design.in.c.html
  67. https://rads.stackoverflow.com/amzn/click/com/0321486811
  68. http://en.wikipedia.org/wiki/Compilers:_Principles%2C_Techniques%2C_and_Tools
  69. https://rads.stackoverflow.com/amzn/click/com/012088478X
  70. http://www.cs.indiana.edu/eopl/
  71. http://flipcode.com/archives/articles.shtml
  72. https://rads.stackoverflow.com/amzn/click/com/1931841578
  73. http://www.codeproject.com/KB/recipes/B32Machine1/VMCS.pdf
  74. http://research.microsoft.com/%7Esimonpj/papers/pj-lester-book/
  75. http://www1.digitalgrammars.com/ipl-book/
  76. http://www.codeproject.com/KB/recipes/programminglanguagetoools.aspx
  77. http://en.wikipedia.org/wiki/Interpreter_pattern
  78. https://rads.stackoverflow.com/amzn/click/com/0201633612
  79. http://pragprog.com/titles/tpdsl/language-implementation-patterns
  80. http://compilers.iecc.com/crenshaw/
  81. http://www.stack.nl/%7Emarcov/compiler.pdf
  82. http://books.google.com/books?id=Id9cYsIdjIwC&lpg=PP1&ots=IxFkFWJ-8V&dq=%22linkers%20and%20loaders%22&pg=PA215#v=onepage&q=%22linkers%20and%20loaders%22&f=false
  83. https://rads.stackoverflow.com/amzn/click/com/0521562473
  84. http://llvm.org/docs/tutorial/
  85. https://rads.stackoverflow.com/amzn/click/com/0521607647
  86. https://rads.stackoverflow.com/amzn/click/com/052182060X
  87. https://rads.stackoverflow.com/amzn/click/com/0521607655
  88. http://www.amazon.com/gp/offer-listing/013630740X?tag=thecompilerconne&camp=14573&creative=327641&linkCode=am1&creativeASIN=013630740X&adid=0JPMVBRNCAN6PDKGYSXX&
  89. http://www.dickgrune.com/Books/PTAPG_1st_Edition/
  90. http://www-old.oberon.ethz.ch/WirthPubl/ProjectOberon.pdf
  91. https://rads.stackoverflow.com/amzn/click/com/0137302673
  92. http://www.cs.brown.edu/%7Esk/Publications/Books/ProgLangs/
  93. http://repository.readscheme.org/ftp/papers/ai-lab-pubs/AITR-474.pdf
  94. http://web.archive.org/web/20141221110345/http://cm.bell-labs.com/who/ken/trust.html
  95. http://msdn.microsoft.com/en-us/magazine/cc136756.aspx
  96. http://mitpress.mit.edu/sicp/
  97. http://www.cis.upenn.edu/%7Ebcpierce/tapl/
  98. http://prog21.dadgum.com/30.html
  99. http://www.hokstad.com/writing-a-compiler-in-ruby-bottom-up-step-1.html
 100. https://bernsteinbear.com/blog/compiling-a-lisp-0/
 101. https://stackoverflow.com/a/1672
 102. https://stackoverflow.com/posts/1672/revisions
 103. https://stackoverflow.com/posts/1672/revisions
 104. https://stackoverflow.com/users/340
 105. http://compilers.iecc.com/crenshaw/]
 106. https://stackoverflow.com/users/13198/thevillageidiot
 107. https://www.coursera.org/course/compilers
 108. https://stackoverflow.com/users/505292/quantumkarl
 109. https://www.tutorialspoint.com/compiler_design/index.htm
 110. https://stackoverflow.com/users/1757805/francis-cugler
 111. https://compilers.iecc.com/crenshaw/
 112. https://stackoverflow.com/users/13580938/dimitar-bogdanov
 113. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 114. https://rads.stackoverflow.com/amzn/click/com/0321486811
 115. https://rads.stackoverflow.com/amzn/click/com/1565920007
 116. https://stackoverflow.com/a/1156434
 117. https://stackoverflow.com/posts/1156434/revisions
 118. https://stackoverflow.com/posts/1156434/revisions
 119. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 120. https://rads.stackoverflow.com/amzn/click/com/0521607647
 121. https://rads.stackoverflow.com/amzn/click/com/052182060X
 122. https://rads.stackoverflow.com/amzn/click/com/0521607655
 123. https://rads.stackoverflow.com/amzn/click/com/0201403536
 124. http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf
 125. https://stackoverflow.com/a/7085
 126. https://stackoverflow.com/posts/7085/revisions
 127. https://stackoverflow.com/posts/7085/revisions
 128. https://stackoverflow.com/users/878
 129. http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf
 130. https://stackoverflow.com/users/2310961/matepal297
 131. https://stackoverflow.com/users/1353549/akim
 132. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 133. https://rads.stackoverflow.com/amzn/click/com/1931841578
 134. https://stackoverflow.com/a/1686
 135. https://stackoverflow.com/posts/1686/revisions
 136. https://stackoverflow.com/posts/1686/revisions
 137. https://stackoverflow.com/users/22437/dour-high-arch
 138. https://stackoverflow.com/users/99354/marco-van-de-voort
 139. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 140. http://compilers.iecc.com/crenshaw/
 141. https://www.quora.com/As-a-self-taught-programmer-how-can-I-learn-about-compilers/answer/Akhil-Kooliyatt?srid=TAGM
 142. https://stackoverflow.com/a/1678
 143. https://stackoverflow.com/posts/1678/revisions
 144. https://stackoverflow.com/posts/1678/revisions
 145. https://stackoverflow.com/users/3988992
 146. https://stackoverflow.com/users/106762/a-m0d
 147. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 148. http://www.antlr.org/wiki/display/CS652/CS652+Home
 149. http://www.pragprog.com/titles/tpantlr/the-definitive-antlr-reference
 150. http://www.antlr.org/wiki/display/CS652/C+subset+compiler
 151. http://llvm.org/docs/LangRef.html
 152. https://stackoverflow.com/a/1693
 153. https://stackoverflow.com/posts/1693/revisions
 154. https://stackoverflow.com/posts/1693/revisions
 155. https://stackoverflow.com/users/101
 156. https://stackoverflow.com/users/257418/lynn
 157. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 158. http://www.ethoberon.ethz.ch/WirthPubl/CBEAll.pdf
 159. https://stackoverflow.com/a/3592870
 160. https://stackoverflow.com/posts/3592870/revisions
 161. https://stackoverflow.com/posts/3592870/revisions
 162. https://stackoverflow.com/users/444469
 163. https://stackoverflow.com/users/86604/ingo
 164. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 165. http://tldp.org/HOWTO/Lex-YACC-HOWTO-5.html
 166. http://www.mactech.com/articles/mactech/Vol.16/16.07/UsingFlexandBison/
 167. https://stackoverflow.com/a/1156391
 168. https://stackoverflow.com/posts/1156391/revisions
 169. https://stackoverflow.com/posts/1156391/revisions
 170. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 171. https://stackoverflow.com/a/1158408
 172. https://stackoverflow.com/posts/1158408/revisions
 173. https://stackoverflow.com/posts/1158408/revisions
 174. https://stackoverflow.com/users/23771/mike-dunlavey
 175. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 176. http://www.antlr.org/
 177. http://pragprog.com/titles/tpdsl/language-implementation-patterns
 178. https://stackoverflow.com/a/2853691
 179. https://stackoverflow.com/posts/2853691/revisions
 180. https://stackoverflow.com/posts/2853691/revisions
 181. https://stackoverflow.com/users/105744
 182. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 183. http://books.google.com/books?id=h34d_jr2iikC&dq=%22linkers+and+loaders%22&pg=PP1&ots=IxFkFWJ-8V&sig=GSlclmkezTRL6YYguGJmZsnkM3c&hl=en&sa=X&oi=book_result&resnum=1&ct=result
 184. https://stackoverflow.com/a/15178
 185. https://stackoverflow.com/posts/15178/revisions
 186. https://stackoverflow.com/posts/15178/revisions
 187. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 188. https://rads.stackoverflow.com/amzn/click/com/0321486811
 189. https://rads.stackoverflow.com/amzn/click/com/0201633612
 190. https://stackoverflow.com/a/2523
 191. https://stackoverflow.com/posts/2523/revisions
 192. https://stackoverflow.com/posts/2523/revisions
 193. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 194. http://llvm.org/docs/tutorial/
 195. https://stackoverflow.com/a/17694
 196. https://stackoverflow.com/posts/17694/revisions
 197. https://stackoverflow.com/posts/17694/revisions
 198. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 199. http://en.wikipedia.org/wiki/Oberon_%28programming_language%29
 200. http://www.amazon.de/Project-Oberon-Design-Operating-Compiler/dp/0201544288/ref=sr_1_3?ie=UTF8&s=books-intl-de&qid=1281378762&sr=8-3
 201. https://stackoverflow.com/a/3443032
 202. https://stackoverflow.com/posts/3443032/revisions
 203. https://stackoverflow.com/posts/3443032/revisions
 204. https://stackoverflow.com/users/155082
 205. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 206. http://en.wikipedia.org/wiki/Local_C_compiler
 207. http://www.cs.princeton.edu/software/lcc/
 208. https://github.com/drh/lcc
 209. https://stackoverflow.com/a/74176
 210. https://stackoverflow.com/posts/74176/revisions
 211. https://stackoverflow.com/posts/74176/revisions
 212. https://stackoverflow.com/users/8015
 213. https://stackoverflow.com/users/368070/gideon
 214. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 215. http://msdn.microsoft.com/en-us/magazine/cc136756.aspx
 216. http://msdn.microsoft.com/en-us/magazine/cc136756.aspx
 217. https://stackoverflow.com/a/401786
 218. https://stackoverflow.com/posts/401786/revisions
 219. https://stackoverflow.com/posts/401786/revisions
 220. https://stackoverflow.com/users/47642
 221. https://stackoverflow.com/users/84291/hejazzman
 222. https://stackoverflow.com/users/47642/dbones
 223. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 224. http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools
 225. https://stackoverflow.com/a/1241910
 226. https://stackoverflow.com/posts/1241910/revisions
 227. https://stackoverflow.com/posts/1241910/revisions
 228. https://stackoverflow.com/users/150636
 229. https://stackoverflow.com/users/1993474/cosmoloc
 230. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 231. http://compilers.iecc.com/crenshaw/
 232. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler#1678
 233. http://www.freepascal.org/
 234. http://www.freepascal.org/download.var
 235. http://en.wikipedia.org/wiki/Dragon_book
 236. http://en.wikipedia.org/wiki/Dragon_book
 237. https://stackoverflow.com/a/17768
 238. https://stackoverflow.com/posts/17768/revisions
 239. https://stackoverflow.com/posts/17768/revisions
 240. https://stackoverflow.com/users/2092
 241. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 242. https://stackoverflow.com/a/17690
 243. https://stackoverflow.com/posts/17690/revisions
 244. https://stackoverflow.com/posts/17690/revisions
 245. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 246. http://www.faqs.org/faqs/compilers/faq/
 247. https://stackoverflow.com/a/3125367
 248. https://stackoverflow.com/posts/3125367/revisions
 249. https://stackoverflow.com/posts/3125367/revisions
 250. https://stackoverflow.com/users/357174
 251. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 252. https://github.com/darius/ichbins
 253. http://www.canonical.org/~kragen/sw/urscheme/
 254. https://stackoverflow.com/a/172181
 255. https://stackoverflow.com/posts/172181/revisions
 256. https://stackoverflow.com/posts/172181/revisions
 257. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 258. https://stackoverflow.com/a/8690
 259. https://stackoverflow.com/posts/8690/revisions
 260. https://stackoverflow.com/posts/8690/revisions
 261. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 262. http://www.cs.vu.nl/~dick/PTAPG.html
 263. https://stackoverflow.com/a/789357
 264. https://stackoverflow.com/posts/789357/revisions
 265. https://stackoverflow.com/posts/789357/revisions
 266. https://stackoverflow.com/users/32173
 267. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 268. http://en.wikipedia.org/wiki/Compilers:_Principles,_Techniques,_and_Tools
 269. https://stackoverflow.com/a/1156383
 270. https://stackoverflow.com/posts/1156383/revisions
 271. https://stackoverflow.com/posts/1156383/revisions
 272. https://stackoverflow.com/users/138304
 273. https://stackoverflow.com/users/134547/zachary-murray
 274. http://blog.280z28.org/
 275. https://stackoverflow.com/users/138304/sam-harwell
 276. https://stackoverflow.com/users/43992/simeon-pilgrim
 277. https://stackoverflow.com/users/138304/sam-harwell
 278. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 279. http://www.bayfronttechnologies.com/mc_tutorial.html
 280. https://stackoverflow.com/a/1344367
 281. https://stackoverflow.com/posts/1344367/revisions
 282. https://stackoverflow.com/posts/1344367/revisions
 283. https://stackoverflow.com/users/120163
 284. https://stackoverflow.com/users/927333/ingconti
 285. https://stackoverflow.com/users/120163/ira-baxter
 286. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 287. http://www.ethoberon.ethz.ch/WirthPubl/ProjectOberon.pdf
 288. https://stackoverflow.com/a/98010
 289. https://stackoverflow.com/posts/98010/revisions
 290. https://stackoverflow.com/posts/98010/revisions
 291. https://stackoverflow.com/users/12677
 292. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 293. http://compilers.iecc.com/crenshaw/
 294. http://cm.bell-labs.com/who/ken/trust.html
 295. https://stackoverflow.com/a/22718
 296. https://stackoverflow.com/posts/22718/revisions
 297. https://stackoverflow.com/posts/22718/revisions
 298. https://stackoverflow.com/users/2509
 299. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 300. http://research.microsoft.com/~simonpj/papers/pj-lester-book/
 301. https://stackoverflow.com/a/156867
 302. https://stackoverflow.com/posts/156867/revisions
 303. https://stackoverflow.com/posts/156867/revisions
 304. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 305. http://jakarta.apache.org/bcel/
 306. https://stackoverflow.com/a/6695987
 307. https://stackoverflow.com/posts/6695987/revisions
 308. https://stackoverflow.com/posts/6695987/revisions
 309. https://stackoverflow.com/users/736518
 310. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 311. https://stackoverflow.com/a/1156689
 312. https://stackoverflow.com/posts/1156689/revisions
 313. https://stackoverflow.com/posts/1156689/revisions
 314. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 315. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler?page=2&tab=scoredesc#tab-top
 316. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler?page=2&tab=scoredesc#tab-top
 317. https://stackoverflow.com/questions/tagged/compiler-construction
 318. https://stackoverflow.com/questions/tagged/language-agnostic
 319. https://stackoverflow.com/questions/ask
 320. https://stackoverflow.blog/2024/01/09/maximum-glitch-how-to-break-tetris/
 321. https://stackoverflow.blog/2024/01/11/how-to-build-a-role-playing-video-game-in-24-hours/
 322. https://meta.stackexchange.com/questions/395389/update-to-our-advertising-guidelines
 323. https://meta.stackexchange.com/questions/395881/sites-can-now-request-to-enable-a-banner-to-warn-about-their-policy-on-ai-genera
 324. https://meta.stackoverflow.com/questions/421831/temporary-policy-generative-ai-e-g-chatgpt-is-banned
 325. https://stackoverflow.com/questions/3662410/create-my-own-programming-language?noredirect=1
 326. https://stackoverflow.com/questions/3810119/how-to-go-about-making-your-own-programming-language?noredirect=1
 327. https://stackoverflow.com/questions/3946911/how-to-write-a-simple-compiler-in-c?noredirect=1
 328. https://stackoverflow.com/questions/426239/parsers-and-compilers-for-dummies-where-to-start?noredirect=1
 329. https://stackoverflow.com/questions/1129785/compiler-design?noredirect=1
 330. https://stackoverflow.com/questions/4091887/how-would-you-go-about-writing-a-simple-programming-language?noredirect=1
 331. https://stackoverflow.com/questions/2923287/what-is-the-process-of-creating-an-interpreted-language?noredirect=1
 332. https://stackoverflow.com/questions/6361462/where-to-start-if-i-want-to-understand-how-compilers-and-programming-languages-a?noredirect=1
 333. https://stackoverflow.com/questions/2034221/how-can-i-write-a-quick-and-dirty-interpreter?noredirect=1
 334. https://stackoverflow.com/questions/6865026/help-with-compiler-design?noredirect=1
 335. https://stackoverflow.com/questions/linked/1669
 336. https://stackoverflow.com/questions/95635/what-does-a-just-in-time-jit-compiler-do
 337. https://stackoverflow.com/questions/3380498/how-to-approach-creating-a-jvm-programming-language
 338. https://stackoverflow.com/questions/9554418/can-coco-r-turn-a-parsed-file-into-bytecode
 339. https://stackoverflow.com/questions/2625261/how-is-a-lattice-used-by-a-compiler
 340. https://stackoverflow.com/questions/1380380/microsoft-cci-resources-references-for-writing-compilers
 341. https://stackexchange.com/questions?tab=hot
 342. https://or.stackexchange.com/questions/11506/algorithm-needed-to-find-optimum-area-of-2-dimensional-data-set
 343. https://music.stackexchange.com/questions/133400/what-happened-to-jazz-in-1980
 344. https://history.stackexchange.com/questions/74165/what-was-the-standard-time-in-the-principality-of-lippe
 345. https://french.stackexchange.com/questions/54107/conveying-get-a-life
 346. https://puzzling.stackexchange.com/questions/125072/on-solving-the-minimally-clued-8x8-sudoku
 347. https://literature.stackexchange.com/questions/26019/is-george-a-dishwasher
 348. https://money.stackexchange.com/questions/160886/how-is-dividend-good-for-stock-share-investors
 349. https://philosophy.stackexchange.com/questions/107320/do-the-senses-themselves-not-what-they-deceptively-reveal-exist-in-some-form
 350. https://superuser.com/questions/1825387/why-did-my-coworker-see-a-painting-ified-version-of-my-background-image-on-a-z
 351. https://codegolf.stackexchange.com/questions/269104/perfect-an-array
 352. https://math.stackexchange.com/questions/4842761/autocommutator-subgroup-is-a-characteristic-subgroup
 353. https://music.stackexchange.com/questions/133410/how-to-notate-free-time-in-musescore
 354. https://crafts.stackexchange.com/questions/12022/how-to-scan-pencil-drawings-to-get-good-dynamic-range
 355. https://askubuntu.com/questions/1499756/virtualbox-6-stopped-working-after-kernel-upgrade-in-ubuntu-22-04
 356. https://academia.stackexchange.com/questions/205742/asking-a-professor-for-materials-before-the-course
 357. https://rpg.stackexchange.com/questions/209954/why-would-i-put-an-asi-into-con-instead-of-taking-the-tough-feat
 358. https://academia.stackexchange.com/questions/205735/why-do-some-journals-want-to-send-the-manuscript-to-arxiv-before-submission
 359. https://law.stackexchange.com/questions/98729/if-everyone-in-the-senate-is-drunk-does-that-invalidate-their-actions
 360. https://academia.stackexchange.com/questions/205760/professor-gets-funding-and-does-not-give-to-student
 361. https://music.stackexchange.com/questions/133407/why-does-musescore-interpret-westergaards-a-flat-as-g-seeking-clarification-on
 362. https://academia.stackexchange.com/questions/205709/convention-comma-and-period-in-an-enumeration
 363. https://workplace.stackexchange.com/questions/194969/how-to-get-coworkers-to-stop-giving-me-chatgpt-generated-suggestions
 364. https://tex.stackexchange.com/questions/706882/creating-a-product-integration-symbol-which-behaves-as-the-standard-integration
 365. https://astronomy.stackexchange.com/questions/55714/at-what-velocity-would-an-object-have-to-fall-in-order-to-become-weightless
 366. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 367. https://stackoverflow.com/
 368. https://stackoverflow.com/questions
 369. https://stackoverflow.com/help
 370. https://stackoverflow.co/
 371. https://stackoverflow.co/teams/
 372. https://stackoverflow.co/advertising/
 373. https://stackoverflow.co/collectives/
 374. https://stackoverflow.co/talent/
 375. https://stackoverflow.co/
 376. https://stackoverflow.co/
 377. https://stackoverflow.co/company/press/
 378. https://stackoverflow.co/company/work-here/
 379. https://stackoverflow.com/legal
 380. https://stackoverflow.com/legal/privacy-policy
 381. https://stackoverflow.com/legal/terms-of-service/public
 382. https://stackoverflow.co/company/contact/
 383. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 384. https://stackoverflow.com/legal/cookie-policy
 385. https://stackexchange.com/
 386. https://stackexchange.com/sites#technology
 387. https://stackexchange.com/sites#culturerecreation
 388. https://stackexchange.com/sites#lifearts
 389. https://stackexchange.com/sites#science
 390. https://stackexchange.com/sites#professional
 391. https://stackexchange.com/sites#business
 392. https://api.stackexchange.com/
 393. https://data.stackexchange.com/
 394. https://stackoverflow.blog/?blb=1
 395. https://www.facebook.com/officialstackoverflow/
 396. https://twitter.com/stackoverflow
 397. https://linkedin.com/company/stack-overflow
 398. https://www.instagram.com/thestackoverflow
 399. https://stackoverflow.com/help/licensing
 400. https://stackoverflow.com/legal/cookie-policy

   Hidden links:
 402. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 403. https://stackoverflow.com/
 404. https://meta.stackoverflow.com/
 405. javascript:void(0)
 406. javascript:void(0)
 407. javascript:void(0)
 408. https://stackoverflowteams.com/teams/create/free/?utm_source=so-owned&utm_medium=side-bar&utm_campaign=campaign-38&utm_content=cta
 409. https://stackoverflow.com/posts/1669/timeline
 410. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 411. https://stackoverflow.com/posts/1672/timeline
 412. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 413. https://stackoverflow.com/posts/1156434/timeline
 414. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 415. https://stackoverflow.com/posts/7085/timeline
 416. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 417. https://stackoverflow.com/posts/1686/timeline
 418. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 419. https://stackoverflow.com/posts/1678/timeline
 420. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 421. https://stackoverflow.com/posts/1693/timeline
 422. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 423. https://stackoverflow.com/posts/3592870/timeline
 424. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 425. https://stackoverflow.com/posts/1156391/timeline
 426. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 427. https://stackoverflow.com/posts/1158408/timeline
 428. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 429. https://stackoverflow.com/posts/2853691/timeline
 430. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 431. https://stackoverflow.com/posts/15178/timeline
 432. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 433. https://stackoverflow.com/posts/2523/timeline
 434. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 435. https://stackoverflow.com/posts/17694/timeline
 436. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 437. https://stackoverflow.com/posts/3443032/timeline
 438. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 439. https://stackoverflow.com/posts/74176/timeline
 440. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 441. https://stackoverflow.com/posts/401786/timeline
 442. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 443. https://stackoverflow.com/posts/1241910/timeline
 444. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 445. https://stackoverflow.com/posts/17768/timeline
 446. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 447. https://stackoverflow.com/posts/17690/timeline
 448. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 449. https://stackoverflow.com/posts/3125367/timeline
 450. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 451. https://stackoverflow.com/posts/172181/timeline
 452. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 453. https://stackoverflow.com/posts/8690/timeline
 454. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 455. https://stackoverflow.com/posts/789357/timeline
 456. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 457. https://stackoverflow.com/posts/1156383/timeline
 458. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 459. https://stackoverflow.com/posts/1344367/timeline
 460. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 461. https://stackoverflow.com/posts/98010/timeline
 462. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 463. https://stackoverflow.com/posts/22718/timeline
 464. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 465. https://stackoverflow.com/posts/156867/timeline
 466. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 467. https://stackoverflow.com/posts/6695987/timeline
 468. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 469. https://stackoverflow.com/posts/1156689/timeline
 470. https://stackoverflow.com/questions/1669/learning-to-write-a-compiler
 471. https://stackoverflow.com/q/3662410
 472. https://stackoverflow.com/q/3810119
 473. https://stackoverflow.com/q/3946911
 474. https://stackoverflow.com/q/426239
 475. https://stackoverflow.com/q/1129785
 476. https://stackoverflow.com/q/4091887
 477. https://stackoverflow.com/q/2923287
 478. https://stackoverflow.com/q/6361462
 479. https://stackoverflow.com/q/2034221
 480. https://stackoverflow.com/q/6865026
 481. https://stackoverflow.com/q/95635
 482. https://stackoverflow.com/q/3380498
 483. https://stackoverflow.com/q/9554418
 484. https://stackoverflow.com/q/2625261
 485. https://stackoverflow.com/q/1380380
 486. https://stackoverflow.com/