Skip to content

Accepting Numeric Input #2

Description

@profbrandon

When a digit or '.' is typed and the cursor's position is...

  • in a placeholder, populate the placeholder with a numeric expression.
    • x + _| becomes x + 4
  • inside a number, insert the character into the number.
    • y * 4|.35 becomes y * 46.35
  • in an infix binary operator or prefix operator and the next node is...
    • a placeholder, populate the placeholder with a numeric expression.
      • w -|_ becomes w - 9
      • (-|_) becomes (-9)
    • a number, append the character to the number.
      • z +|7 becomes x+17
      • (-|20) becomes (-120)
    • a variable and the operator is...
      • binary, insert a multiplication with a new number as the left child and the variable as the right child.
        • 6 -|x becomes 6 - 2 * x
        • 3 ^|a becomes 3 ^ (2 * a)
      • prefix, replace the unary operator with a multiplication between the unary operator with a new number and the variable.
        • (-|t) becomes (-4)*t

postfix operators: TBD

Note:
Should '.' be considered a binary operator? It would solve the issue of a numeric expression solely containing '.' being a legal expression, and potentially of it being inserted more than once into a single number. It would also create placeholders on either side.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

featureNew feature or request

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions