#P3695. CYaRon!语
CYaRon!语
Description
Below is a typical CYaRon! language program.
{ vars
chika:int
you:int
ruby:array[int, 1..2]
i:int
}
# All the above variables have a default value of 0.
# Variable names can only be English letters.
# The yosoro statement outputs a number followed by a space.
:yosoro 2
# Outputs 2 and a space (we will no longer mention the space below).
# The set statement assigns a value to a variable.
# Only addition and subtraction operators are supported.
:set chika, 1
:set you, 2
:yosoro chika + you
# The previous statement outputs 3.
# The following conditional statements all use this format:
# operator, expression, expression
# For example, eq, a, 1 means a == 1 in the C language.
# All operators include: lt: < gt: > le: <= ge: >= eq: == neq: !=
# The three from Japan cannot pronounce "if" correctly, so they changed it to "ihu".
{ ihu eq, chika, 1
:set you, 3
:yosoro 1
}
# Outputs 1.
# The above is an ihu statement; else is not required.
# The hor statement is similar,
# it corresponds to: for i = 1 to you
{ hor i, 1, you
:yosoro i
}
# Outputs 1 2 3
# Below is how to use while and arrays.
:set i, 1
{ while le, i, 2
:yosoro i
:set ruby[i], i+1
:yosoro ruby[i]
:set i, i+1
}
# Outputs 1 2 2 3
# Arrays will not be nested, i.e., you will only have a[i], a[i+2], and not something like a[i + b[i]].
# The last line of a CYaRon! program must be a newline.
Your task is to write an interpreter for the CYaRon! language. Read a CYaRon! program from input, execute it by interpretation, and output the execution result.
Input Format
The input file is entirely a CYaRon! language program, and the last line is guaranteed to be an empty line.
When reading the input, keep reading until EOF.
Output Format
The execution result of the CYaRon! language program.
Specifically, it is the outputs of all :yosoro statements in the program.
{ vars
a:int
b:int
}
:set a, 1
:set b, 2
:yosoro a+b
3
Hint
We guarantee the following about the testdata:
-
The input is guaranteed to be a valid CYaRon! language program, without comments. The code style and indentation (four spaces) match the sample above. However, the number and presence of spaces before commas and operators are not guaranteed to be the same.
-
Variable names are fewer than 10 characters and contain only lowercase English letters. The maximum array size is 1000. The maximum number of variables is 50. The result of every expression, including variable values, is guaranteed to fit in the int range. (However, arrays may have ranges like [2001..3000], and indices may range from 0 up to 1e8.)
-
All instructions are lowercase.
-
The program is guaranteed to finish within reasonable time and memory limits.
-
During the execution of a hor statement, the loop variable, the initial value, and the end value will not be changed by the code inside the loop.
-
The program has at most 500 lines.

Translated by ChatGPT 5
京公网安备 11011102002149号