From: Chris Lattner Date: Tue, 6 Nov 2007 06:32:18 +0000 (+0000) Subject: edits X-Git-Url: http://demsky.eecs.uci.edu/git/?a=commitdiff_plain;h=4134c2821f1b09550d882d6204f6637c7a7d794b;p=oota-llvm.git edits git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@43758 91177308-0d34-0410-b5e6-96231b3b80d8 --- diff --git a/docs/tutorial/LangImpl1.html b/docs/tutorial/LangImpl1.html index ee097ff6bfd..077575fe119 100644 --- a/docs/tutorial/LangImpl1.html +++ b/docs/tutorial/LangImpl1.html @@ -38,8 +38,8 @@

Welcome to the "Implementing a language with LLVM" tutorial. This tutorial runs through the implementation of a simple language, showing how fun and easy it can be. This tutorial will get you up and started as well as help to -build a framework you can extend to other languages, allowing you to use this -as a way to start playing with other LLVM specific things. +build a framework you can extend to other languages. The code in this tutorial +can also be used as a playground to hack on other LLVM specific things.

@@ -59,8 +59,8 @@ use the code as a basis for future projects, fixing these deficiencies shouldn't be hard.

I've tried to put this tutorial together in a way that makes chapters easy to -skip over if you are already familiar or are uninterested with various pieces. -The structure of the tutorial is: +skip over if you are already familiar with or are uninterested in the various +pieces. The structure of the tutorial is:

-

By the end of the tutorial, we'll have written about 700 lines of -non-comment, non-blank lines of code. With this small amount of code, we'll +

By the end of the tutorial, we'll have written a bit less than 700 lines of +non-comment, non-blank, lines of code. With this small amount of code, we'll have built up a very reasonable compiler for a non-trivial language including a hand-written lexer, parser, AST, as well as code generation support with a JIT compiler. While other systems may have interesting "hello world" tutorials, @@ -115,8 +115,9 @@ LLVM and why you should consider it if you're interested in language or compiler design.

A note about this tutorial: we expect you to extend the language and play -with it on your own. Take the code and go crazy hacking away at it. It can be -a lot of fun to play with languages! In any case, lets get into the code!

+with it on your own. Take the code and go crazy hacking away at it, compilers +don't need to be scary creatures - it can be a lot of fun to play with +languages!

@@ -127,7 +128,8 @@ a lot of fun to play with languages! In any case, lets get into the code!

This tutorial will be illustrated with a toy language that we'll call -"Kaleidoscope". +"Kaleidoscope" (derived +from "meaning beautiful, form, and view"). Kaleidoscope is a procedural language that allows you to define functions, use conditionals, math, etc. Over the course of the tutorial, we'll extend Kaleidoscope to support the if/then/else construct, a for loop, user defined @@ -169,9 +171,11 @@ atan2(sin(.4), cos(42))

-

A more interesting example is included in Chapter 6 where we show the code -used to implement a Mandelbrot Set viewer -in Kaleidoscope.

+

A more interesting example is included in Chapter 6 where we write a little +Kaleidoscope application that displays +a Mandelbrot Set at various levels of magnification.

+ +

Lets dive into the implementation of this language!

@@ -210,7 +214,7 @@ static double NumVal; // Filled in if tok_number

Each token returned by our lexer will either be one of the Token enum values -or it will be an 'unknown' character like '+', which is returned as its ascii +or it will be an 'unknown' character like '+', which is returned as its ASCII value. If the current token is an identifier, the IdentifierStr global variable holds the name of the identifier. If the current token is a numeric literal (like 1.0), NumVal holds its value. Note that we use @@ -298,9 +302,9 @@ if you typed in "1.23". Feel free to extend it :). Next we handle comments:

We handle comments by skipping to the end of the line and then return the -next comment. Finally, if the input doesn't match one of the above cases, it is -either an operator character like '+' or the end of the file. These are handled with -this code:

+next token. Finally, if the input doesn't match one of the above cases, it is +either an operator character like '+' or the end of the file. These are handled +with this code: