(Apologies if this is an easy one, and also please let me know if there's a better way to do what I'm trying to do.)
I'm building a DSL in which one of my concepts (call it MyFunction) has a child that must either be a string literal or a concept that ultimately resolves to a string. I've set up a simple concept hierarchy like this:
-- StringLiteralExpression (has property "value" of type string)
And I've got the aforementioned original concept, MyFunction, has a child called value of type AbstractStringExpression (cardinality 1).
What I'm having trouble accomplishing is this: when the user is entering the "value" child of MyFunction, I'd like to have the editor infer that the value the user is entering is a string literal, either by the user starting out by typing double-quotes, or once the text the user enters clearly doesn't match the alias of any concept that descends from AbstractStringExpression, and subsequently automatically substitute a StringLiteralExpression node for the initially null AbstractStringExpression node.
I see that the "expressions" sample that ships with MPS does this for the initializer in variable declarations; the initial node is of concept Expression, but once you type a non-zero number it is automatically substituted to IntegerConstant, and if you subsequently enter a decimal, it is again substituted to FlatConstant. So I know that theoretically this type of inference and node substitution based on the user's input is possible, but I just can't seem to figure out how it is done.
Any input you can give me would be greatly appreciated.