mirror of
https://github.com/google/blockly.git
synced 2026-01-09 18:10:08 +01:00
Reduce more unneeded parentheses in JS and Python.
This commit is contained in:
@@ -59,8 +59,8 @@ Blockly.Python.addReservedWords(
|
||||
Blockly.Python.ORDER_ATOMIC = 0; // 0 "" ...
|
||||
Blockly.Python.ORDER_COLLECTION = 1; // tuples, lists, dictionaries
|
||||
Blockly.Python.ORDER_STRING_CONVERSION = 1; // `expression...`
|
||||
Blockly.Python.ORDER_MEMBER = 2; // . []
|
||||
Blockly.Python.ORDER_FUNCTION_CALL = 2; // ()
|
||||
Blockly.Python.ORDER_MEMBER = 2.1; // . []
|
||||
Blockly.Python.ORDER_FUNCTION_CALL = 2.2; // ()
|
||||
Blockly.Python.ORDER_EXPONENTIATION = 3; // **
|
||||
Blockly.Python.ORDER_UNARY_SIGN = 4; // + -
|
||||
Blockly.Python.ORDER_BITWISE_NOT = 4; // ~
|
||||
@@ -84,9 +84,26 @@ Blockly.Python.ORDER_NONE = 99; // (...)
|
||||
* @type {!Array.<!Array.<number>>}
|
||||
*/
|
||||
Blockly.Python.ORDER_OVERRIDES = [
|
||||
// (foo()).bar() -> foo().bar()
|
||||
// (foo()).bar -> foo().bar
|
||||
// (foo())[0] -> foo()[0]
|
||||
[Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_MEMBER]
|
||||
[Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_MEMBER],
|
||||
// (foo())() -> foo()()
|
||||
[Blockly.Python.ORDER_FUNCTION_CALL, Blockly.Python.ORDER_FUNCTION_CALL],
|
||||
// (foo.bar).baz -> foo.bar.baz
|
||||
// (foo.bar)[0] -> foo.bar[0]
|
||||
// (foo[0]).bar -> foo[0].bar
|
||||
// (foo[0])[1] -> foo[0][1]
|
||||
[Blockly.Python.ORDER_MEMBER, Blockly.Python.ORDER_MEMBER],
|
||||
// (foo.bar)() -> foo.bar()
|
||||
// (foo[0])() -> foo[0]()
|
||||
[Blockly.Python.ORDER_MEMBER, Blockly.Python.ORDER_FUNCTION_CALL]
|
||||
|
||||
// not (not foo) -> not not foo
|
||||
[Blockly.Python.ORDER_LOGICAL_NOT, Blockly.Python.ORDER_LOGICAL_NOT],
|
||||
// a and (b and c) -> a and b and c
|
||||
[Blockly.Python.ORDER_LOGICAL_AND, Blockly.Python.ORDER_LOGICAL_AND],
|
||||
// a or (b or c) -> a or b or c
|
||||
[Blockly.Python.ORDER_LOGICAL_OR, Blockly.Python.ORDER_LOGICAL_OR]
|
||||
];
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user