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,
-EDIT-
Current operators are:
**
(power)
*
(multiply)
%
(modulus)
+
(add)
-
(subtract and negation)
~
(reciprocal)
!
(NOT)
>
(greater)
<
(less)
>=
(greater-equal)
<=
(less-equal)
==
(equality)
<>
(inequality)
&
(AND)
|
(OR)
^
(XOR)
??
(null-coalesing)
=
(assignment)
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.
The APL answer is ÷. I think that's recognizable.
How about a word "div"?
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With