Skip to content

Latest commit

 

History

History
194 lines (135 loc) · 7.22 KB

ideas.md

File metadata and controls

194 lines (135 loc) · 7.22 KB

IF statement logic

FOR (commands;) {statements}

WHILE (condition) {statements}

IF (condition) {statements}

ELSEIF  (condition)     {statements}   ...

ELSE                    {statements}

DO {statements} WHILE/UNTIL (condition)

TRY {statements} CATCH [exception],{statements} ... FINALLY {statements}

after detecting the keyword, BEGIN with "\G" (and not any invalid chars) END with "(" (or any invalid chars, maybe just any "\S") PATTERNS available switches notCode

This will these items to just immediately after the keyword.

begin when a ( is coming end with any character not processed or an end of line begin with the ( (with \G) end when the ) is coming process inner condition in command_mode begin with the ) end with any character not processed or an end of line advancedToToken begin when a { is coming end with any character not processed or an end of line begin with the { (with \G) end with the } process inner condition in $self begin when just past } AND NOT followed by } end with any character not processed or an end of line advancedToToken begin with elseif end with any character not processed or an end of line advancedToToken begin when a ( is coming end with any character not processed or an end of line begin with the ( (with \G) end when the ) is coming process inner condition in command_mode begin with the ) end with any character not processed or an end of line advancedToToken begin when a { is coming end with any character not processed or an end of line begin with the { (with \G) end when the } is coming process inner condition in $self begin with else end with any character not processed or an end of line advancedToToken begin when a ( is coming end with any character not processed or an end of line begin with the ( (with \G) end when the ) is coming process inner condition in command_mode begin with the ) end with any character not processed or an end of line advancedToToken begin when a { is coming end any character not processed or an end of line begin with the { (with \G) end with } process inner condition in $self

ESLEIF needs to loop, be recursive, on its own ELSE needs to be the last chance to match, this might beed to be done in the root of IF. Need to not get caught on nested IF's that close together, need to make sure to completely close out of one statement, so the end of the next one can be detected!

Its possible that either an expression is ending ) or a scriptblock is ending }. Its also possible a new expression ( or a new scriptblock { may follow. Recursive to $SELF is the only way to prevent refire of ( or {

This mean ELSE and ELSEIF must both be found recursively, so the syntax always moves forward until there is a clearly delimiting character (in this case, a line end)

Remember, use begin when something is next, end when !\G to return immediately after the end.

<---------------------> repeatable IF(cond){statements}ELSEIF(cond){statments} ^^^^^^ Optional, but terminates repeating without it ELSE{statements} <- alternate ending

AdvanceToToken Begin when ( is next End with any character not processed or end of line include common (cond){statements}ELSEIF patterns Begin with ELSE

complex argument scoping. arguments that start with a variable reference need to process first variable, if it possesses a member or index reference, the argument ends at the end of the reference. If there is no reference, then the argument is an unquoted expandable string, for which further embedded variables cannot reference members. arguments that start with a .$ actually represent two arguments. . becomes its own argument. All other unquoted arguments are expandable strings. Embedded variables cannot reference variables. An argument that starts with a substatement, the substatement is its own argument.

Redesign Expression Mode

Expression Mode =

expression [{;} or {|} or {&}]

Note: expression mode is really just the starter to expressions from command mode. Many other points would start with subexpression.

expression =

operand-expression [operator subexpression]

    or

operand-property assignment command

    or

operand-expression range-operator operand-expression [operator subexpression]

note: assignment is a special case operator that is technically equivelent to a post unary operator, but is binary, and accepts a result from a command (which can in turn be an expression which could lead to another assignment).

Unfortunately range-operator is a special case operator, because it precludes assignment, it needs to be included with other assignments, but it also needs to be included with other subexpressions. It might need to be its own item and included in a higher level group.

subexpression =

operand-expression [operator subexpression]

operand-expression =

operand [post-unary-operator]

operand =

[pre-unary-operator] operand

    or

operand-property

operand-property

{{scriptblock} or {variable} or {numeric-constant} or {group-expression} or {quotedstring} or {hashtable-expression} or {array-expression} or {substatement}} [accessor operand]

Note: operand is recursive, thus multiple pre-unary operators may appear before a single operand, an operand is complete once an operand-property is detected. Also: operand-expression is reusable for sub-operands like argument is, such as for a hashtable key.

Post unary operators must only detect once after an operand expression. This is because they are technically a form of assignment.

Consider: Accessors are a form of post unary operator. It would probably simplify things if accessors were patterns of operand, because the entire accessor expression can then have a post unary operator applied.

Consider: [type] casts are a form of pre-unary operator.

Types and Attributes

[ type_or_attribute [ subtype ], [ subtype ]

OR

    (
        Attribute arguments list [, more ...]
    )

]

In an attribute arguments, named_argument = [argument value] [, ...] argument_value [, ...]

named_argument follows typical property name rules argument_value must be constant expression (expression mode)