The Player Spotlight: Rising Stars & Veteran Performers
This section highlights key players whose performances could significantly influence the outcomes of Group F matches. From promising young talents making their mark in top-flight football to seasoned veterans bringing experience and skill under pressure situations—get acquainted with these influential figures shaping today's football landscape.
Rising Star: Marcus Rashford (Manchester United)
Marcus Rashford continues his meteoric rise as one of England’s brightest talents at Manchester United. His pace, skillful dribbling ability coupled with clinical finishing make him an indispensable asset for both club and country.
- Total Goals Last Season: 22 (including assists)
- Average Distance Covered Per Game: Over 11km
Veteran Force: Harry Kane (Tottenham Hotspur)
In his role as captain for both Tottenham Hotspur & England national team Harry Kane exemplifies leadership qualities alongside his remarkable goal-scoring prowess which has seen him become one of football’s leading marksman over recent years.
- Total Career Goals (Professional): Over 200+
- Average Pass Completion Rate: Above 80%rkhadka/parrot<|file_sep|>/README.md
# Parrot
A tiny language interpreter written in Python.
## Usage
python parrot.py [filename]
## Features
- Functions
- Variables
- Loops
- Conditionals
- Basic arithmetic operators
- Strings
## Examples
### Hello World
js
print("Hello World");
### Fibonacci Sequence
js
function fib(n) {
if n <= 1 then {
return n;
} else {
return fib(n - 1) + fib(n - 2);
}
}
for i from(0) to(10) {
print(fib(i));
}
### Factorial
js
function factorial(n) {
if n == 0 then {
return 1;
} else {
return n * factorial(n - 1);
}
}
print(factorial(5));
## Notes
The interpreter uses a global variable table for variable lookup.
<|repo_name|>rkhadka/parrot<|file_sep|>/parrot.py
#!/usr/bin/env python3
import sys
import re
class Token:
def __init__(self, token_type):
self.token_type = token_type
class Literal(Token):
def __init__(self, value):
super().__init__("LITERAL")
self.value = value
class Identifier(Token):
def __init__(self, name):
super().__init__("IDENTIFIER")
self.name = name
class Keyword(Token):
def __init__(self, name):
super().__init__("KEYWORD")
self.name = name
class Operator(Token):
def __init__(self):
super().__init__("OPERATOR")
class LeftParenthesis(Operator):
def __str__(self):
return "("
class RightParenthesis(Operator):
def __str__(self):
return ")"
class Comma(Operator):
def __str__(self):
return ","
class LeftBrace(Operator):
def __str__(self):
return "{"
class RightBrace(Operator):
def __str__(self):
return "}"
class Plus(Operator):
def __str__(self):
return "+"
class Minus(Operator):
def __str__(self):
return "-"
class Star(Operator):
def __str__(self):
return "*"
class Slash(Operator):
def __str__(self):
return "/"
class BangEqual(Operator):
def __str__(self):
return "!="
class EqualEqual(Operator):
def __str__(self):
return "=="
class LessThan(Operator):
def __str__(self):
return "<"
class GreaterThan(Operator):
def __str__(self):
return ">"
class Equal(Operator):
def __str__(self):
return "="
keywords = ["and", "or", "if", "else", "while", "for", "print", "return",
"from", "to"]
operators = [Plus(), Minus(), Star(), Slash(), BangEqual(), EqualEqual(),
LessThan(), GreaterThan()]
left_parentheses = LeftParenthesis()
right_parentheses = RightParenthesis()
left_brace = LeftBrace()
right_brace = RightBrace()
comma = Comma()
equal_sign = Equal()
def is_number(s):
try:
float(s)
return True
except ValueError:
return False
def tokenize(code):
tokens = []
index = -1
while index + len(code) != len(code):
index +=1
char = code[index]
if char == " ":
continue
elif char == "+":
tokens.append(Plus())
elif char == "-":
tokens.append(Minus())
elif char == "*":
tokens.append(Star())
elif char == "/":
tokens.append(Slash())
elif char == "!":
if index + len("!=") <= len(code) -1
and code[index:index+len("!=")] == "!=":
tokens.append(BangEqual())
index += len("!=") -1
else:
raise Exception(f"Unexpected character {char}")
elif char == "=":
if index + len("==") <= len(code) -1
and code[index:index+len("==")] == "==":
tokens.append(EqualEqual())
index += len("==") -1
elif index + len("=") <= len(code) -1
and code[index:index+len("=")] == "=":
tokens.append(equal_sign)
index += len("=") -1
else:
raise Exception(f"Unexpected character {char}")
elif char == "<":
tokens.append(LessThan())
elif char == ">":
tokens.append(GreaterThan())
elif char == "(":
tokens.append(left_parentheses)
elif char == ")":
tokens.append(right_parentheses)
elif char == "{":
tokens.append(left_brace)
elif char == "}":
tokens.append(right_brace)
elif char == ",":
tokens.append(comma)
elif is_number(char) or (char == "." and is_number(code[index+1])):
num_str = ""
while index + len(code) != len(code)
and (is_number(code[index]) or code[index] == "."):
num_str += code[index]
index +=1
tokens.append(Literal(float(num_str)))
index -=1
elif code[index].isalpha() or code[index] == "_":
word_str = ""
while index + len(code) != len(code)
and (code[index].isalpha() or code[index].isdigit() or code[index] == "_"):
word_str += code[index]
index +=1
if word_str in keywords:
tokens.append(Keyword(word_str))
else:
tokens.append(Identifier(word_str))
index -=1
else:
raise Exception(f"Unexpected character {char}")
return tokens
def parse(tokens):
ast = []
index = -1
while index + len(tokens) != len(tokens):
index +=1
token = tokens[index]
if isinstance(token, Literal):
ast.append({
type : "LiteralExpression",
value : token.value,
line : token.line,
column : token.column,
end_line : token.end_line,
end_column : token.end_column
})
# TODO handle identifiers correctly (e.g., function names)
#elif isinstance(token, Identifier):
#elif isinstance(token, Keyword):
elif isinstance(token, Plus):
ast.append({
type : "AdditionExpression",
left : parse(tokens)[0],
right : parse(tokens)[0],
line : token.line,
column : token.column,
end_line : token.end_line,
end_column : token.end_column
})
elif isinstance(token, Minus):
ast.append({
type : "SubtractionExpression",
left : parse(tokens)[0],
right : parse(tokens)[0],
line : token.line,
column : token.column,
end_line : token.end_line,
end_column : token.end_column
})
elif isinstance(token, Star):
ast.append({
type : "MultiplicationExpression",
left : parse(tokens)[0],
right : parse(tokens)[0],
line : token.line,
column : token.column,
end_line : token.end_line,
end_column : token.end_column
})
elif isinstance(token, Slash):
ast.append({
type : "DivisionExpression",
left : parse(tokens)[0],
right : parse(tokens)[0],
line : token.line,
column : token.column,
end_line : token.end_line,
end_column : token.end_column
})
elif isinstance(token, BangEqual):
ast.append({
type : "BangEqualExpression",
left : parse(tokens)[0],
right : parse(tokens)[0],
line : token.line,
column : token.column,
end_line : token.end_line,
end_column : token.end_column
})
elif isinstance(token, EqualEqual):
ast.append({
type :"EqualEqualExpression",
left: parse(tokens)[0],
right: parse(tokens)[0],
line: token.line,
column: token.column,
end_line:token.end_line,
end_column:token.end_column
})
# TODO handle assignment expressions correctly (e.g., x = y)
#elif isinstance(token , Equal):
elif isinstance(token , LessThan):
ast.append({
type :"LessThanExpression",
left:parse(tokens)[0],
right:parse(tokens)[0],
line:token.line,
column:token.column,
end_line:token.end_line,
end_column:token.end_column
})
elif isinstance(token , GreaterThan):
ast.append({
type :"GreaterThanExpression",
left:parse(tokens)[0],
right:parse(tokens)[0],
line:token.line,
column:token.column,
end_line:token.end_line,
end_column:token.end_column
})
# TODO handle unary expressions correctly (e.g., !x)
# TODO handle function calls correctly (e.g., f(x))
# TODO handle parentheses correctly
elif isinstance(token , LeftBrace):
block_ast = []
while not isinstance(parse(tokens)[0], RightBrace):
block_ast.extend(parse(tokens))
ast.extend(block_ast[:-1])
elif isinstance(token , LeftParenthesis):
expr_ast = []
while not isinstance(parse(tokens)[0], RightParenthesis):
expr_ast.extend(parse(tokens))
ast.extend(expr_ast[:-1])
elif isinstance(token , Keyword):
if str(token.name) == 'if':
ast.extend(parse_if_else_expr())
elif str(token.name) == 'while':
ast.extend(parse_while_expr())
elif str(token.name) == 'for':
ast.extend(parse_for_expr())
else:
raise Exception('Unknown keyword')
elif isinstance(token , Comma):
ast.extend(parse_comma_expr())
elif isinstance(token , RightBrace):
break
else:
raise Exception(f'Unexpected Token {token}')
return ast
def parse_if_else_expr():
if_expr_ast = []
if_expr_ast