Skip to content

mizukmb/my-compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

19 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

my-compiler

Compiling for Original language.

Usage

language statement.

if ( 10 == 1 + 9 ) {
  10
}

Run.

require './lexer.rb'
require './parser.rb'

str = <<EOF
if ( 10 == 1 + 9 ) {
  10
}
EOF

# lexer
lex = MyLexer.new(str).run

# parser
p MyParser.new(lex).run # => ["if", ["==", ["lit", 10], ["+", ["lit", 1], ["lit", 9]]], ["lit", 10]]

functions

  • Number literal 1
  • String "foo"
  • Calculation 10 + 20 * 30 / 40
    • +, -, *, /, %
  • if
if ( ... ) {
  ...
}
  • multi line
10 + 20
if ( 100 = 100 ) {
  "OK"
}
  • else
  • elseif
  • for
  • variable
  • function
  • and more... 😇

Presentation Materials

here ( Japanese ) -> 雰囲気でコンパイラを書いたら大変だった話 - Speaker Deck

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages