![]() This is where photographing real features is different from looking at a toy kaleidoscope where there is a tube, a triangular prism of mirrors and coloured pieces of plastic at the end. ![]() Saying this, the reverse challenge is to create an image which has rotational symmetry. In the photo below, you can use a mirror to clarify that the symmetry is indeed reflective rather than rotational. Photographing my dog gave the best illustration of the difference. But unless you target your feature carefully, it is unlikely to have rotational symmetry, even if the original feature has – as indicated by this lifebuoy station which has a rotational symmetry of 2. There will always be 3 lines of reflective symmetry. Also, there are more challenging activities to undertake which are probably suited to children in older classes.įor example, does the kaleidoscope app create photos which have rotational or reflective symmetry? This will really test a child’s peers of observation and understanding of rotational symmetry. For young children, this is the level I would be working at.Īs well as learning about photography and seeing features in a different way, other useful discussions may arise. With classes, group of children can have fun creating “pairs” of objects for others to match up or to play “snap” with. As I was at the beach, I went around photographing different features in a normal frame and a kaleidoscope one.Įven the most mundane features take on a new form and life when photographed through the kaleidoscope feature. is Number Expression.I decided to undertake a very simple “Guess the Feature” activity. Though, before diving into the parser, we need to implement AST nodes, that we can use during parsing.īasic block of each AST node is ExprAST node, which is stored under ast/ExprAST.h file.Īll other nodes are extends from ExprAST node.Įach of AST nodes must implement one method - codegen().Ĭodegen() method is responsible for generating LLVM IR, using LLVM IRBuilder API, that's all.Īs you can see in ast folder, we have implemented the following AST nodes with appropriate code generation into LLVM IR:Įach of these nodes have a constructor where all mandatory values are initialized.īased on that information, codegen() can build LLVM IR, usine these values. So, basically, gettok function reads characters and returns numbers (tokens).įurther, we can use these tokens in parser (semantic analysis). The actual reading of a stream is implemented in lexer/lexer.cpp file.įunction gettok reads characters one-by-one from stdin and groups them in tokens. This way, we can identify tokens through lexical analysis. Tokens are just an enum structure, which consists of token identifier and a number assigned to this token. Tokens identifiers are stored under lexer/token.h file and lexer implementation under lexer/lexer.cpp file. Lexical analysis is the process of separating a stream of characters into different words, which in computer science we call 'tokens'. Lexer is responsible for getting a stream of chars and translating it into a groups of tokens.Ī lexer is a software program that performs lexical analysis. If you dig in and use the code as a basis for future projects, fixing these deficiencies shouldn’t be hard. In practice, this means that we’ll take a number of shortcuts to simplify the exposition.įor example, the code uses global variables all over the place, doesn’t use nice design patterns like visitors, etc. ![]() It is useful to point out ahead of time that this tutorial is really about teaching compiler techniques and LLVM specifically, not about teaching modern and sane software engineering principles. This will let us cover a fairly broad range of language design and LLVM-specific usage issues, showing and explaining the code for it all along the way, without overwhelming you with tons of details up front. ![]() The goal of this tutorial is to progressively unveil our language, describing how it is built up over time. The code in this tutorial can also be used as a playground to hack on other LLVM specific things. This tutorial will get you up and started as well as help to build a framework you can extend to other languages. This tutorial runs through the implementation of a simple language, showing how fun and easy it can be. That's why I've started official LLVM tutorial - Kaleidoscope. I'm interested in LLVM and want to try simple things with it. Brew install This should bring up a simple REPL. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |