This commit is contained in:
NikolajDanger
2022-06-08 16:16:20 +02:00
parent 935c90f645
commit f4c608aaf2
5 changed files with 130 additions and 120 deletions

144
README.md
View File

@@ -6,19 +6,19 @@
## Example code ## Example code
### Hello World ### Hello World
``` ```
DESIGNA x UT "Hello World!" DESIGNA x VT "Hello World!"
DICE x DICE x
``` ```
### Recursive Fibonacci number function ### Recursive Fibonacci number function
``` ```
DEFINI fib x UT { DEFINI fib x VT {
SI x EST NULLUS TUNC { SI x EST NVLLVS TVNC {
REDI NULLUS REDI NVLLVS
} ALUID SI x EST I TUNC { } ALVID SI x EST I TVNC {
REDI I REDI I
} ALUID { } ALVID {
REDI ((INVOCA fib (x-II)) + (INVOCA fib (x-I))) REDI ((INVOCA fib (x-II)) + (INVOCA fib (x-I)))
} }
} }
@@ -29,17 +29,17 @@ DEFINI fib x UT {
``` ```
VOCA FORS VOCA FORS
DESIGNA correct UT FORTIS_NUMERUS I C DESIGNA correct VT FORTIS_NVMERVS I C
DESIGNA gvess UT NULLUS DESIGNA gvess VT NVLLVS
DUM FALSITAS FACE { DVM FALSITAS FACE {
DESIGNA gvess UT AUDI_NUMERUS DESIGNA gvess VT AVDI_NVMERVS
SI gvess MINUS correct TUNC { SI gvess MINVS correct TVNC {
DICE "Too low!" DICE "Too low!"
} ALUID SI gvess PLUS correct TUNC { } ALVID SI gvess PLVS correct TVNC {
DICE "Too high!" DICE "Too high!"
} ALUID { } ALVID {
ERUMPE ERVMPE
} }
} }
@@ -47,24 +47,24 @@ DICE "You guessed correctly!"
``` ```
## Variables ## Variables
Variables are set with the `DESIGNA` and `UT` keywords. Type is inferred. Variables are set with the `DESIGNA` and `VT` keywords. Type is inferred.
``` ```
DESIGNA x UT XXVI DESIGNA x VT XXVI
``` ```
Variable can consist of lower-case letters, numbers, as well as `_`. Variable can consist of lower-case letters, numbers, as well as `_`.
## Data types ## Data types
### NULLUS ### NVLLVS
`NULLUS` is a special kind of data type in `CENTVRION`, similar to the `null` value in many other languages. `NULLUS` can be 0 if evaluated as an int or float, or an empty string if evaluated as a string. `NULLUS` cannot be evaluated as a boolean. `NVLLVS` is a special kind of data type in `CENTVRION`, similar to the `null` value in many other languages. `NVLLVS` can be 0 if evaluated as an int or float, or an empty string if evaluated as a string. `NVLLVS` cannot be evaluated as a boolean.
### Strings ### Strings
Strings are written as text in quotes (`'` or `"`). Strings are written as text in quotes (`'` or `"`).
``` ```
DESIGNA x UT "this is a string" DESIGNA x VT "this is a string"
``` ```
### Integers ### Integers
@@ -82,12 +82,12 @@ Integers must be written in roman numerals using the following symbols:
Each of the symbols written by themself is equal to the value of the symbol. Different symbols written from largest to smallest are equal to the sum of the symbols. Two to three of the same symbol written consecutively is equal to the sum of those symbols (only true for `I`s, `X`s, `C`s or `M`s ). A single `I` written before a `V` or `X` is equal to 1 less than the value of the second symbol. Similarly, an `X` written before a `L` or `C` is 10 less than the second symbol, and a `C` written before a `D` or `M` is 100 less than the second symbol. Each of the symbols written by themself is equal to the value of the symbol. Different symbols written from largest to smallest are equal to the sum of the symbols. Two to three of the same symbol written consecutively is equal to the sum of those symbols (only true for `I`s, `X`s, `C`s or `M`s ). A single `I` written before a `V` or `X` is equal to 1 less than the value of the second symbol. Similarly, an `X` written before a `L` or `C` is 10 less than the second symbol, and a `C` written before a `D` or `M` is 100 less than the second symbol.
Because of the restrictions of roman numerals, numbers above 3.999 are impossible to write in the base `CENTVRION` syntax. If numbers of that size are required, see the `MAGNUM` module. Because of the restrictions of roman numerals, numbers above 3.999 are impossible to write in the base `CENTVRION` syntax. If numbers of that size are required, see the `MAGNVM` module.
The number 0 can be expressed with the keyword `NULLUS`. The number 0 can be expressed with the keyword `NVLLVS`.
#### Negative numbers #### Negative numbers
Negative numbers can be expressed as `NULLUS` minus the value. For an explicit definition of negative numbers, see the `SUBNULLA` module. Negative numbers can be expressed as `NVLLVS` minus the value. For an explicit definition of negative numbers, see the `SVBNVLLA` module.
### Floats ### Floats
The base `CENTVRION` syntax does not allow for floats. However, the `FRACTIO` module adds a syntax for fractions. The base `CENTVRION` syntax does not allow for floats. However, the `FRACTIO` module adds a syntax for fractions.
@@ -99,17 +99,17 @@ Booleans are denoted with the keywords `VERITAS` for true and `FALSITAS` for fal
Arrays are defined using square brackets (`[]`). Arrays are defined using square brackets (`[]`).
## Conditionals ## Conditionals
### SI/TUNC ### SI/TVNC
If-then statements are denoted with the keywords `SI` (if) and `TUNC` (then). Thus, the code If-then statements are denoted with the keywords `SI` (if) and `TVNC` (then). Thus, the code
``` ```
DESIGNA x UT VERITAS DESIGNA x VT VERITAS
SI x TUNC { SI x TVNC {
DICE I DICE I
REDI NULLLUS REDI NVLLLVS
} }
DICE NULLUS DICE NVLLVS
> I > I
``` ```
@@ -117,32 +117,32 @@ DICE NULLUS
Will return `I` (1), as the conditional evaluates `x` to be true. Will return `I` (1), as the conditional evaluates `x` to be true.
### Boolean expressions ### Boolean expressions
In conditionals, `EST` functions as an equality evaluation, and `MINUS` (<) and `PLUS` (>) function as inequality evaluation. In conditionals, `EST` functions as an equality evaluation, and `MINVS` (<) and `PLVS` (>) function as inequality evaluation.
### ALUID ### ALVID
When using `SI`/`TUNC` statements, you can also use `ALUID` as an "else". When using `SI`/`TVNC` statements, you can also use `ALVID` as an "else".
``` ```
DESIGNA x UT VERITAS DESIGNA x VT VERITAS
SI x TUNC { SI x TVNC {
DICE I DICE I
} ALUID { } ALVID {
DICE NULLUS DICE NVLLVS
} }
> I > I
``` ```
`SI` statements may follow immediately after `ALUID`. `SI` statements may follow immediately after `ALVID`.
``` ```
DESIGNA x UT II DESIGNA x VT II
SI x EST I TUNC SI x EST I TVNC
DICE I DICE I
ALUID SI x EST II TUNC ALVID SI x EST II TVNC
DICE II DICE II
ALUID ALVID
DICE III DICE III
> II > II
@@ -150,16 +150,16 @@ ALUID
### Boolean operators ### Boolean operators
The keyword `ET` can be used as a boolean "and". The keyword `AUT` can be used as a boolean "or". The keyword `ET` can be used as a boolean "and". The keyword `AVT` can be used as a boolean "or".
``` ```
DESIGNA x UT VERITAS DESIGNA x VT VERITAS
DESIGNA y UT FALSITAS DESIGNA y VT FALSITAS
SI x ET y TUNC { SI x ET y TVNC {
DICE I DICE I
} ALUID SI x AUT y TUNC { } ALVID SI x AVT y TVNC {
DICE II DICE II
} ALUID { } ALVID {
DICE III DICE III
} }
@@ -167,23 +167,23 @@ SI x ET y TUNC {
``` ```
## Loops ## Loops
### DONICUM loops ### DONICVM loops
``` ```
DESIGNA x UT NULLUS DESIGNA x VT NVLLVS
DONICUM y UT NULLUS USQUE X FACE { DONICVM y VT NVLLVS VSQVE X FACE {
DESIGNA x UT x + y DESIGNA x VT x + y
} }
DICE x DICE x
> XLV > XLV
``` ```
### DUM loops ### DVM loops
``` ```
DESIGNA x UT NULLUS DESIGNA x VT NVLLVS
DUM x PLUS X FACE { DVM x PLVS X FACE {
DESIGNA x UT x+I DESIGNA x VT x+I
} }
DICE x DICE x
@@ -192,7 +192,7 @@ DICE x
### PER loops ### PER loops
``` ```
DESIGNA x UT [I, II, III, IV, V] DESIGNA x VT [I, II, III, IV, V]
PER y IN x FACE { PER y IN x FACE {
DICE y DICE y
} }
@@ -205,12 +205,12 @@ PER y IN x FACE {
``` ```
## Functions ## Functions
Functions are defined with the `DEFINI` and `UT` keywords. The `REDI` keyword is used to return. `REDI` must have exactly one parameter. `REDI` can also be used to end the program, if used outside of a function. Functions are defined with the `DEFINI` and `VT` keywords. The `REDI` keyword is used to return. `REDI` must have exactly one parameter. `REDI` can also be used to end the program, if used outside of a function.
Calling a function is done with the `INVOCA` keyword. Calling a function is done with the `INVOCA` keyword.
``` ```
DEFINI square x UT { DEFINI square x VT {
REDI (x*x) REDI (x*x)
} }
@@ -221,28 +221,28 @@ DICE (INVOCA square XI)
## Built-ins ## Built-ins
### DICE ### DICE
### AUDI ### AVDI
### AUDI_NUMERUS ### AVDI_NVMERVS
### ERUMPE ### ERVMPE
### LONGITUDO ### LONGITVDO
## Modules ## Modules
Modules are additions to the base `CENTVRION` syntax. They add or change certain features. Modules are included in your code by having Modules are additions to the base `CENTVRION` syntax. They add or change certain features. Modules are included in your code by having
```VOCA %MODULE NAME%``` ```VOCA %MODVLE NAME%```
In the beginning of your source file. In the beginning of your source file.
Unlike many other programming languages with modules, the modules in `CENTVRION` are not libraries that can be "imported" from other scripts written in the language. They are features of the compiler, disabled by default. Vnlike many other programming languages with modules, the modules in `CENTVRION` are not libraries that can be "imported" from other scripts written in the language. They are features of the compiler, disabled by default.
### FORS ### FORS
```VOCA FORS``` ```VOCA FORS```
The `FORS` module allows you to add randomness to your `CENTVRION` program. It adds 2 new built-in functions: `FORTIS_NUMERUS int int` and `FORTIS_ELECTIONIS ['a]`. The `FORS` module allows you to add randomness to your `CENTVRION` program. It adds 2 new built-in functions: `FORTIS_NVMERVS int int` and `FORTIS_ELECTIONIS ['a]`.
`FORTIS_NUMERUS int int` picks a random int in the (inclusive) range of the two given ints. `FORTIS_NVMERVS int int` picks a random int in the (inclusive) range of the two given ints.
`FORTIS_ELECTIONIS ['a]` picks a random element from the given array. `FORTIS_ELECTIONIS array` is identical to ```array[FORTIS_NUMERUS NULLUS ((LONGITUDO array)-I)]```. `FORTIS_ELECTIONIS ['a]` picks a random element from the given array. `FORTIS_ELECTIONIS array` is identical to ```array[FORTIS_NVMERVS NVLLVS ((LONGITVDO array)-I)]```.
### FRACTIO ### FRACTIO
```VOCA FRACTIO``` ```VOCA FRACTIO```
@@ -257,16 +257,16 @@ The symbol `|` can be used to denote that the following fraction symbols are 1 "
A single "set" of fraction symbols can only represent up to 11/12, as 12/12 can be written as 1. A single "set" of fraction symbols can only represent up to 11/12, as 12/12 can be written as 1.
### MAGNUM ### MAGNVM
```VOCA MAGNUM``` ```VOCA MAGNVM```
`MAGNUM` adds the ability to write integers larger than `MMMCMXCIX` (3.999) in your code, by adding the thousands operator, "`_`". `MAGNVM` adds the ability to write integers larger than `MMMCMXCIX` (3.999) in your code, by adding the thousands operator, "`_`".
When `_` is added _after_ a numeric symbol, the symbol becomes 1.000 times larger. The operator can be added to the same symbol multiple times. So "`V_`" is 5.000, and "`V__`" is 5.000.000. The strict rules for integers still apply, so 4.999 cannot be written as "`IV_`", but must instead be written as "`MV_CMXCIX`". When `_` is added _after_ a numeric symbol, the symbol becomes 1.000 times larger. The operator can be added to the same symbol multiple times. So "`V_`" is 5.000, and "`V__`" is 5.000.000. The strict rules for integers still apply, so 4.999 cannot be written as "`IV_`", but must instead be written as "`MV_CMXCIX`".
All integer symbols except `I` may be given a `_`. All integer symbols except `I` may be given a `_`.
### SUBNULLA ### SVBNVLLA
```VOCA SUBNULLA``` ```VOCA SVBNVLLA```
The `SUBNULLA` module adds the ability to write negative numbers as `-II` instead of `NULLUS-II`. The `SVBNVLLA` module adds the ability to write negative numbers as `-II` instead of `NVLLVS-II`.

View File

@@ -180,7 +180,7 @@ class Erumpe(BaseBox):
return "Erumpe()" return "Erumpe()"
def eval(self, vtable, ftable, _): def eval(self, vtable, ftable, _):
vtable["ERUMPE"] = True vtable["ERVMPE"] = True
return vtable, ftable return vtable, ftable
class Nullus(BaseBox): class Nullus(BaseBox):
@@ -213,9 +213,9 @@ class BinOp(BaseBox):
case "SYMBOL_DIVIDE": case "SYMBOL_DIVIDE":
# TODO: Fractio # TODO: Fractio
return left // right return left // right
case "KEYWORD_MINUS": case "KEYWORD_MINVS":
return left < right return left < right
case "KEYWORD_PLUS": case "KEYWORD_PLVS":
return left > right return left > right
case "KEYWORD_EST": case "KEYWORD_EST":
return left == right return left == right
@@ -266,11 +266,11 @@ class DumStatement(BaseBox):
vtable, ftable = statement.eval( vtable, ftable = statement.eval(
vtable, ftable, modules vtable, ftable, modules
) )
if vtable["ERUMPE"]: if vtable["ERVMPE"]:
break break
if vtable["ERUMPE"]: if vtable["ERVMPE"]:
vtable["ERUMPE"] = False vtable["ERVMPE"] = False
break break
return vtable, ftable return vtable, ftable
@@ -297,11 +297,11 @@ class PerStatement(BaseBox):
vtable, ftable = statement.eval( vtable, ftable = statement.eval(
vtable, ftable, modules vtable, ftable, modules
) )
if vtable["ERUMPE"]: if vtable["ERVMPE"]:
break break
if vtable["ERUMPE"]: if vtable["ERVMPE"]:
vtable["ERUMPE"] = False vtable["ERVMPE"] = False
break break
return vtable, ftable return vtable, ftable
@@ -349,15 +349,15 @@ class BuiltIn(BaseBox):
] ]
match self.builtin: match self.builtin:
case "AUDI_NUMERUS": case "AVDI_NVMERVS":
return num_to_int(input()) return num_to_int(input())
case "DICE": case "DICE":
print(' '.join(make_string(i) for i in parameters)) print(' '.join(make_string(i) for i in parameters))
return None return None
case "ERUMPE": case "ERVMPE":
vtable["ERUMPE"] = True vtable["ERVMPE"] = True
return None return None
case "FORTIS_NUMERUS": case "FORTIS_NVMERVS":
# TODO: Fors # TODO: Fors
return random.randint(parameters[0], parameters[1]) return random.randint(parameters[0], parameters[1])
case _: case _:
@@ -374,7 +374,7 @@ class Program(BaseBox):
return f"{modules_string},\n{statements_string}" return f"{modules_string},\n{statements_string}"
def eval(self): def eval(self):
vtable = {"ERUMPE": False} vtable = {"ERVMPE": False}
ftable = {} ftable = {}
modules = [module.module_name for module in self.modules] modules = [module.module_name for module in self.modules]

View File

@@ -3,37 +3,37 @@ from rply import LexerGenerator
valid_characters = '|'.join(list("abcdefghiklmnopqrstvxyz_")) valid_characters = '|'.join(list("abcdefghiklmnopqrstvxyz_"))
keyword_tokens = [("KEYWORD_"+i, i) for i in [ keyword_tokens = [("KEYWORD_"+i, i) for i in [
"ALUID", "ALVID",
"DEFINI", "DEFINI",
"DESIGNA", "DESIGNA",
"DONICUM", "DONICVM",
"DUM", "DVM",
"ERUMPE", "ERVMPE",
"EST", "EST",
"FACE", "FACE",
"FALSITAS", "FALSITAS",
"INVOCA", "INVOCA",
"IN", "IN",
"MINUS", "MINVS",
"NULLUS", "NVLLVS",
"PER", "PER",
"PLUS", "PLVS",
"REDI", "REDI",
"SI", "SI",
"TUNC", "TVNC",
"USQUE", "VSQVE",
"UT", "VT",
"VERITAS", "VERITAS",
"VOCA" "VOCA"
]] ]]
builtin_tokens = [("BUILTIN", i) for i in [ builtin_tokens = [("BUILTIN", i) for i in [
"AUDI_NUMERUS", "AVDI_NVMERVS",
"AUDI", "AVDI",
"DICE", "DICE",
"FORTIS_NUMERUS", "FORTIS_NVMERVS",
"FORTIS_ELECTIONIS", "FORTIS_ELECTIONIS",
"LONGITUDO" "LONGITVDO"
]] ]]
data_tokens = [ data_tokens = [
@@ -44,8 +44,8 @@ data_tokens = [
module_tokens = [("MODULE", i) for i in [ module_tokens = [("MODULE", i) for i in [
"FORS", "FORS",
"FRACTIO", "FRACTIO",
"MAGNUM", "MAGNVM",
"SUBNULLA" "SVBNVLLA"
]] ]]
symbol_tokens = [ symbol_tokens = [

20
main.py
View File

@@ -2,13 +2,23 @@ from lexer import Lexer
from parser import Parser from parser import Parser
text_input = """ text_input = """
DEFINI invoca i UT { VOCA FORS
REDI i
DESIGNA correct VT FORTIS_NVMERVS I C
DESIGNA gvess VT NVLLVS
DVM FALSITAS FACE {
DESIGNA gvess VT AVDI_NVMERVS
SI gvess MINVS correct TVNC {
DICE "Too low!"
} ALVID SI gvess PLVS correct TVNC {
DICE "Too high!"
} ALVID {
ERVMPE
}
} }
DESIGNA invoca UT I DICE "You guessed correctly!"
DICE (INVOCA invoca invoca)
""" """
lexer = Lexer().get_lexer() lexer = Lexer().get_lexer()

View File

@@ -11,7 +11,7 @@ class Parser():
self.pg = ParserGenerator( self.pg = ParserGenerator(
ALL_TOKENS, ALL_TOKENS,
precedence=[ precedence=[
('left', ["KEYWORD_PLUS", "KEYWORD_MINUS", "KEYWORD_EST"]), ('left', ["KEYWORD_PLVS", "KEYWORD_MINVS", "KEYWORD_EST"]),
('left', ["SYMBOL_PLUS", "SYMBOL_MINUS"]), ('left', ["SYMBOL_PLUS", "SYMBOL_MINUS"]),
('left', ["SYMBOL_TIMES", "SYMBOL_DIVIDE"]) ('left', ["SYMBOL_TIMES", "SYMBOL_DIVIDE"])
] ]
@@ -47,7 +47,7 @@ class Parser():
else: else:
return [calls[0]] + calls[2] return [calls[0]] + calls[2]
@self.pg.production('statement : KEYWORD_DESIGNA id KEYWORD_UT expression') @self.pg.production('statement : KEYWORD_DESIGNA id KEYWORD_VT expression')
def statement_designa(tokens): def statement_designa(tokens):
return ast_nodes.Designa(tokens[1], tokens[3]) return ast_nodes.Designa(tokens[1], tokens[3])
@@ -75,7 +75,7 @@ class Parser():
def expression_id(tokens): def expression_id(tokens):
return tokens[0] return tokens[0]
@self.pg.production('statement : KEYWORD_DEFINI id ids KEYWORD_UT SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL') @self.pg.production('statement : KEYWORD_DEFINI id ids KEYWORD_VT SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL')
def defini(tokens): def defini(tokens):
return ast_nodes.Defini(tokens[1], tokens[2], tokens[6]) return ast_nodes.Defini(tokens[1], tokens[2], tokens[6])
@@ -96,7 +96,7 @@ class Parser():
def expression_bool(tokens): def expression_bool(tokens):
return ast_nodes.Bool(tokens[0].name == "KEYWORD_VERITAS") return ast_nodes.Bool(tokens[0].name == "KEYWORD_VERITAS")
@self.pg.production('expression : KEYWORD_NULLUS') @self.pg.production('expression : KEYWORD_NVLLVS')
def expression_nullus(_): def expression_nullus(_):
return ast_nodes.Nullus() return ast_nodes.Nullus()
@@ -105,8 +105,8 @@ class Parser():
@self.pg.production('expression : expression SYMBOL_TIMES expression') @self.pg.production('expression : expression SYMBOL_TIMES expression')
@self.pg.production('expression : expression SYMBOL_DIVIDE expression') @self.pg.production('expression : expression SYMBOL_DIVIDE expression')
@self.pg.production('expression : expression KEYWORD_EST expression') @self.pg.production('expression : expression KEYWORD_EST expression')
@self.pg.production('expression : expression KEYWORD_MINUS expression') @self.pg.production('expression : expression KEYWORD_MINVS expression')
@self.pg.production('expression : expression KEYWORD_PLUS expression') @self.pg.production('expression : expression KEYWORD_PLVS expression')
def binop(tokens): def binop(tokens):
return ast_nodes.BinOp(tokens[0], tokens[2], tokens[1].name) return ast_nodes.BinOp(tokens[0], tokens[2], tokens[1].name)
@@ -132,15 +132,15 @@ class Parser():
def loops(tokens): def loops(tokens):
return tokens[0] return tokens[0]
@self.pg.production('statement : KEYWORD_ERUMPE') @self.pg.production('statement : KEYWORD_ERVMPE')
def erumpe(_): def erumpe(_):
return ast_nodes.Erumpe() return ast_nodes.Erumpe()
@self.pg.production('si_statement : KEYWORD_SI expression KEYWORD_TUNC SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL opt_newline aluid_statement') @self.pg.production('si_statement : KEYWORD_SI expression KEYWORD_TVNC SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL opt_newline aluid_statement')
def si(tokens): def si(tokens):
return ast_nodes.SiStatement(tokens[1], tokens[5], tokens[9]) return ast_nodes.SiStatement(tokens[1], tokens[5], tokens[9])
@self.pg.production('dum_statement : KEYWORD_DUM expression KEYWORD_FACE SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL') @self.pg.production('dum_statement : KEYWORD_DVM expression KEYWORD_FACE SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL')
def dum(tokens): def dum(tokens):
return ast_nodes.DumStatement(tokens[1], tokens[5]) return ast_nodes.DumStatement(tokens[1], tokens[5])
@@ -148,7 +148,7 @@ class Parser():
def per(tokens): def per(tokens):
return ast_nodes.PerStatement(tokens[3], tokens[1], tokens[7]) return ast_nodes.PerStatement(tokens[3], tokens[1], tokens[7])
@self.pg.production('donicum_statement : KEYWORD_DONICUM id KEYWORD_UT expression KEYWORD_USQUE expression KEYWORD_FACE SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL') @self.pg.production('donicum_statement : KEYWORD_DONICVM id KEYWORD_VT expression KEYWORD_VSQVE expression KEYWORD_FACE SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL')
def donicum(tokens): def donicum(tokens):
range_array = ast_nodes.DataRangeArray(tokens[3], tokens[5]) range_array = ast_nodes.DataRangeArray(tokens[3], tokens[5])
return ast_nodes.PerStatement(range_array, tokens[1], tokens[9]) return ast_nodes.PerStatement(range_array, tokens[1], tokens[9])
@@ -157,11 +157,11 @@ class Parser():
def aluid_empty(_): def aluid_empty(_):
return None return None
@self.pg.production('aluid_statement : KEYWORD_ALUID si_statement') @self.pg.production('aluid_statement : KEYWORD_ALVID si_statement')
def aluid_si(tokens): def aluid_si(tokens):
return [tokens[1]] return [tokens[1]]
@self.pg.production('aluid_statement : KEYWORD_ALUID SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL aluid_statement') @self.pg.production('aluid_statement : KEYWORD_ALVID SYMBOL_LCURL opt_newline statements opt_newline SYMBOL_RCURL aluid_statement')
def aluid(tokens): def aluid(tokens):
return tokens[3] return tokens[3]
@@ -173,7 +173,7 @@ class Parser():
def array(tokens): def array(tokens):
return ast_nodes.DataArray(tokens[1]) return ast_nodes.DataArray(tokens[1])
@self.pg.production('expression : SYMBOL_LBRACKET expression KEYWORD_USQUE expression SYMBOL_RBRACKET') @self.pg.production('expression : SYMBOL_LBRACKET expression KEYWORD_VSQVE expression SYMBOL_RBRACKET')
def range_array(tokens): def range_array(tokens):
return ast_nodes.DataRangeArray(tokens[1], tokens[3]) return ast_nodes.DataRangeArray(tokens[1], tokens[3])