Morse Code Translator
A two-way Morse code encoder/decoder — lexical analysis in Flex, logic in C, compiled to WebAssembly and wired into a browser frontend.
Try It Live
Type in either direction — this runs the same encode/decode logic as the shipped tool, right here in the page.
Case File
Three angles on the same build — click through.
Most Morse code tools online are either a one-way encoder or a one-way decoder — few handle both directions cleanly, and even fewer expose the actual lexical parsing logic behind the translation instead of just doing a lookup-table swap.
The goal was to build it properly: real tokenization of input (whether text or dot-dash sequences), not a glorified find-and-replace — and to do the heavy logic in a systems language, not JavaScript, then bring it to the browser.
- Flex (Lex) for Lexical Analysis — tokenizes input text and Morse sequences using proper lexer rules, recognizing character boundaries and dot-dash patterns the way a compiler front-end would, rather than manually splitting strings.
- Core Logic in C — the actual encoding/decoding runs in C for fast, low-level token processing — deliberately chosen over doing the logic in JavaScript to keep the translation layer language-agnostic and portable.
- Compiled to WebAssembly — the C/Flex logic compiles to WASM so it runs directly in the browser, at near-native speed, with no backend server needed for translation.
- Thin JS/HTML Frontend — a simple interface that calls into the WebAssembly module for real-time translation as you type, keeping the browser layer as thin as possible since all real logic lives in the compiled module.
A fully client-side Morse translator — no server round-trip needed, since the C logic runs directly in-browser via WebAssembly. Supports both encoding (text → Morse) and decoding (Morse → text) through the same interface.
The real value of this project wasn't the translation table — it was learning the actual compiler-adjacent toolchain: lexing with Flex, writing portable C, and shipping it to a browser via WASM instead of defaulting to JavaScript for everything.
Lexer Rules, Simplified
A rough sketch of how Flex tokenizes input before the C logic ever sees it.
Stack
Click any tag to see how it's actually used in this project.
Click any technology above to see exactly how it's used in this build.