---
Implement evaluator of string concatenation expressions.
Summary
The executable shall be passed two parameters:
A path to string function definitions
A path to string expressions
Kód: Vybrat vše
prog FUNCS_FILE EXPRS_FILE
Function Definitions File Composition
Each line contains a single function definition. A single line shall be as follows:
Kód: Vybrat vše
FUNCTION_NAME ARGS = BODY
Examples:
Kód: Vybrat vše
foo x = x
goo x y = y x
hoo a b c = a a a
Each line contains a single string expression. A single line shall be as follows:
Kód: Vybrat vše
FUNCTION_NAME(ARG1,ARG2,...,ARGN)
Example:
Kód: Vybrat vše
foo("ahoj")
goo("a","b")
hoo(foo("ahoj"),goo("l","m"),"x")
The program shall process function definitions file and print value of each string expression on separate line. The value is computed by passing arguments to the functions and concatenating strings as specified by the body of the function definitions.
The solution using the examples above as file contents:
Kód: Vybrat vše
prog funcs.txt exprs.txt
Kód: Vybrat vše
ahoj
b a
ahoj ahoj ahoj
When program encounters a malformed line (bad function name, no equals sign, malformed expression), it shall print parse error to standard output.
Other errors
- when BODY contains word not present in ARGS - print def error to standard output
- when an expression contains an undefined function name - print nodef error to standard output
- when a function is called with incorrect number of parameters - print param error to standard output
When the program encounters erroneous line, it prints error message and continues processing other lines.