Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Group terminals into set

Group terminals into sets

What does this warning mean ? How do I solve it ?

Here is the code I am referring to

expression : expression operator=DIV expression
           | expression operator=MUL expression
           | expression operator=ADD expression
           | expression operator=SUB expression
           | INT
           | FLOAT
           | BOOLEAN
           | NULL
           | ID
           ;
like image 917
Gautam Avatar asked Apr 26 '13 09:04

Gautam


People also ask

Can you open two Mac terminals?

You can open new Terminal windows and tabs with the default profile, the same profile used by the active window or tab, or a profile you specify. Use the General preferences pane to choose the profiles used when opening new windows and tabs.

How do I merge Windows terminals?

The answer is to hold down command + shift + option whilst dragging the body of the terminal (not the tab) back to the terminal you wish to merge.


1 Answers

The ANTLR 4 parser generator can combine groups of transitions to form a single "set transition" in certain cases, reducing static and dynamic memory overhead as well as improving runtime performance. This can only occur if all alternatives of a block contain a single element or set. For example, the following code allows INT and FLOAT to be combined into a single transition:

// example 1
number
    :   INT
    |   FLOAT
    ;

// example 2, elements grouped into a set
primary
    :   '(' expression ')'
    |   (INT | FLOAT)
    ;

However, in the following situation the elements cannot be combined by the compiler so they'll be treated separately:

primary
    :   '(' expression ')'
    |   INT
    |   FLOAT
    ;

The hint suggests places where the simple addition of ( ... ) is enough to allow the compiler to collapse a set that it would otherwise not be able to. Altering your code to the following would address the warning.

expression
    :   expression operator=DIV expression
    |   expression operator=MUL expression
    |   expression operator=ADD expression
    |   expression operator=SUB expression
    |   (   INT
        |   FLOAT
        |   BOOLEAN
        |   NULL
        |   ID
        )
    ;
like image 175
Sam Harwell Avatar answered Sep 29 '22 07:09

Sam Harwell