Literals, operators, expressions, and statements are language elements that found imperative approach in Paml.
Literals
Paml defines built-in literals only for values, and the literal syntax is similar to JSON. The feature is that there are no built-in data types (and corresponding keywords) and literals are just tokens that Paml distinguishes. Actual data types are specified from a domain and are targets for transformations or passed to output code as is.
- Number: 123.5
- String: "This is a text."
- Bool: false, true
- Composite value: {}
- Collection: []
- Routine
I'm not sure that missing built-in data types is possible to define proper language grammar and parser, so for now the feature is in research mode and can be changed in future when other language features will be designed.
Operators
Since no explicit built-in data types are defined in Paml, there is no explicit arithmetic or any other operators, all operators are symbolic operators.
A symbolic operator is a "free text" token of some syntax from a domain. Paml models do not distinguish the semantics of a symbolic operator until a transformation applied to the operator defines its implementation, and as result its semantics.
A symbolic operator is a join point, so a transformation can (and probably should) be applied to the operator.
The operands of symbolic operators can be objects and values. The actual syntax and semantics are verified by the compiler of the output language like C#.
For symbolic operators, round braces and comma characters are important, so these characters cannot be used in symbolic operators (as well as other Paml reserved keywords and symbols).
Symbolic operators are an abstraction for any operations on any values and objects. Actual syntax of a symbolic operator can be a token. The idea is that styling features also can be available for operator syntax, like superscripts or anything else.
Symbolic operators can be of 3 types: unary prefix and postfix operators, binary operators, and N-nary prefix operators.
- Symbolic operators can consist of (almost) any characters and should be marked via text styling.
- Variable names can also have rich font styling.
- In IDE, hovering symbolic operators should highlight its operands. The code below simulates the highlighting only operators themselves.
Expressions
An expression is a something that has a type and can be put into the right part of an assignment operator.
Expressions can be arguments for messages and routines parameters.
- Object variable
- Value variable
- Reading (accessing) a value item of value or object
- "object instance" expression
- Value literal
- Sending a message with returning a value
- Calling a shared routine with returning value or object
- Symbolic operators
- Routines
Statements
So far it seems that in models only "if" statement for control flow is required, so explicit cycle statements such as "for" or "while" can be redundant.
Missing explicit cycle statements is also in research mode.
- Object variable declaration
- Object variable declaration and initialization with "object instance" expression
- Value variable declaration
- Value variable declaration and initialization with value literal
- Sending a message to an object
- Reading a value item
- Shared routine call
- Assignment object variable
- Assignment value variable or value item
- Return statement
- If statement
- Expression statement
Write a comment