(FB, or Functional-Basic, as found here Interpret Functional-Basic)
Identifiers can only have upper and lower case ASCII letters.
- The identifier right after a
- The identifier in a
for (? in b) <-- ? is invalid let b_b8 = ... <-- b_b8 is invalid
If you encounter an identifier that has not been defined in either a
let expression or a
for loop. Note that the identifier in a for loop only count in the expression following it.
- Anywhere an identifier is used
let b = a <-- nope for (x in a) x+1 <-- nope, still don't know what `a` is print x <-- gotcha! `x` is out of scope here
End of line is the deliminator for statements in FB, so you can't have a statement span multiple lines (even if it's surrounded by parenthesis
()). Use this if you expected more but encountered a EOL char.
- Any line
let b <-- missing the `= [statement]` for ( <-- missing `x in y) [statement]` print <-- print what? print print sum <-- sum what?
This is best explained by examples.
- Any line
print * 2 <-- What is `*2` doing for me? I need a statement! 3**5 <-- `3*` expects a number, not a `*` symbol for x in y <-- a little diffrent, but for expects a pren `(`, not x
Used when a list is expected and a number was encountered, or when a number is needed and you get a list. Lists in FB are only allowed to have numbers or other lists as children, so errors can occur here as well. Note that if you find an identifier that is valid, you should perform this check based on the id's type.
- Function application
- List literal creation
let y =  let z = y + [, ] <-- invalid, y is a list of numbers, right hand side is a list of lists print y + 1 <-- y is a list, not a number sum 1 <-- sum takes a list, not a number  -  <-- invalid, subtraction doesn't apply to lists 1 +  <-- addition doesn't work with a list and a number for (digit in 12) ... <-- `for` takes a list let list = [00, 00] let nlst = [list, 1] <-- invalid [1, ] <-- invalid
This is when a
for loop or
let statements identifiers overlap with a currently defined identifier.
- In a
- In a
let y = 8 let y = 5 <-- invalid, y is already defined for (y in ) <-- invalid, y is already defined for (x in ) ... let x = 8 <-- valid since the `x` in the for loop is out of scope
Nested for loop
Again, pretty self explanatory. FB doesn't allow nested for loops.
for (x in [[1, 5], [2, 8]]) for (y in x) x*y <-- just invalid
If you are writing a function, you will receive one multi-line string. If you are writing a full program, you must take a multi-line input.
Output format is simply the error title, followed by the line number the error occurs on. You must show all errors in the program.
[error title] on line [line number, 1-indexed]
This is one large example that should show all possible error types and outputs. Please let me know if I missed something.
let bb8 = 0 let bbEight = lst for (x in let x = 5*/5 let y = 4 let z = [5, 6] + y let y = [] + [y] for (x in [[y, y+1], 5]) for (y in x)
Invalid identifier on line 1 Undefined identifier on line 2 Unexpected EOL on line 4 Unexpected token on line 5 Improper type on line 6 Improper type on line 7 Multiple assignment on line 7 Nested for loop on line 8 Multiple assignment on line 8 Multiple assignment on line 8 Improper type on line 8 Unexpected EOL on line 8
Note that thees checks may come in any order, and if the same error occurs multiple times on the same line, you must print the error multiple times as well.
I hope this isn't to difficult
I have removed the
Empty line error since it didn't make sense, and nobody is working on the problem (to my knowledge).