DogLang is a fun, interpreted programming language I created with syntax inspired by our canine friends. With keywords like bark for printing, wagtail for loops, and sniff for conditionals, it brings a playful approach to coding.
This is an open-source hobby project that welcomes contributors of all experience levels. Whether you're a seasoned developer or just starting out:
- Experiment with the language
- Suggest new "dog-themed" features
- Help improve documentation
- Add new functionality
- Fix bugs
The goal is to create something enjoyable while learning about language design and interpretation. Pull requests and issues are very welcome on GitHub!
DogLang is a programming language with the following components:
- Lexical analyzer (Tokenizer)
- Syntax analyzer (Parser)
- Semantic analyzer
- Symbol table for variable management
- Interpreter for code execution
- Variable assignments
- Arithmetic operations
- Conditional statements (sniff)
- Loop constructs (wagtail)
- Print statements (bark)
- Input (fetch)
- Comparison operators
a = 10;
bark(variable_name);
wagtail(condition) {
// loop body
}
sniff(condition) {
// if true
} else {
// if false
}
a = fetch("Enter a value:");
a = 0;
wagtail(a<100) {
bark(a);
a = a+10;
}
This program initializes a variable a to 0, then loops while a is less than 100, printing the value of a and incrementing it by 10 each iteration.
a = 10;
sniff(a%2==0) {
bark("Even");
} else {
bark("Odd");
}
This program checks if variable a is even or odd and prints the result.
a = fetch("Enter the number");
wagtail(a<10) {
bark(a);
a = a+1;
}
This program asks the user for a number and then counts from that number up to 10.
Clone this repository to your local machine:
git clone https://github.com/pallavrai/doglang.git
cd doglang
pip install .
Install DogLang directly using pip:
pip install doglang
-
From a file:
doglang -f your_program.doggy -
Directly from the command line:
doglang -e "a=10; bark(a);"
- To view the tokens generated from your code:
doglang -f your_program.doggy --tokens
DogLang programs use the .doggy file extension.
bark: Print a valuewagtail: Loop constructsniff: Conditional statementfetch: Input from userelse: Alternative branch for conditionals
- Arithmetic:
+,-,*,/,% - Comparison:
==,!=,>,<,>=,<= - Assignment:
=
- Each statement should end with a semicolon (optional in some contexts)
- Blocks of code are enclosed in curly braces
{} - Variables don't need type declarations - they're inferred automatically
- Currently only supports integer and string data types
- No function definitions
- Limited error reporting
Tokenizer.py: Lexical analyzerSyntaxAnalyser.py: ParserSemanticAnalyser.py: Semantic analyzermain.py: Interpreter implementationSymbolTable.py: Symbol table for variable management
