Skip to content

Commit

Permalink
Merge pull request #16 from Puskar-Roy/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
Puskar-Roy authored Feb 26, 2025
2 parents 7276e31 + 0591674 commit c9736b0
Show file tree
Hide file tree
Showing 13 changed files with 753 additions and 883 deletions.
237 changes: 237 additions & 0 deletions ducklangweb
Original file line number Diff line number Diff line change
@@ -0,0 +1,237 @@
/*index.html*/
Basic web page of ducklang
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>DuckLang - The Fun Programming Language</title>
<link rel="stylesheet" href="styles.css">
</head>
<body>

<!-- Header Section -->
<header>
<h1>DuckLang ✨</h1>
<img src="https://th.bing.com/th/id/OIP.tBSugepmJgGcWMXErnmgZAHaHa?w=180&h=180&c=7&r=0&o=5&pid=1.7" width="200" height="200">


<p>Welcome to DuckLang, the quirky and fun programming language that makes coding a laugh-out-loud experience!</p>
</header>

<!-- Overview Section -->
<section id="overview">
<h2>What is DuckLang?</h2>
<p>DuckLang is a playful and engaging programming language designed to engage young developers with its humorous syntax. A unique blend of Bengali, Hindi, and English makes coding fun and easy to understand!</p>
<p>Get ready to code like never before, where coding meets comedy!</p>
</section>

<!-- Installation Section -->
<section id="installation">
<h2>How to Install DuckLang</h2>
<p>Follow these steps to get DuckLang up and running on your machine:</p>
<ul>
<li>Ensure Python and Git are installed on your machine.</li>
<li>Change permissions for the setup script:</li>
<pre><code>chmod +x setup.sh</code></pre>
<li>Run the setup script to set up the project:</li>
<pre><code>./setup.sh</code></pre>
<li>Start the project:</li>
<pre><code>python main.py</code></pre>
</ul>
<p>For more details, check the guidebook!</p>
</section>

<!-- Getting Started Section -->
<section id="getting-started">
<h2>Getting Started with DuckLang</h2>
<p>Here’s your chance to write your first DuckLang program! Start by writing some funny code and experience the humor of DuckLang syntax.</p>
<p>Check out our documentation to begin coding with DuckLang and discover how its language and syntax make programming enjoyable!</p>
<a href="main.py">Explore the Docs</a>
</section>

<!-- Contribution Section -->
<section id="contribution">
<h2>Contribute to DuckLang</h2>
<p>We welcome contributions to DuckLang! Please refer to the <a href="readme.md">README.md</a> file for guidelines on how to contribute.</p>
<p>Remember to always push your changes to the `dev` branch!</p>
</section>

<!-- Contact Section -->
<section id="contact">
<h2>Contact</h2>
<p>If you have any questions or feedback, feel free to open an issue or contact the project maintainer.</p>
<p>Show some love by starring the repository!</p>
<p>Maintainer: Puskar Roy 🖋️</p>
</section>

<!-- Footer Section -->
<footer>
<p>&copy; 2025 DuckLang | All rights reserved.</p>
</footer>

</body>
</html>
//style.css of web page of ducklang
/* General Reset */
* {
margin: 0;
padding: 0;
box-sizing: border-box;
}

/* Body and Font Settings */
body {
font-family: Arial, sans-serif;
background-color: #f8f9fa;
color: #333;
line-height: 1.6;
}

/* Header Section */
header {
text-align: center;
padding: 40px;
background-color: #ffcc00;
color: white;
}

header h1 {
font-size: 2.5em;
margin-bottom: 10px;
}

/* Overview Section */
#overview {
padding: 30px;
background-color: #fff;
margin: 20px auto;
max-width: 900px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#overview h2 {
font-size: 2em;
color: #ffcc00;
}

#overview p {
font-size: 1.2em;
margin-bottom: 20px;
}

/* Installation Section */
#installation {
padding: 30px;
background-color: #f9f9f9;
margin: 20px auto;
max-width: 900px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#installation h2 {
font-size: 2em;
color: #ffcc00;
}

#installation ul {
list-style-type: none;
margin-top: 10px;
}

#installation li {
font-size: 1.1em;
margin: 10px 0;
}

pre code {
font-size: 1.1em;
background-color: #f1f1f1;
padding: 10px;
border-radius: 6px;
display: block;
white-space: pre-wrap;
}

/* Getting Started Section */
#getting-started {
padding: 30px;
background-color: #fff;
margin: 20px auto;
max-width: 900px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#getting-started h2 {
font-size: 2em;
color: #ffcc00;
}

#getting-started p {
font-size: 1.2em;
margin-bottom: 20px;
}

#getting-started a {
display: inline-block;
padding: 10px 20px;
background-color: #ffcc00;
color: white;
text-decoration: none;
border-radius: 6px;
font-size: 1.2em;
margin-top: 20px;
}

/* Contribution Section */
#contribution {
padding: 30px;
background-color: #f9f9f9;
margin: 20px auto;
max-width: 900px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#contribution h2 {
font-size: 2em;
color: #ffcc00;
}

#contribution p {
font-size: 1.2em;
}

/* Contact Section */
#contact {
padding: 30px;
background-color: #fff;
margin: 20px auto;
max-width: 900px;
border-radius: 8px;
box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

#contact h2 {
font-size: 2em;
color: #ffcc00;
}

#contact p {
font-size: 1.2em;
}

/* Footer */
footer {
text-align: center;
padding: 20px;
background-color: #ffcc00;
color: white;
margin-top: 40px;
}
/*for opening the web page of ducklang*/
file:///C:/Users/D/DuckLang/DuckLang/index.html
72 changes: 40 additions & 32 deletions main.py
Original file line number Diff line number Diff line change
@@ -1,32 +1,40 @@
"""Module providing Lexer Function"""
from src.lexer import lexer

source_code = '''
# Variable declarations and assignments
quack("Hello")
let my_count = ((( 7 + my_idea ) * 7437 + 949) == 84)
if (x = 10):
y = x + 20 * 3
if (a == b):
quack(90)
'''

def run_lexer(source_code):
'''Call the lexer to tokenize the source code'''
tokens = lexer(source_code)

# Print header
print(f"{'Token Type':<25} {'Value':<30} {'Position'}")
print("="*80) # Separator line

# Print each token in a well-formatted way
for token in tokens:
token_type = token['type']
value = token['value']
position = token['position']

# Print token info with proper formatting
print(f"{token_type:<25} {str(value):<30} {position}")

if __name__ == "__main__":
run_lexer(source_code)
from src.lexer import Lexer

# Sample source code input
source_code = """
def match(self, text):
if self.source[self.position.index:self.position.index + len(text)] -> == text:
for . in range(len(text)):
self.advance()
return True
return False
"""

# Initialize lexer
lexer = Lexer()
tokens = lexer.tokenize(source_code)

# Print detailed token information
print("\n📝 Token Details:")
for token in tokens:
print(f"🔹 {token}")

# Print a nicely formatted table
print("\n📌 Token Table:")

# Define column widths
col_widths = [30, 12, 14, 12, 6, 8]
line_sep = "+" + "+".join(["-" * w for w in col_widths]) + "+"

# Print table header
print(line_sep)
print(f"| {'Type':<20} | {'Value':<12} | {'Start Index':<14} | {'End Index':<12} | {'Line':<6} | {'Column':<8} |")
print(line_sep)

# Print table rows
for token in tokens:
print(f"| {str(token.token_type):<20} | {str(token.value):<12} | {str(token.start_pos.index):<14} | {str(token.end_pos.index):<12} | {str(token.start_pos.line):<6} | {str(token.start_pos.column):<8} |")

# Print table footer
print(line_sep)
Loading

0 comments on commit c9736b0

Please sign in to comment.