Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
62 changes: 60 additions & 2 deletions .env.example
Original file line number Diff line number Diff line change
@@ -1,3 +1,61 @@
PRINT_COMMAND="Your Print Command!"
VARIABLE_DECLARE="Your Variable declaration Command!"
PRINT_COMMAND=print
VARIABLE_DECLARE=var

# Customizable keyword mappings
KEYWORD_PRINT=show
KEYWORD_IF=when
KEYWORD_ELSE=otherwise
KEYWORD_WHILE=repeat
KEYWORD_FOR=loop
KEYWORD_FUNCTION=def
KEYWORD_RETURN=give
KEYWORD_BREAK=stop
KEYWORD_CONTINUE=skip
KEYWORD_AND=also
KEYWORD_OR=either
KEYWORD_NOT=negate
KEYWORD_TRUE=yes
KEYWORD_FALSE=no
KEYWORD_NONE=nothing
KEYWORD_VAR=let

# Custom Error Messages
# You can override any error message by uncommenting and modifying these lines

# Syntax Errors
#ERROR_SYNTAX_GENERIC="🦆 Oops! Your code has a syntax error at line {line}"
#ERROR_MISSING_BRACKET="🦆 Missing a {bracket_type} at line {line}. Every duck needs its pair!"
#ERROR_INVALID_TOKEN="🦆 Found an unexpected {token} at line {line}. That's not duck-friendly!"
#ERROR_UNEXPECTED_TOKEN="🦆 Found a {token} where it shouldn't be at line {line}. Ducks like order!"
#ERROR_INVALID_INDENTATION="🦆 Your code's indentation at line {line} is making ducks dizzy!"

# Runtime Errors
#ERROR_DIVISION_BY_ZERO="🦆 Even ducks know you can't divide by zero!"
#ERROR_UNDEFINED_VAR="🦆 Can't find the variable '{var_name}'. Did it fly away?"
#ERROR_TYPE_MISMATCH="🦆 Expected a {expected_type} but got a {actual_type}. Ducks of a feather..."
#ERROR_INDEX_OUT_OF_RANGE="🦆 Index {index} is out of the pond! Maximum is {max_index}"
#ERROR_STACK_OVERFLOW="🦆 Too many nested ducks! They're starting to pile up!"

# Function Errors
#ERROR_UNDEFINED_FUNCTION="🦆 The function '{func_name}' is MIA (Missing In Action)!"
#ERROR_INVALID_ARGUMENTS="🦆 Expected {expected} ducks, but got {actual}. Count them again!"
#ERROR_RECURSION_LIMIT="🦆 Your ducks are going in circles! Time to break the loop"

# Type Errors
#ERROR_TYPE_CONVERSION="🦆 Can't transform a {from_type} into a {to_type}. Magic has limits!"
#ERROR_INVALID_OPERATION="🦆 Can't {operation} with {type1} and {type2}. They don't mix!"
#ERROR_NULL_REFERENCE="🦆 Found an empty nest where a value should be!"

# IO Errors
#ERROR_FILE_NOT_FOUND="🦆 The file '{file}' is playing hide and seek... and winning!"
#ERROR_PERMISSION_DENIED="🦆 No access to '{file}'. This pond is private!"
#ERROR_IO_ERROR="🦆 Duck communication error: {details}"

# Configuration
#ERROR_INVALID_KEYWORD="🦆 The keyword '{keyword}' isn't in the duck dictionary!"
#ERROR_DUPLICATE_KEYWORD="🦆 '{keyword}' is already used for {existing_use}. Ducks need unique names!"
#ERROR_INVALID_CONFIG="🦆 Your duck configuration is invalid: {details}"

# Import/Module
#ERROR_MODULE_NOT_FOUND="🦆 Can't find the module '{module}'. Is it hiding?"
#ERROR_CIRCULAR_IMPORT="🦆 Your imports are going in circles! Ducks are getting dizzy!"
47 changes: 47 additions & 0 deletions custom_program.duck
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Function definition using 'def' instead of 'function'
def factorial(n) {
# Using 'when' instead of 'if'
when n < 0 {
give 0
}

when n <= 1 {
give 1
}

let result = 1
let counter = n

# Using 'repeat' instead of 'while'
repeat counter > 1 {
result = result * counter
counter = counter - 1
}

give result
}

# Using 'let' instead of 'var'
let numbers = [1, 2, 3, 4, 5]

# Using 'show' instead of 'print'
show "Testing custom keywords!"

# Using 'when/otherwise' instead of 'if/else'
when 5 > 3 {
show "5 is greater than 3"
} otherwise {
show "This won't be shown"
}

# Test logical operators
let x = yes # Using 'yes' instead of 'true'
let y = no # Using 'no' instead of 'false'

when x also negate y { # Using 'also' instead of 'and', 'negate' instead of 'not'
show "Logic works!"
}

show "Factorial of 5 is:"
let result = factorial(5)
show result
Loading