Skip to content

(work in progress) A recursive descent compiler (LL(1)) written in Swift

License

Notifications You must be signed in to change notification settings

noahbass/compiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

compiler-project

MIT license Build Status

(work in progress) A recursive descent compiler (LL(1)) written in Swift

Goals

  • Write in Swift
  • LL lookahead 1
  • Use no existing Swift features for creating compiler subsystems (no regular expressions, etc.)
  • Use finite automata for the scanner
    • Explore DFAs "in parallel" with dovetailing
    • Further down the line, look into using multi-threading in Swift to explore the DFAs in parallel

Using the compiler

$ swift build
$ ./.build/debug/compilerprojectexecutable filename.src

Testing the compiler

$ swift test

Compiler Details

1. Scanner

The scanner (or lexical analyzer) is written as many Deterministic Finite Automaton (DFA) machines, all explored in parallel until one accepts or none accept (marked as an unknown token). The scanner produces a stream of tokens.

This approach to the writing the scanner is definitely not as time efficient as writing a single large DFA, but it was still interesting to implement.

License

MIT

About

(work in progress) A recursive descent compiler (LL(1)) written in Swift

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages