Skip to content

hkokk1234/TabloidParserCompiler

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Tabloid Parser & Python Transpiler

A small ANTLR-based toolchain that parses the tabloid-inspired "Tabloid" language and emits runnable Python. Use it to showcase language tooling: a custom grammar, generated parser/lexer, and a listener that translates constructs to clean Python.

Project Layout

Quick Start

  1. Ensure ANTLR is on the classpath (example uses antlr-4.13.1-complete.jar).
  2. Compile Java sources:
    javac -cp ".:antlr-4.13.1-complete.jar" Tabloid*.java
  3. Convert a Tabloid program to Python:
    java -cp ".:antlr-4.13.1-complete.jar" Tabloid2Python sample1.tbd
  4. Run the generated Python:
    python3 sample1.py

Language Highlights

  • Dramatic keywords (e.g., WHAT IF, STAY TUNED WHILE, SHOCKING DEVELOPMENT) mapped to familiar Python control flow.
  • Functions with DISCOVER HOW TO ... WITH ... RUMOR HAS IT ... END OF STORY.
  • Boolean and arithmetic comparisons (SMALLER THAN, BEATS, IS ACTUALLY, etc.) lowered to Python operators.
  • Simple input/output helpers (YOU WON'T WANT TO MISS, TELL ME, LATEST NEWS ON).

Regenerating the Parser

If you tweak Tabloid.g4, regenerate the lexer and parser:

antlr4 Tabloid.g4 -visitor -listener
javac -cp ".:antlr-4.13.1-complete.jar" Tabloid*.java

Notes for Portfolio Reviewers

  • Samples exercise functions, recursion, conditionals, loops, arithmetic, logic, and user input.
  • The transpiler now renders properly spaced Python with accurate operators and else-handling, keeping the generated code readable.

About

A parser and compiler for the Tabloid programming language, built using ANTLR4. The project translates Tabloid source code (.tbd) into Python code and includes sample programs and grammar definitions. Implemented in Java.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors