fork download
  1. %option noyywrap
  2.  
  3. %{
  4. #include <stdio.h>
  5. #include <stdlib.h>
  6.  
  7. int line_num = 1;
  8.  
  9. void print_token(const char *type, char *lexeme) {
  10. printf("Line %d: \t%-20s \t%s\n", line_num, type, lexeme);
  11. }
  12. %}
  13.  
  14. DIGIT [0-9]
  15. LETTER [a-zA-Z_]
  16. ALPHANUM [a-zA-Z0-9_]
  17. ID {LETTER}{ALPHANUM}*
  18.  
  19. INT_NUM {DIGIT}+
  20. FLOAT_NUM {DIGIT}*\.{DIGIT}+([eE][-+]?{DIGIT}+)?
  21. HEX_NUM 0[xX][0-9a-fA-F]+
  22.  
  23. STRING_SQ \'([^'\n]|\\.)*\'
  24. STRING_DQ \"([^"\n]|\\.)*\"
  25. TRIPLE_STR \"\"\"(.|\n)*?\"\"\"
  26.  
  27. %%
  28.  
  29. #.* { print_token("COMMENT", yytext); }
  30.  
  31. "def" { print_token("KEYWORD_DEF", yytext); }
  32. "class" { print_token("KEYWORD_CLASS", yytext); }
  33. "return" { print_token("KEYWORD_RETURN", yytext); }
  34. "if" { print_token("KEYWORD_IF", yytext); }
  35. "elif" { print_token("KEYWORD_ELIF", yytext); }
  36. "else" { print_token("KEYWORD_ELSE", yytext); }
  37. "while" { print_token("KEYWORD_WHILE", yytext); }
  38. "for" { print_token("KEYWORD_FOR", yytext); }
  39. "in" { print_token("KEYWORD_IN", yytext); }
  40. "import" { print_token("KEYWORD_IMPORT", yytext); }
  41. "from" { print_token("KEYWORD_FROM", yytext); }
  42. "as" { print_token("KEYWORD_AS", yytext); }
  43. "try" { print_token("KEYWORD_TRY", yytext); }
  44. "except" { print_token("KEYWORD_EXCEPT", yytext); }
  45. "print" { print_token("KEYWORD_PRINT", yytext); }
  46. "pass" { print_token("KEYWORD_PASS", yytext); }
  47. "break" { print_token("KEYWORD_BREAK", yytext); }
  48. "continue" { print_token("KEYWORD_CONTINUE", yytext); }
  49. "lambda" { print_token("KEYWORD_LAMBDA", yytext); }
  50. "with" { print_token("KEYWORD_WITH", yytext); }
  51.  
  52. "True" { print_token("BOOLEAN_TRUE", yytext); }
  53. "False" { print_token("BOOLEAN_FALSE", yytext); }
  54. "None" { print_token("NONE_TYPE", yytext); }
  55.  
  56. "+" { print_token("OP_PLUS", yytext); }
  57. "-" { print_token("OP_MINUS", yytext); }
  58. "*" { print_token("OP_MULT", yytext); }
  59. "/" { print_token("OP_DIV", yytext); }
  60. "%" { print_token("OP_MOD", yytext); }
  61. "**" { print_token("OP_POWER", yytext); }
  62. "//" { print_token("OP_FLOOR_DIV", yytext); }
  63. "=" { print_token("OP_ASSIGN", yytext); }
  64. "==" { print_token("OP_EQUALS", yytext); }
  65. "!=" { print_token("OP_NOT_EQ", yytext); }
  66. ">" { print_token("OP_GT", yytext); }
  67. "<" { print_token("OP_LT", yytext); }
  68. ">=" { print_token("OP_GTE", yytext); }
  69. "<=" { print_token("OP_LTE", yytext); }
  70. "+=" { print_token("OP_PLUS_ASSIGN", yytext); }
  71. "-=" { print_token("OP_MINUS_ASSIGN", yytext); }
  72.  
  73. "(" { print_token("LPAREN", yytext); }
  74. ")" { print_token("RPAREN", yytext); }
  75. "[" { print_token("LBRACKET", yytext); }
  76. "]" { print_token("RBRACKET", yytext); }
  77. "{" { print_token("LBRACE", yytext); }
  78. "}" { print_token("RBRACE", yytext); }
  79. ":" { print_token("COLON", yytext); }
  80. "," { print_token("COMMA", yytext); }
  81. "." { print_token("DOT", yytext); }
  82. ";" { print_token("SEMICOLON", yytext); }
  83.  
  84. {HEX_NUM} { print_token("HEX_LITERAL", yytext); }
  85. {FLOAT_NUM} { print_token("FLOAT_LITERAL", yytext); }
  86. {INT_NUM} { print_token("INT_LITERAL", yytext); }
  87. {STRING_SQ} { print_token("STRING_LITERAL", yytext); }
  88. {STRING_DQ} { print_token("STRING_LITERAL", yytext); }
  89.  
  90. {ID} { print_token("IDENTIFIER", yytext); }
  91.  
  92. \n { line_num++; }
  93.  
  94. [ \t]+ { }
  95.  
  96. . { printf("Line %d: \tUNKNOWN \t%s\n", line_num, yytext); }
  97.  
  98. %%
  99.  
  100. int main(int argc, char **argv) {
  101. if (argc > 1) {
  102. yyin = fopen(argv[1], "r");
  103. if (!yyin) {
  104. printf("Error: Could not open file %s\n", argv[1]);
  105. return 1;
  106. }
  107. } else {
  108. printf("Usage: ./myscanner <input_file>\n");
  109. return 1;
  110. }
  111.  
  112. printf("LEXICAL ANALYSIS FOR PYTHON\n");
  113. printf("--------------------------------------------------\n");
  114. yylex();
  115. return 0;
  116. }
Success #stdin #stdout #stderr 0.02s 7108KB
stdin
# =============================================================================
# COMPREHENSIVE PYTHON TEST FILE - ALL LANGUAGE FEATURES
# =============================================================================

# -------------------------------
# 1. ALL DATA TYPES & LITERALS
# -------------------------------

# Numeric literals
integer_var = 42
float_var = 3.14159
hex_var = 0x1A3F
octal_var = 0o755
binary_var = 0b1101
complex_var = 3 + 4j
scientific_var = 1.23e-4

# String literals
single_quote_str = 'hello world'
double_quote_str = "python programming"
triple_single_str = '''multiline
string with triple
single quotes'''
triple_double_str = """multiline
string with triple
double quotes"""
f_string = f"formatted: {integer_var}"
raw_string = r"raw string \n no escape"

# Boolean and None
true_var = True
false_var = False
none_var = None

# Collections
list_var = [1, 2, 3, "mixed", True]
tuple_var = (1, "hello", 3.14)
dict_var = {"key1": "value1", "key2": 42}
set_var = {1, 2, 3, 2, 1}

# -------------------------------
# 2. ALL KEYWORDS
# -------------------------------

# Function definition keywords
def regular_function(param1, param2):
    """This is a regular function"""
    return param1 + param2

# Class definition
class MyClass:
    """A sample class"""
    
    def __init__(self, value):
        self.value = value
    
    def get_value(self):
        return self.value
    
    @classmethod
    def class_method(cls):
        return "class method"
    
    @staticmethod
    def static_method():
        return "static method"

# Control flow keywords
if True:
    print("if statement")
elif False:
    print("elif statement")
else:
    print("else statement")

# Loops
for i in range(5):
    print(f"for loop: {i}")
    if i == 2:
        continue
    if i == 4:
        break

while True:
    print("while loop")
    break

# Exception handling
try:
    risky_operation = 10 / 2
except ZeroDivisionError as e:
    print(f"Error: {e}")
except Exception:
    print("General exception")
finally:
    print("Finally block")

# Import keywords
import math
import os as operating_system
from sys import platform
from collections import deque, Counter

# Scope keywords
global global_variable
global_variable = "I'm global"

def scope_test():
    local_var = "I'm local"
    global global_variable
    global_variable = "modified"

# Async keywords
async def async_function():
    await some_async_operation()
    return "async result"

# Other keywords
lambda_func = lambda x: x * 2
del list_var[0]

# -------------------------------
# 3. ALL OPERATORS
# -------------------------------

# Arithmetic operators
a, b = 10, 3
add = a + b
subtract = a - b
multiply = a * b
divide = a / b
floor_divide = a // b
modulus = a % b
power = a ** b

# Assignment operators
x = 5
x += 3
x -= 2
x *= 4
x /= 2
x //= 3
x %= 5
x **= 2

# Comparison operators
eq = (a == b)
ne = (a != b)
gt = (a > b)
lt = (a < b)
ge = (a >= b)
le = (a <= b)

# Logical operators
and_result = (True and False)
or_result = (True or False)
not_result = (not True)

# Identity operators
is_result = (a is b)
is_not_result = (a is not b)

# Membership operators
in_result = (2 in [1, 2, 3])
not_in_result = (4 not in [1, 2, 3])

# Bitwise operators
bit_and = a & b
bit_or = a | b
bit_xor = a ^ b
bit_not = ~a
left_shift = a << 2
right_shift = a >> 1

# Bitwise assignment
y = 15
y &= 7
y |= 8
y ^= 4
y <<= 1
y >>= 2

# Walrus operator
if (n := len("hello")) > 3:
    print(f"Length is {n}")

# -------------------------------
# 4. ALL FUNCTION TYPES
# -------------------------------

# Regular function
def simple_func():
    return "simple"

# Function with type hints
def typed_func(name: str, age: int) -> str:
    return f"{name} is {age}"

# Function with default parameters
def default_params(a, b=10, c=None):
    if c is None:
        c = []
    return a + b

# Function with *args and **kwargs
def flexible_func(*args, **kwargs):
    return args, kwargs

# Generator function
def number_generator(limit):
    for i in range(limit):
        yield i * 2

# Async function
async def fetch_data(url):
    # Simulate async operation
    return f"data from {url}"

# Lambda function
square = lambda x: x ** 2
add_lambda = lambda x, y: x + y

# Nested function
def outer_function():
    outer_var = "outer"
    
    def inner_function():
        return outer_var + " inner"
    
    return inner_function()

# Function with decorators
def simple_decorator(func):
    def wrapper(*args, **kwargs):
        print("Before function call")
        result = func(*args, **kwargs)
        print("After function call")
        return result
    return wrapper

@simple_decorator
def decorated_function():
    return "decorated"

# Multiple decorators
def decorator1(func):
    return func

def decorator2(func):
    return func

@decorator1
@decorator2
def multi_decorated():
    return "multi-decorated"

# Class-based decorator
class ClassDecorator:
    def __init__(self, func):
        self.func = func
    
    def __call__(self, *args, **kwargs):
        return self.func(*args, **kwargs)

@ClassDecorator
def class_decorated():
    return "class decorated"

# -------------------------------
# 5. ALL CONTROL STRUCTURES
# -------------------------------

# If-elif-else chains
score = 85
if score >= 90:
    grade = 'A'
elif score >= 80:
    grade = 'B'
elif score >= 70:
    grade = 'C'
else:
    grade = 'F'

# Nested if statements
if True:
    if False:
        pass
    else:
        print("nested else")

# For loops with different iterables
for char in "hello":
    print(char)

for key, value in {"a": 1, "b": 2}.items():
    print(f"{key}: {value}")

for i, item in enumerate(["apple", "banana"]):
    print(f"{i}: {item}")

# While-else loop
count = 0
while count < 3:
    print(count)
    count += 1
else:
    print("Loop completed")

# Try-except-else-finally
def safe_divide(x, y):
    try:
        result = x / y
    except ZeroDivisionError:
        return "Cannot divide by zero"
    except TypeError as e:
        return f"Type error: {e}"
    else:
        print("Division successful")
        return result
    finally:
        print("Division attempt completed")

# Context manager (with statement)
with open('test.txt', 'w') as f:
    f.write("Hello World")

# -------------------------------
# 6. ADVANCED FEATURES
# -------------------------------

# List comprehensions
squares = [x**2 for x in range(10)]
even_squares = [x**2 for x in range(10) if x % 2 == 0]

# Dictionary comprehensions
square_dict = {x: x**2 for x in range(5)}

# Set comprehensions
unique_chars = {char for char in "hello world"}

# Generator expressions
gen_expr = (x*2 for x in range(5))

# Conditional expressions (ternary)
max_value = a if a > b else b

# Multiple assignment
x, y, z = 1, 2, 3
a = b = c = 0

# Extended unpacking
first, *middle, last = [1, 2, 3, 4, 5]

# Format strings with expressions
name = "Alice"
age = 30
formatted = f"{name.upper()} is {age + 5} years old in 5 years"

# Ellipsis
def incomplete():
    ...

class AbstractClass:
    def method(self):
        ...

# -------------------------------
# 7. COMPLEX EXAMPLES
# -------------------------------

# Complex class with inheritance
class Animal:
    def __init__(self, name):
        self.name = name
    
    def speak(self):
        raise NotImplementedError

class Dog(Animal):
    def speak(self):
        return f"{self.name} says Woof!"

class Cat(Animal):
    def speak(self):
        return f"{self.name} says Meow!"

# Multiple inheritance
class Aquatic:
    def swim(self):
        return "Swimming"

class Flying:
    def fly(self):
        return "Flying"

class Duck(Aquatic, Flying):
    def __init__(self, name):
        self.name = name

# Complex function with everything
@simple_decorator
def complex_example(
    required: str,
    optional: int = 10,
    *args: tuple,
    **kwargs: dict
) -> dict:
    """A complex function demonstrating many features"""
    
    # Walrus in comprehension
    results = {
        key: (value := val * 2) 
        for key, val in kwargs.items() 
        if (value := val * 2) > 10
    }
    
    # Multiple conditions
    if (required and 
        optional > 5 and 
        len(args) > 0 and
        'important' in kwargs):
        
        # Nested try-except
        try:
            processed = [
                item.upper() if isinstance(item, str) else item * 2
                for item in args
                if item is not None
            ]
        except Exception as e:
            print(f"Error: {e}")
            processed = []
        finally:
            print("Processing complete")
    
    else:
        processed = []
    
    return {
        'results': results,
        'processed': processed,
        'metadata': {
            'args_count': len(args),
            'kwargs_count': len(kwargs)
        }
    }

# -------------------------------
# 8. MAIN EXECUTION BLOCK
# -------------------------------

if __name__ == "__main__":
    # Test all features
    
    # Data types
    print("Data types test:")
    print(f"Integer: {integer_var}")
    print(f"Float: {float_var}")
    print(f"String: {single_quote_str}")
    print(f"F-string: {f_string}")
    
    # Functions
    print("\nFunctions test:")
    result = regular_function(5, 3)
    print(f"Regular function: {result}")
    
    # Classes
    print("\nClasses test:")
    dog = Dog("Buddy")
    print(dog.speak())
    
    # Control structures
    print("\nControl structures test:")
    for i in range(3):
        if i % 2 == 0:
            print(f"Even: {i}")
        else:
            print(f"Odd: {i}")
    
    # Operators
    print("\nOperators test:")
    print(f"Arithmetic: {add}, {subtract}, {multiply}")
    print(f"Comparison: {eq}, {ne}, {gt}")
    print(f"Logical: {and_result}, {or_result}, {not_result}")
    
    # Advanced features
    print("\nAdvanced features test:")
    print(f"List comprehension: {squares}")
    print(f"Dict comprehension: {square_dict}")
    print(f"Ternary: {max_value}")
    
    # Complex example
    print("\nComplex example test:")
    complex_result = complex_example(
        "required_value",
        15,
        "hello", "world",
        important=10,
        test=5
    )
    print(f"Complex result: {complex_result}")
    
    print("\n✅ ALL FEATURES TESTED SUCCESSFULLY!")

# -------------------------------
# END OF COMPREHENSIVE TEST FILE
# -------------------------------
stdout

	
stderr
ERROR: /home/30kYJX/prog:4:1: Syntax error: End of file in quoted atom
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? ERROR: Can't ignore goal at this port
ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? ERROR: '$runtoplevel'/0: Undefined procedure: program/0
   Exception: (3) program ? Options:
+:                  spy        -:              no spy
/c|e|r|f|u|a goal:  find       .:              repeat find
a:                  abort      A:              alternatives
b:                  break      c (ret, space): creep
[depth] d:          depth      e:              exit
f:                  fail       [ndepth] g:     goals (backtrace)
h (?):              help       i:              ignore
l:                  leap       L:              listing
n:                  no debug   p:              print
r:                  retry      s:              skip
u:                  up         w:              write
m:                  exception details
C:                  toggle show context
   Exception: (3) program ? ERROR: Unknown option (h for help)
   Exception: (3) program ? % Break level 1

ERROR: Syntax error: Operator expected
ERROR: complex_var = 3 + 
ERROR: ** here **
ERROR: 4j
scientific_var = 1.23e-4

# String literals
single_quote_str = 'hello world'
double_quote_str = "python programming"
triple_single_str = '''multiline
string with triple
single quotes'''
triple_double_str = """multiline
string with triple
double quotes"""
f_string = f"formatted: {integer_var}"
raw_string = r"raw string \n no escape"

# Boolean and None
true_var = True
false_var = False
none_var = None

# Collections
list_var = [1, 2, 3, "mixed", True]
tuple_var = (1, "hello", 3.14)
dict_var = {"key1": "value1", "key2": 42}
set_var = {1, 2, 3, 2, 1}

# -------------------------------
# 2 . 

ERROR: Syntax error: Operator expected
ERROR: ALL
ERROR: ** here **
ERROR:  KEYWORDS
# -------------------------------

# Function definition keywords
def regular_function(param1, param2):
    """This is a regular function"""
    return param1 + param2

# Class definition
class MyClass:
    """A sample class"""
    
    def __init__(self, value):
        self.value = value
    
    def get_value(self):
        return self.value
    
    @classmethod
    def class_method(cls):
        return "class method"
    
    @staticmethod
    def static_method():
        return "static method"

# Control flow keywords
if True:
    print("if statement")
elif False:
    print("elif statement")
else:
    print("else statement")

# Loops
for i in range(5):
    print(f"for loop: {i}")
    if i == 2:
        continue
    if i == 4:
        break

while True:
    print("while loop")
    break

# Exception handling
try:
    risky_operation = 10 / 2
except ZeroDivisionError as e:
    print(f"Error: {e}")
except Exception:
    print("General exception")
finally:
    print("Finally block")

# Import keywords
import math
import os as operating_system
from sys import platform
from collections import deque, Counter

# Scope keywords
global global_variable
global_variable = "I'm global"

def scope_test():
    local_var = "I'm local"
    global global_variable
    global_variable = "modified"

# Async keywords
async def async_function():
    await some_async_operation()
    return "async result"

# Other keywords
lambda_func = lambda x: x * 2
del list_var[0]

# -------------------------------
# 3 . 

ERROR: Syntax error: Operator expected
ERROR: ALL
ERROR: ** here **
ERROR:  OPERATORS
# -------------------------------

# Arithmetic operators
a, b = 10, 3
add = a + b
subtract = a - b
multiply = a * b
divide = a / b
floor_divide = a // b
modulus = a    
power = a ** b

# Assignment operators
x = 5
x += 3
x -= 2
x *= 4
x /= 2
x //= 3
x     
x **= 2

# Comparison operators
eq = (a == b)
ne = (a != b)
gt = (a > b)
lt = (a < b)
ge = (a >= b)
le = (a <= b)

# Logical operators
and_result = (True and False)
or_result = (True or False)
not_result = (not True)

# Identity operators
is_result = (a is b)
is_not_result = (a is not b)

# Membership operators
in_result = (2 in [1, 2, 3])
not_in_result = (4 not in [1, 2, 3])

# Bitwise operators
bit_and = a & b
bit_or = a | b
bit_xor = a ^ b
bit_not = ~a
left_shift = a << 2
right_shift = a >> 1

# Bitwise assignment
y = 15
y &= 7
y |= 8
y ^= 4
y <<= 1
y >>= 2

# Walrus operator
if (n := len("hello")) > 3:
    print(f"Length is {n}")

# -------------------------------
# 4 . 

ERROR: Syntax error: Operator expected
ERROR: ALL
ERROR: ** here **
ERROR:  FUNCTION TYPES
# -------------------------------

# Regular function
def simple_func():
    return "simple"

# Function with type hints
def typed_func(name: str, age: int) -> str:
    return f"{name} is {age}"

# Function with default parameters
def default_params(a, b=10, c=None):
    if c is None:
        c = []
    return a + b

# Function with *args and **kwargs
def flexible_func(*args, **kwargs):
    return args, kwargs

# Generator function
def number_generator(limit):
    for i in range(limit):
        yield i * 2

# Async function
async def fetch_data(url):
    # Simulate async operation
    return f"data from {url}"

# Lambda function
square = lambda x: x ** 2
add_lambda = lambda x, y: x + y

# Nested function
def outer_function():
    outer_var = "outer"
    
    def inner_function():
        return outer_var + " inner"
    
    return inner_function()

# Function with decorators
def simple_decorator(func):
    def wrapper(*args, **kwargs):
        print("Before function call")
        result = func(*args, **kwargs)
        print("After function call")
        return result
    return wrapper

@simple_decorator
def decorated_function():
    return "decorated"

# Multiple decorators
def decorator1(func):
    return func

def decorator2(func):
    return func

@decorator1
@decorator2
def multi_decorated():
    return "multi-decorated"

# Class-based decorator
class ClassDecorator:
    def __init__(self, func):
        self.func = func
    
    def __call__(self, *args, **kwargs):
        return self.func(*args, **kwargs)

@ClassDecorator
def class_decorated():
    return "class decorated"

# -------------------------------
# 5 . 

ERROR: Syntax error: Operator expected
ERROR: ALL
ERROR: ** here **
ERROR:  CONTROL STRUCTURES
# -------------------------------

# If-elif-else chains
score = 85
if score >= 90:
    grade = 'A'
elif score >= 80:
    grade = 'B'
elif score >= 70:
    grade = 'C'
else:
    grade = 'F'

# Nested if statements
if True:
    if False:
        pass
    else:
        print("nested else")

# For loops with different iterables
for char in "hello":
    print(char)

for key, value in {"a": 1, "b": 2}.items():
    print(f"{key}: {value}")

for i, item in enumerate(["apple", "banana"]):
    print(f"{i}: {item}")

# While-else loop
count = 0
while count < 3:
    print(count)
    count += 1
else:
    print("Loop completed")

# Try-except-else-finally
def safe_divide(x, y):
    try:
        result = x / y
    except ZeroDivisionError:
        return "Cannot divide by zero"
    except TypeError as e:
        return f"Type error: {e}"
    else:
        print("Division successful")
        return result
    finally:
        print("Division attempt completed")

# Context manager (with statement)
with open('test.txt', 'w') as f:
    f.write("Hello World")

# -------------------------------
# 6 . 

ERROR: Syntax error: Operator expected
ERROR: ADVANCED
ERROR: ** here **
ERROR:  FEATURES
# -------------------------------

# List comprehensions
squares = [x**2 for x in range(10)]
even_squares = [x**2 for x in range(10) if x          

# Dictionary comprehensions
square_dict = {x: x**2 for x in range(5)}

# Set comprehensions
unique_chars = {char for char in "hello world"}

# Generator expressions
gen_expr = (x*2 for x in range(5))

# Conditional expressions (ternary)
max_value = a if a > b else b

# Multiple assignment
x, y, z = 1, 2, 3
a = b = c = 0

# Extended unpacking
first, *middle, last = [1, 2, 3, 4, 5]

# Format strings with expressions
name = "Alice"
age = 30
formatted = f"{name.upper()} is {age + 5} years old in 5 years"

# Ellipsis
def incomplete():
    ...

class AbstractClass:
    def method(self):
        ...

# -------------------------------
# 7 . 

ERROR: Syntax error: Operator expected
ERROR: COMPLEX
ERROR: ** here **
ERROR:  EXAMPLES
# -------------------------------

# Complex class with inheritance
class Animal:
    def __init__(self, name):
        self.name = name
    
    def speak(self):
        raise NotImplementedError

class Dog(Animal):
    def speak(self):
        return f"{self.name} says Woof!"

class Cat(Animal):
    def speak(self):
        return f"{self.name} says Meow!"

# Multiple inheritance
class Aquatic:
    def swim(self):
        return "Swimming"

class Flying:
    def fly(self):
        return "Flying"

class Duck(Aquatic, Flying):
    def __init__(self, name):
        self.name = name

# Complex function with everything
@simple_decorator
def complex_example(
    required: str,
    optional: int = 10,
    *args: tuple,
    **kwargs: dict
) -> dict:
    """A complex function demonstrating many features"""
    
    # Walrus in comprehension
    results = {
        key: (value := val * 2) 
        for key, val in kwargs.items() 
        if (value := val * 2) > 10
    }
    
    # Multiple conditions
    if (required and 
        optional > 5 and 
        len(args) > 0 and
        'important' in kwargs):
        
        # Nested try-except
        try:
            processed = [
                item.upper() if isinstance(item, str) else item * 2
                for item in args
                if item is not None
            ]
        except Exception as e:
            print(f"Error: {e}")
            processed = []
        finally:
            print("Processing complete")
    
    else:
        processed = []
    
    return {
        'results': results,
        'processed': processed,
        'metadata': {
            'args_count': len(args),
            'kwargs_count': len(kwargs)
        }
    }

# -------------------------------
# 8 . 

ERROR: Stream user_input:1005:32 Syntax error: Unexpected end of file
% Exit break level 1
   Exception: (3) program ? EOF: exit