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
2 changes: 1 addition & 1 deletion example_code/is_prime.haellae
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,5 @@ is_prime ære-samma-som en-fungsjon såm-brukær n såm-gjør
gi-tilbake "Prime".
åså-varn-færi.

x ære-samma-som kjør is_prime med 101.
x ære-samma-som kjør is_prime med 101 å-det-var-det.
spøtt-ut x.
6 changes: 3 additions & 3 deletions example_code/torus.haellae
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@ hent-ut-pytonslange-funksjon "math" å-kallen-for matte i-samma-slengen.
hent-ut-pytonslange-funksjon "time" å-kallen-for tid i-samma-slengen.


theta_spacing ære-samma-som 0 kåmma 04.
phi_spacing ære-samma-som 0 kåmma 01.
theta_spacing ære-samma-som 0 kåmma 2.
phi_spacing ære-samma-som 0 kåmma 05.
PI ære-samma-som 3 kåmma 141592653589793.

screen_width ære-samma-som 50.
Expand Down Expand Up @@ -132,7 +132,7 @@ render_frame ære-samma-som en-fungsjon såm-brukær A å B såm-gjør
v ære-samma-som 0.
u ære-samma-som 0.
iterations ære-samma-som 0.
speed ære-samma-som 20.
speed ære-samma-som 25.

imens iterations småære-enn 1000 ta-åsså-gjør
kjør os dått system med "clear" å-det-var-det.
Expand Down
15 changes: 10 additions & 5 deletions parser/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
'kjør':'RUN',
'med':'WITH',
'gi-tilbake':'RETURN',
'kåmma':'COMMA',
#'kåmma':'COMMA',
'endre': 'CHANGE_ARRAY_INDEX',
'te': 'TO',
'e-orlbok-beståænes-av':'START_OF_DICT',
Expand All @@ -59,7 +59,7 @@
}

tokens = [
'NAME','NUMBER', 'STRING',
'NAME','NUMBER', 'STRING', 'FLOAT',
'END_OF_STATEMENT',
] + list(set(reserved.values()))

Expand All @@ -78,6 +78,11 @@ def t_NAME(t):
r'[a-zA-ZæøåÆØÅ_][a-zA-ZæøåÆØÅ0-9_]*'
return t

def t_FLOAT(t):
r'\d+\s*kåmma\s*\d+'
t.value = float(t.value.replace(r'kåmma', '.').replace(" ", ""))
return t

def t_NUMBER(t):
r'\d+'
t.value = int(t.value)
Expand Down Expand Up @@ -105,7 +110,7 @@ def t_error(t):
('nonassoc', 'LT', 'GT', 'EQ'), # Nonassociative operators
('left', 'PLUS', 'MINUS', 'MOD'),
('left', 'TIMES', 'DIVIDE'),
('nonassoc', 'COMMA'),
#('nonassoc', 'COMMA'),
('nonassoc', 'IN_DICT', 'IN_LIST'),
)

Expand All @@ -130,8 +135,8 @@ def p_expression_number(p):
p[0] = ('literal-expression',p[1])

def p_expression_float(p):
'''expression : NUMBER COMMA NUMBER'''
p[0] = ('literal-expression',float(str(p[1])+'.'+str(p[3])))
'''expression : FLOAT'''
p[0] = ('literal-expression', p[1])

def p_expression_string(p):
'''expression : STRING'''
Expand Down