So you're making a new programming language

Language design

Artistic

- How does it feel to use?

 

- Can I express my thoughts in new ways?

Technical

- What problems does it solve?

 

- What are the novelities (potential innovations)?

Syntax

The compiler

Flow

The syntax tree

Expressions

Tokens

Tokens

PushToStack

Whitespace

Number

Name

NewLine

Comment

Lexer

Character State State change
<start> Ready
"#" Ready Read PushToStack { # }
" " Reading whitespace
"1" Reading number Read Whitespace { " " }
"0" Reading number
" " Reading whitespace Read number { 10 }
"%" Reading comment Read Whitespace { " " }

Lexer

Character State State change
"%" Reading comment Read Whitespace { " " }
" " Reading comment
"p" Reading comment
"u" Reading comment
"s" Reading comment
"h" Reading comment
"\n" Ready Read Comment { "% push" }

Lexer

Running...

Tokens

Token
PushToStack
Number { value: 10 }
Comment { value: "push" }
Newline { value: "\n" }
Name { value: "print" }
Newline { value: "\n" }

Expressions

PushToStack

Number

FunctionCall

Parsing

Parsing

Interpreter

- Runtime

- Evaluate one line at a time

- Usually run-until-error

- Usually slower

Compiler

- Errors (mostly) exist in data or compiler, not code

- Consider entire program

- Usually faster, due to optimizations

Generators just each use one branch at a time

...until you've generated everything

Tooling

Syntax highlighting

Auto-formatting

Auto Format

Inline-errors

Editor support (LSP)

On hover

Editor support (LSP)

Autocomplete

vscode - run file

Native code

Intepreted + debug

Playground

Repl

Once you have an AST, you can do anything

1 hour to think

3 hours for MVP

1 hour for LSP
1 hour for Playground

3 hours to compile to native
3 hours to debug

 

It's not as hard as you think

 

 https://github.com/eeue56/tegan-lang 

So you're making a new programming language

By Noah Hall

So you're making a new programming language

  • 81