Spider-Man hanging upside down
FIG. 07

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.

ROLE
Solo Developer
TIMELINE
Feb 2025 – Apr 2025
TYPE
Systems / Web Tool
STATUS
Complete
2
DIRECTIONS: ENCODE + DECODE
0
SERVER ROUND-TRIPS
C
CORE LOGIC LANGUAGE
WASM
RUNS DIRECTLY IN BROWSER

Try It Live

Type in either direction — this runs the same encode/decode logic as the shipped tool, right here in the page.

Separate letters with a space, words with " / " when typing Morse to decode.

Case File

Three angles on the same build — click through.

// WHY THIS NEEDED BUILDING

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.

// HOW IT WAS PUT TOGETHER
  • 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.
// WHAT SHIPPED

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.

// text mode: tokenize characters
[A-Za-z] { return CHAR_TOKEN; }
[ \t] { return WORD_BREAK; }
 
// morse mode: tokenize dot-dash sequences
[.-]+ { return MORSE_TOKEN; }
" / " { return WORD_BREAK; }

Stack

Click any tag to see how it's actually used in this project.

SELECT A TAG

Click any technology above to see exactly how it's used in this build.

← Project on B&B Ticket Resale Platform →