Download presentation
Presentation is loading. Please wait.
Published byΆρχιππος Πολίτης Modified over 5 years ago
1
A Quest for a Statically Typed Embeddable Programming Language
Project Fox A Quest for a Statically Typed Embeddable Programming Language Pierre van Houtryve
2
The Rabbit Hole Introduction:
(Illustration Source: )
3
Fox Learning Project Statically Typed
End goal: Embeddability in other Applications Fox should be interoperable with C++ (Not an official logo, just an illustration . Source: )
4
How it’s Made: Compiler and Interpreters
(LLVM Logo)
5
The Lexer func foo(y: int) { let x: int = 3; }
Source Kind Location “func” FuncKw 1:1-1-4 “foo” Identifier 1:6-1:8 “(“ LParen 1:9-1:9 “y” 1:10-1:10 “:” Colon 1:11-1:11 “int” IntKw 1:13-1:15 “)” RParen 1:16-1:16 “{“ LBrace 1:18-1:18 “let” LetKw 2:3-2:5 … Converts the source code into tokens
6
IntegerLiteralExpr Value : 3
Source Kind Location “func” FuncKw 1:1-1-4 “foo” Identifier 1:6-1:8 “(“ LParen 1:9-1:9 “y” 1:10-1:10 “:” Colon 1:11-1:11 “int” IntKw 1:13-1:15 “)” RParen 1:16-1:16 “{“ LBrace 1:18-1:18 “let” LetKw 2:3-2:5 … The Parser Consumes the tokens and produces the Abstract Syntax Tree (AST) FuncDecl Identifier: “foo” CompoundStmt Size: 1 VarDecl Type: “int” Identifier: “x” IntegerLiteralExpr Value : 3 ParamDecl Identifier: “y”
7
IntegerLiteralExpr Value : 3
FuncDecl Identifier: “foo” CompoundStmt Size: 1 VarDecl Type: “int” Identifier: “x” IntegerLiteralExpr Value : 3 ParamDecl Identifier: “y” Semantic Analysis Checks the language’s semantics Optional, mostly done in statically typed languages Analyzes the AST, searching for errors, inconsistencies, etc.
8
IntegerLiteralExpr Value : 3
FuncDecl Identifier: “foo” CompoundStmt Size: 1 VarDecl Type: “int” Identifier: “x” IntegerLiteralExpr Value : 3 ParamDecl Identifier: “y” Code Generation Generates something from the AST Another existing programming language E.g. TypeScript (JavaScript) An Intermediate Representation E.g. Clang (LLVM IR), Swift (SIL) Bytecode for a Virtual Machine E.g. Java (JVM BC), Fox (Fox VM BC) Machine Code
9
How do you write one? Trial and Error of course!
FuncDecl Identifier: “foo” CompoundStmt Size: 1 VarDecl Type: “int” Identifier: “x” IntegerLiteralExpr Value : 3 ParamDecl Identifier: “y” The AST Usually the first representation of the code built by the compiler/interpreter A basic version is trivial to write, but it can get really complicated really fast as new language features are added. How do you write one? Trial and Error of course!
10
Trial and Error Everywhere!
Not the fastest way of doing things, but you learn a lot!
11
Conclusion Progress on Fox is slow, but I enjoy the journey because I learn a lot! Fox: A statically typed interpreted programming language Learning Project Relatively limited feature set, not really usable in its current state GitHub:
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.