I am currently designing and implementing a small programming language as an extra-credit project in a class I'm taking. My problem is that the language has three numeric types: Long, Double, and Fraction. Fractions can be written in the language as proper or improper fractions (e.g. "2 1/3" or "1/2"). This fact leads to problems such as "2/3.5" (Long/Double) and "2/3"(Long/Long) not being handled correctly by the lexer.The best solution that I see is to change the division operator. So far, I think "\" is the best solution since "//" starts comments.
Would you pick "\", if you were designing the language?
Would you pick something else? If so, what?
Note: changing the way fractions are written is not possible.
Thanks in advance for your help,
Current operators are:
- (subtract and negation)
Note: I am under no strictly binding demands by my teacher; however, I basically convinced him that I could turn a simple fraction calculator into a language. Changing the fraction's syntax would go against the fraction calculator's syntax for fractions, which is preferably avoided.