Last modified 7 years ago Last modified on 2017-09-27 08:43:14

Base Ideas

(1) Namespaces

(1.1) Data Types

(2) Types

(3) Enums

(4) Signals

(5) Singletons

(6) Classes

(6.1) Finite State Machines

(7) Expression Syntax

This is just an area in which I'm exploring a simple expression syntax ...
I hope to determine which logic for expression is simply lexical, which goes in grammar, which in type system / checking. Add to this ideas of lexical hints, syntax hints, type hints and better error recovery etc etc etc

Here's an example of a simple syntax

operators := ( "+" | "-" | "*" | "/" | "%" | ":=" );
expression := 
  ( identifier
  | constant
  | operator /* monadic */ expression 
      ( operator /* diadic */ expression )
  | "(" expression ")"
  );

The above syntax should let you have any operator as either monadic or diadic ... and has no implicit precedence (ie the brackets are required to produce the precedence)

This doesn't take into account whether an identifer is or isn't mutable ... and takes no account of contants not being mutable.

What does all this this mean?

Well if we don't mind having expressions like

3 := fred + (2 * -15) + *thing

Then it's accepable.

Some improvement

OK, well if we sp;it the operators into monadic, diadic or both then hat might help things somewhat.

infixMonadics := ( "-" | "!" | "++" | "--" );

infixDiadics := ( "+" | "-" | "*" | "/" | "%" | ":=" | "==" );

infixTriadic := "?";

postfixMonadics := ( "++" | "--" );

typename := lexicalIdent [nameSpaceEnvironmentTypeCheck(LEX)];

bracedMonadic :=
  "«" typename "»"; // CASTING

surroundingMonadic := 
  ( "(" expression ")"  // precedence 
  | "|" expression "|"  // sizeof
  ) ;

constant := ( integerConstant | stringConstant | realConstant | lambdaConstant );

expression := 
  ( identifier
  | constant
  | ( infixMonadics expression
    | bracedMonadic "(" expression ")"
    | expression ( postfixMonadics )
    )
    ( ( inFixDiadics expression
      | infixTriadic expression ":" expression 
      | expression 
      ) )
  | surroundingMonadic
  );

which gives us the ability to specify a subset of monadic, diadic operators (infix notation) and a set of monadic braced expressions (apparently single parameter functions).

This would show up the following errors in the syntax and not in the type checking

freddy / * burt // ERROR at *, as * is not a monadic infix operator
arthur := «bool»(tom == 21) ? 1*2*dick : harry  // and triadics

(7.1) What about identifiers (Expression Syntax) ?

(7.2) Compile Time Type Checking

(8) Lambda Statements (Compound Statements)