diff --git a/playground/examples/shift_operation.qut b/playground/examples/shift_operation.qut new file mode 100644 index 0000000..2bd95b4 --- /dev/null +++ b/playground/examples/shift_operation.qut @@ -0,0 +1,11 @@ +//Generic Rotation Algorithm (|b| = any) +qustring b = "110111"; //111011 -> 111110 +print b; +b << 1; +print b; + +//Pavone-Viola Rotation Algorithm (|c| = 2^p) +qustring c = "11011111"; //111011 -> 111110 +print c; +c << 1; +print c; \ No newline at end of file diff --git a/specification/grammar/qutes_lexer.g4 b/specification/grammar/qutes_lexer.g4 index a8a7261..3f13a04 100644 --- a/specification/grammar/qutes_lexer.g4 +++ b/specification/grammar/qutes_lexer.g4 @@ -41,6 +41,8 @@ GREATER : '>' ; GREATEREQUAL : '>=' ; LOWER : '<' ; LOWEREQUAL : '<=' ; +LSHIFT : '<<' ; +RSHIFT : '>>' ; ASSIGN : '=' ; AUTO_INCREMENT : '++' ; AUTO_DECREMENT : '--' ; diff --git a/specification/grammar/qutes_parser.g4 b/specification/grammar/qutes_parser.g4 index dcc8c9d..29951ba 100644 --- a/specification/grammar/qutes_parser.g4 +++ b/specification/grammar/qutes_parser.g4 @@ -34,7 +34,7 @@ variableDeclaration : variableType variableName (ASSIGN expr)? ; -expr +expr // Order: https://en.wikipedia.org/wiki/Order_of_operations#Programming_languages : ROUND_PARENTHESIS_OPEN expr ROUND_PARENTHESIS_CLOSE #ParentesizeExpression | literal #LiteralExpression | qualifiedName #QualifiedNameExpression @@ -45,6 +45,7 @@ expr // cast operation | expr op=(MULTIPLY | DIVIDE | MODULE) expr #MultiplicativeOperator | expr op=(ADD | SUB) expr #SumOperator + | expr op=(LSHIFT | RSHIFT) expr #ShiftOperator | expr op=(GREATEREQUAL | LOWEREQUAL | GREATER | LOWER ) expr #RelationalOperator | expr op=(EQUAL | NOT_EQUAL) expr #EqualityOperator | expr op=AND expr #LogicAndOperator diff --git a/src/grammar_frontend/operation.py b/src/grammar_frontend/operation.py index ff77c21..f8e6e69 100644 --- a/src/grammar_frontend/operation.py +++ b/src/grammar_frontend/operation.py @@ -25,7 +25,10 @@ def visitMultiplicativeOperator(self, ctx:qutes_parser.MultiplicativeOperatorCon return self.__visit_binary_operator(ctx) def visitSumOperator(self, ctx:qutes_parser.SumOperatorContext): - return self.__visit_binary_operator(ctx) + return self.__visit_binary_operator(ctx) + + def visitShiftOperator(self, ctx:qutes_parser.ShiftOperatorContext): + return self.__visit_binary_operator(ctx) def visitRelationalOperator(self, ctx:qutes_parser.RelationalOperatorContext): return self.__visit_boolean_operation(ctx) @@ -75,6 +78,27 @@ def __visit_binary_operator(self, ctx:qutes_parser.SumOperatorContext | qutes_pa if (first_term_symbol and QutesDataType.is_quantum_type(first_term_symbol.symbol_declaration_static_type)): pass result = first_term_value - second_term_value + if(isinstance(ctx, qutes_parser.ShiftOperatorContext)): + if(ctx.LSHIFT()): + if (first_term_symbol and QutesDataType.is_quantum_type(first_term_symbol.symbol_declaration_static_type)): + if(second_term_symbol and not QutesDataType.is_quantum_type(second_term_symbol.symbol_declaration_static_type)): + from quantum_circuit.qutes_gates import QutesGates + self.quantum_circuit_handler.push_compose_circuit_operation(QutesGates.left_rot(len(first_term_symbol.quantum_register), second_term_value, 1), [first_term_symbol.quantum_register]) #TODO: handle block size + result = first_term_symbol + else: + raise NotImplementedError("Left shift operator doesn't support second term to be a quantum variable.") + else: + result = first_term_value << second_term_value + if(ctx.RSHIFT()): + if (first_term_symbol and QutesDataType.is_quantum_type(first_term_symbol.symbol_declaration_static_type)): + if(second_term_symbol and not QutesDataType.is_quantum_type(second_term_symbol.symbol_declaration_static_type)): + from quantum_circuit.qutes_gates import QutesGates + self.quantum_circuit_handler.push_compose_circuit_operation(QutesGates.right_rot(len(first_term_symbol.quantum_register), second_term_value, 1), [first_term_symbol.quantum_register]) #TODO: handle block size + result = first_term_symbol + else: + raise NotImplementedError("Right shift operator doesn't support second term to be a quantum variable.") + else: + result = first_term_value >> second_term_value if(isinstance(ctx, qutes_parser.MultiplicativeOperatorContext)): if(ctx.MULTIPLY()): if (first_term_symbol and QutesDataType.is_quantum_type(first_term_symbol.symbol_declaration_static_type)): @@ -278,7 +302,7 @@ def visitGroverOperator(self, ctx:qutes_parser.GroverOperatorContext): if(n_element_to_rotate.is_integer() and utils.is_power_of_two(int(n_element_to_rotate))): logn = max(int(math.log2(n_element_to_rotate)),1) else: - logn = max(int(math.log2(n_element_to_rotate)+1),1) #TODO: non working with pavone-viola cycling rotation gate + logn = max(int(math.log2(n_element_to_rotate))+1,1) if(term_to_quantum.size == 1): if(phase_kickback_ancilla == None): @@ -309,7 +333,7 @@ def visitGroverOperator(self, ctx:qutes_parser.GroverOperatorContext): if (any_positive_results): if(self.log_grover_esm_rotation and rotation_register.measured_classical_register is not None): for result in positive_results: - print(f"Solution found with rotation {int(rotation_register.measured_classical_register.measured_values[result[0]], 2)}") + print(f"Solution found with {int(rotation_register.measured_classical_register.measured_values[result[0]], 2)} left rotations") # print(f"Solution found with rotation {int(rotation_register.measured_classical_register.measured_values[result[0]], 2) % (n_element_to_rotate)}") return self.variables_handler.create_anonymous_symbol(QutesDataType.bool, True, ctx.start.tokenIndex) registers_to_measure.remove(oracle_result) diff --git a/src/quantum_circuit/quantum_circuit_handler.py b/src/quantum_circuit/quantum_circuit_handler.py index 5eb74ec..09a7a76 100644 --- a/src/quantum_circuit/quantum_circuit_handler.py +++ b/src/quantum_circuit/quantum_circuit_handler.py @@ -315,7 +315,7 @@ def push_ESM_operation(self, input:QuantumRegister, rotation_register:QuantumReg self.push_equals_operation(input[:to_match_len], to_match) for i in range(len(rotation_register))[::-1]: - self.push_compose_circuit_operation(QutesGates.crot(array_len,2**i,Qustring.default_char_size).inverse(), [rotation_register[i], *input]) + self.push_compose_circuit_operation(QutesGates.crot(array_len, 2**i, block_size).inverse(), [rotation_register[i], *input]) # It expects the register to put the result into to be the last one in the list grover_count = iter(range(1, 1000)) diff --git a/src/quantum_circuit/qutes_gates.py b/src/quantum_circuit/qutes_gates.py index b5e2394..188f06b 100644 --- a/src/quantum_circuit/qutes_gates.py +++ b/src/quantum_circuit/qutes_gates.py @@ -4,7 +4,7 @@ from quantum_circuit.quantum_circuit_handler import QuantumCircuitHandler from symbols.types import Qubit, Quint, Qustring, QutesDataType from qiskit.circuit.library import GroverOperator -import math +import math, utils class QutesGates(): def __init__(self, ciruit_handler : QuantumCircuitHandler, variables_handler : 'VariablesHandler'): @@ -75,26 +75,65 @@ def sum(self, var_a_symbol:'Symbol', var_b_symbol:'Symbol') -> 'Symbol': return result_symbol #Rotation gate (not controlled), k=2^p - def rot(n, k, block_size=1): - qc = QuantumCircuit(n, name=f'rot_k={k}') - stop = (int(math.log2(n)) - int(math.log2(k*block_size)) + 2) - for i in range(block_size, stop): - for j in range(0, int(n/(k*(2**i)))): - for x in range(j*k*(2**i), k*((j*2**i+1))): - for offset in range(block_size): - inizio_swap = x + k*offset - fine_swap = x + 2**(i-1)*k + k*offset - qc.swap(inizio_swap, fine_swap) - - #qkt.draw_circuit(qc) - rot_gate = qc.to_gate(label='Rot_'+str(k)) + def left_rot_power_2(n, k, block_size=1): + qc = QuantumCircuit(n, name=f'rot_power_2_of_{k}') + if(k > 0): + stop = (int(math.log2(n)) - int(math.log2(k*block_size)) + 2) + for i in range(block_size, stop): + for j in range(0, int(n/(k*(2**i)))): + for x in range(j*k*(2**i), k*((j*2**i+1))): + for offset in range(block_size): + inizio_swap = x + k*offset + fine_swap = x + 2**(i-1)*k + k*offset + qc.swap(inizio_swap, fine_swap) + # print(qc.draw(output='text')) + rot_gate = qc.to_gate(label=f'rot_power_2_of_{k}') + return rot_gate + + #Rotation gate (not controlled), k=any + def right_rot_generic(n, k, block_size=1): + qc = QuantumCircuit(n, name=f'rot_generic_of_{k}') + if(k > 0): + for w in range(k): + for i in range(0, n-1, block_size): + for j in range(block_size): + qc.swap((i+j)%n, (i+j+1)%n) + # print(qc.draw(output='text')) + rot_gate = qc.to_gate(label=f'rot_generic_of_{k}') return rot_gate #Controlled Rotation gate def crot(n, k, block_size=1): - # Creiamo il gate di rotazione come prima - rot_gate = QutesGates.rot(n, k, block_size) - # Aggiungiamo un qubit di controllo al gate per renderlo controllato + rot_gate = QutesGates.left_rot(n, k, block_size) c_rot_gate = rot_gate.control(1) return c_rot_gate + + #Right Rotation gate + def right_rot(n, k, block_size=1): + rot_gate = QutesGates.identity(n) + if(utils.is_power_of_two(n)): + if(utils.is_power_of_two(k)): + rot_gate = QutesGates.left_rot_power_2(n, k, block_size).inverse() + else: + # TODO: if k is not power of 2, but n is, then we need to compose multiple left_rot_power_2 + rot_gate = QutesGates.right_rot_generic(n, k, block_size) + else: + rot_gate = QutesGates.right_rot_generic(n, k, block_size) + return rot_gate + + #Left Rotation gate + def left_rot(n, k, block_size=1): + rot_gate = QutesGates.identity(n) + if(utils.is_power_of_two(n)): + if(utils.is_power_of_two(k)): + rot_gate = QutesGates.left_rot_power_2(n, k, block_size) + else: + # TODO: if k is not power of 2, but n is, then we need to compose multiple left_rot_power_2 + rot_gate = QutesGates.right_rot_generic(n, k, block_size).inverse() + else: + rot_gate = QutesGates.right_rot_generic(n, k, block_size).inverse() + return rot_gate + + def identity(n): + return QuantumCircuit(n, name=f'identity_{n}').to_gate(label=f'identity_{n}') \ No newline at end of file diff --git a/src/qutes_antlr/qutes_lexer.py b/src/qutes_antlr/qutes_lexer.py index 28cce84..a1650d4 100644 --- a/src/qutes_antlr/qutes_lexer.py +++ b/src/qutes_antlr/qutes_lexer.py @@ -10,7 +10,7 @@ def serializedATN(): return [ - 4,0,75,645,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5, + 4,0,77,655,6,-1,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5, 2,6,7,6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2, 13,7,13,2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7, 19,2,20,7,20,2,21,7,21,2,22,7,22,2,23,7,23,2,24,7,24,2,25,7,25,2, @@ -22,55 +22,56 @@ def serializedATN(): 58,2,59,7,59,2,60,7,60,2,61,7,61,2,62,7,62,2,63,7,63,2,64,7,64,2, 65,7,65,2,66,7,66,2,67,7,67,2,68,7,68,2,69,7,69,2,70,7,70,2,71,7, 71,2,72,7,72,2,73,7,73,2,74,7,74,2,75,7,75,2,76,7,76,2,77,7,77,2, - 78,7,78,2,79,7,79,2,80,7,80,1,0,1,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1, - 1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,3,1,3,1,3,1,3,1,3,1,3,1,4,1,4,1,4, - 1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,6,1,6,1,6,1,6, - 1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8,1,8,1,8,1,8,1,9,1,9, - 1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,14,1,14,1,14,1,14,1,15, - 1,15,1,15,1,15,1,16,1,16,1,16,1,17,1,17,1,17,1,18,1,18,1,18,1,18, - 1,18,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,20,1,20,1,20,1,20,1,20, - 1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21,1,22,1,22,1,22,1,22, - 1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,25,1,25,1,25,1,25,1,26, - 1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,27,1,27,1,27,1,27,1,27, - 1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28,1,29,1,29,1,29,1,29, - 1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,31,1,31,1,31,1,32,1,32,1,33, - 1,33,1,33,1,34,1,34,1,35,1,35,1,35,1,36,1,36,1,37,1,37,1,37,1,38, - 1,38,1,38,1,39,1,39,1,39,1,40,1,40,1,40,1,41,1,41,1,41,1,42,1,42, - 1,42,1,43,1,43,1,43,1,44,1,44,1,45,1,45,1,45,1,45,1,46,1,46,1,46, - 1,46,1,47,1,47,1,47,1,47,1,47,1,47,1,47,1,48,1,48,1,48,1,49,1,49, - 1,49,1,49,1,49,1,49,1,50,1,50,1,50,1,51,1,51,1,51,1,51,1,51,1,52, - 1,52,1,52,1,52,1,52,1,52,1,53,1,53,1,53,1,54,1,54,1,55,1,55,1,56, - 1,56,1,57,1,57,1,58,1,58,1,59,1,59,1,60,1,60,1,61,1,61,1,62,1,62, - 1,63,1,63,1,63,1,63,5,63,420,8,63,10,63,12,63,423,9,63,1,63,1,63, - 1,63,1,63,1,63,1,63,5,63,431,8,63,10,63,12,63,434,9,63,3,63,436, - 8,63,1,64,1,64,1,64,1,64,1,64,1,65,1,65,1,65,1,65,1,65,1,65,1,66, - 1,66,1,67,1,67,1,68,1,68,1,68,1,68,1,68,1,68,1,68,1,68,1,68,1,68, - 1,68,1,68,3,68,465,8,68,1,69,1,69,1,69,3,69,470,8,69,1,70,3,70,473, - 8,70,1,70,4,70,476,8,70,11,70,12,70,477,1,71,3,71,481,8,71,1,71, - 4,71,484,8,71,11,71,12,71,485,1,71,1,71,5,71,490,8,71,10,71,12,71, - 493,9,71,1,71,3,71,496,8,71,1,71,1,71,4,71,500,8,71,11,71,12,71, - 501,3,71,504,8,71,1,72,1,72,1,72,1,72,4,72,510,8,72,11,72,12,72, - 511,1,73,1,73,1,73,4,73,517,8,73,11,73,12,73,518,1,74,1,74,1,74, - 3,74,524,8,74,1,74,1,74,5,74,528,8,74,10,74,12,74,531,9,74,1,74, - 1,74,3,74,535,8,74,3,74,537,8,74,1,74,1,74,1,74,1,74,1,74,1,74,1, - 74,1,74,1,74,1,74,3,74,549,8,74,1,74,1,74,3,74,553,8,74,1,74,3,74, - 556,8,74,1,75,1,75,1,75,1,75,1,75,5,75,563,8,75,10,75,12,75,566, - 9,75,1,75,1,75,5,75,570,8,75,10,75,12,75,573,9,75,1,75,1,75,1,75, - 1,75,1,75,1,75,5,75,581,8,75,10,75,12,75,584,9,75,1,75,1,75,5,75, - 588,8,75,10,75,12,75,591,9,75,1,75,1,75,1,75,1,75,3,75,597,8,75, - 1,75,4,75,600,8,75,11,75,12,75,601,1,75,1,75,3,75,606,8,75,1,76, - 1,76,1,76,1,77,1,77,5,77,613,8,77,10,77,12,77,616,9,77,1,78,1,78, - 1,78,1,78,1,78,1,78,5,78,624,8,78,10,78,12,78,627,9,78,1,78,1,78, - 1,79,4,79,632,8,79,11,79,12,79,633,1,79,3,79,637,8,79,1,79,1,79, - 1,80,3,80,642,8,80,1,80,1,80,1,421,0,81,1,1,3,2,5,3,7,4,9,5,11,6, - 13,7,15,8,17,9,19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35, - 18,37,19,39,20,41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57, - 29,59,30,61,31,63,32,65,33,67,34,69,35,71,36,73,37,75,38,77,39,79, - 40,81,41,83,42,85,43,87,44,89,45,91,46,93,47,95,48,97,49,99,50,101, - 51,103,52,105,53,107,54,109,55,111,56,113,57,115,58,117,59,119,60, - 121,61,123,62,125,63,127,0,129,0,131,0,133,0,135,0,137,0,139,64, - 141,65,143,66,145,67,147,68,149,69,151,70,153,71,155,72,157,73,159, - 74,161,75,1,0,33,2,0,73,73,105,105,2,0,78,78,110,110,2,0,84,84,116, + 78,7,78,2,79,7,79,2,80,7,80,2,81,7,81,2,82,7,82,1,0,1,0,1,0,1,0, + 1,1,1,1,1,1,1,1,1,1,1,2,1,2,1,2,1,2,1,2,1,2,1,2,1,3,1,3,1,3,1,3, + 1,3,1,3,1,4,1,4,1,4,1,4,1,4,1,4,1,5,1,5,1,5,1,5,1,5,1,5,1,5,1,5, + 1,5,1,6,1,6,1,6,1,6,1,6,1,6,1,7,1,7,1,7,1,7,1,7,1,8,1,8,1,8,1,8, + 1,8,1,8,1,8,1,9,1,9,1,10,1,10,1,11,1,11,1,12,1,12,1,13,1,13,1,14, + 1,14,1,14,1,14,1,15,1,15,1,15,1,15,1,16,1,16,1,16,1,17,1,17,1,17, + 1,18,1,18,1,18,1,18,1,18,1,19,1,19,1,19,1,19,1,19,1,19,1,19,1,20, + 1,20,1,20,1,20,1,20,1,20,1,20,1,21,1,21,1,21,1,21,1,21,1,21,1,21, + 1,22,1,22,1,22,1,22,1,23,1,23,1,23,1,23,1,24,1,24,1,24,1,24,1,25, + 1,25,1,25,1,25,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,26,1,27, + 1,27,1,27,1,27,1,27,1,27,1,27,1,27,1,28,1,28,1,28,1,28,1,28,1,28, + 1,29,1,29,1,29,1,29,1,29,1,29,1,29,1,29,1,30,1,30,1,30,1,31,1,31, + 1,31,1,32,1,32,1,33,1,33,1,33,1,34,1,34,1,35,1,35,1,35,1,36,1,36, + 1,36,1,37,1,37,1,37,1,38,1,38,1,39,1,39,1,39,1,40,1,40,1,40,1,41, + 1,41,1,41,1,42,1,42,1,42,1,43,1,43,1,43,1,44,1,44,1,44,1,45,1,45, + 1,45,1,46,1,46,1,47,1,47,1,47,1,47,1,48,1,48,1,48,1,48,1,49,1,49, + 1,49,1,49,1,49,1,49,1,49,1,50,1,50,1,50,1,51,1,51,1,51,1,51,1,51, + 1,51,1,52,1,52,1,52,1,53,1,53,1,53,1,53,1,53,1,54,1,54,1,54,1,54, + 1,54,1,54,1,55,1,55,1,55,1,56,1,56,1,57,1,57,1,58,1,58,1,59,1,59, + 1,60,1,60,1,61,1,61,1,62,1,62,1,63,1,63,1,64,1,64,1,65,1,65,1,65, + 1,65,5,65,430,8,65,10,65,12,65,433,9,65,1,65,1,65,1,65,1,65,1,65, + 1,65,5,65,441,8,65,10,65,12,65,444,9,65,3,65,446,8,65,1,66,1,66, + 1,66,1,66,1,66,1,67,1,67,1,67,1,67,1,67,1,67,1,68,1,68,1,69,1,69, + 1,70,1,70,1,70,1,70,1,70,1,70,1,70,1,70,1,70,1,70,1,70,1,70,3,70, + 475,8,70,1,71,1,71,1,71,3,71,480,8,71,1,72,3,72,483,8,72,1,72,4, + 72,486,8,72,11,72,12,72,487,1,73,3,73,491,8,73,1,73,4,73,494,8,73, + 11,73,12,73,495,1,73,1,73,5,73,500,8,73,10,73,12,73,503,9,73,1,73, + 3,73,506,8,73,1,73,1,73,4,73,510,8,73,11,73,12,73,511,3,73,514,8, + 73,1,74,1,74,1,74,1,74,4,74,520,8,74,11,74,12,74,521,1,75,1,75,1, + 75,4,75,527,8,75,11,75,12,75,528,1,76,1,76,1,76,3,76,534,8,76,1, + 76,1,76,5,76,538,8,76,10,76,12,76,541,9,76,1,76,1,76,3,76,545,8, + 76,3,76,547,8,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1,76,1, + 76,3,76,559,8,76,1,76,1,76,3,76,563,8,76,1,76,3,76,566,8,76,1,77, + 1,77,1,77,1,77,1,77,5,77,573,8,77,10,77,12,77,576,9,77,1,77,1,77, + 5,77,580,8,77,10,77,12,77,583,9,77,1,77,1,77,1,77,1,77,1,77,1,77, + 5,77,591,8,77,10,77,12,77,594,9,77,1,77,1,77,5,77,598,8,77,10,77, + 12,77,601,9,77,1,77,1,77,1,77,1,77,3,77,607,8,77,1,77,4,77,610,8, + 77,11,77,12,77,611,1,77,1,77,3,77,616,8,77,1,78,1,78,1,78,1,79,1, + 79,5,79,623,8,79,10,79,12,79,626,9,79,1,80,1,80,1,80,1,80,1,80,1, + 80,5,80,634,8,80,10,80,12,80,637,9,80,1,80,1,80,1,81,4,81,642,8, + 81,11,81,12,81,643,1,81,3,81,647,8,81,1,81,1,81,1,82,3,82,652,8, + 82,1,82,1,82,1,431,0,83,1,1,3,2,5,3,7,4,9,5,11,6,13,7,15,8,17,9, + 19,10,21,11,23,12,25,13,27,14,29,15,31,16,33,17,35,18,37,19,39,20, + 41,21,43,22,45,23,47,24,49,25,51,26,53,27,55,28,57,29,59,30,61,31, + 63,32,65,33,67,34,69,35,71,36,73,37,75,38,77,39,79,40,81,41,83,42, + 85,43,87,44,89,45,91,46,93,47,95,48,97,49,99,50,101,51,103,52,105, + 53,107,54,109,55,111,56,113,57,115,58,117,59,119,60,121,61,123,62, + 125,63,127,64,129,65,131,0,133,0,135,0,137,0,139,0,141,0,143,66, + 145,67,147,68,149,69,151,70,153,71,155,72,157,73,159,74,161,75,163, + 76,165,77,1,0,33,2,0,73,73,105,105,2,0,78,78,110,110,2,0,84,84,116, 116,2,0,66,66,98,98,2,0,79,79,111,111,2,0,76,76,108,108,2,0,83,83, 115,115,2,0,82,82,114,114,2,0,71,71,103,103,2,0,81,81,113,113,2, 0,85,85,117,117,2,0,70,70,102,102,2,0,65,65,97,97,2,0,86,86,118, @@ -79,7 +80,7 @@ def serializedATN(): 2,0,67,67,99,99,2,0,88,88,120,120,2,0,72,72,104,104,2,0,10,10,13, 13,1,0,48,57,2,0,43,43,45,45,2,0,65,70,97,102,1,0,48,49,3,0,65,90, 95,95,97,122,4,0,48,57,65,90,95,95,97,122,2,0,34,34,92,92,3,0,9, - 10,13,13,32,32,682,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0, + 10,13,13,32,32,692,0,1,1,0,0,0,0,3,1,0,0,0,0,5,1,0,0,0,0,7,1,0,0, 0,0,9,1,0,0,0,0,11,1,0,0,0,0,13,1,0,0,0,0,15,1,0,0,0,0,17,1,0,0, 0,0,19,1,0,0,0,0,21,1,0,0,0,0,23,1,0,0,0,0,25,1,0,0,0,0,27,1,0,0, 0,0,29,1,0,0,0,0,31,1,0,0,0,0,33,1,0,0,0,0,35,1,0,0,0,0,37,1,0,0, @@ -92,164 +93,166 @@ def serializedATN(): 0,0,99,1,0,0,0,0,101,1,0,0,0,0,103,1,0,0,0,0,105,1,0,0,0,0,107,1, 0,0,0,0,109,1,0,0,0,0,111,1,0,0,0,0,113,1,0,0,0,0,115,1,0,0,0,0, 117,1,0,0,0,0,119,1,0,0,0,0,121,1,0,0,0,0,123,1,0,0,0,0,125,1,0, - 0,0,0,139,1,0,0,0,0,141,1,0,0,0,0,143,1,0,0,0,0,145,1,0,0,0,0,147, + 0,0,0,127,1,0,0,0,0,129,1,0,0,0,0,143,1,0,0,0,0,145,1,0,0,0,0,147, 1,0,0,0,0,149,1,0,0,0,0,151,1,0,0,0,0,153,1,0,0,0,0,155,1,0,0,0, - 0,157,1,0,0,0,0,159,1,0,0,0,0,161,1,0,0,0,1,163,1,0,0,0,3,167,1, - 0,0,0,5,172,1,0,0,0,7,179,1,0,0,0,9,185,1,0,0,0,11,191,1,0,0,0,13, - 200,1,0,0,0,15,206,1,0,0,0,17,211,1,0,0,0,19,218,1,0,0,0,21,220, - 1,0,0,0,23,222,1,0,0,0,25,224,1,0,0,0,27,226,1,0,0,0,29,228,1,0, - 0,0,31,232,1,0,0,0,33,236,1,0,0,0,35,239,1,0,0,0,37,242,1,0,0,0, - 39,247,1,0,0,0,41,254,1,0,0,0,43,261,1,0,0,0,45,268,1,0,0,0,47,272, - 1,0,0,0,49,276,1,0,0,0,51,280,1,0,0,0,53,284,1,0,0,0,55,293,1,0, - 0,0,57,301,1,0,0,0,59,307,1,0,0,0,61,315,1,0,0,0,63,318,1,0,0,0, - 65,321,1,0,0,0,67,323,1,0,0,0,69,326,1,0,0,0,71,328,1,0,0,0,73,331, - 1,0,0,0,75,333,1,0,0,0,77,336,1,0,0,0,79,339,1,0,0,0,81,342,1,0, - 0,0,83,345,1,0,0,0,85,348,1,0,0,0,87,351,1,0,0,0,89,354,1,0,0,0, - 91,356,1,0,0,0,93,360,1,0,0,0,95,364,1,0,0,0,97,371,1,0,0,0,99,374, - 1,0,0,0,101,380,1,0,0,0,103,383,1,0,0,0,105,388,1,0,0,0,107,394, - 1,0,0,0,109,397,1,0,0,0,111,399,1,0,0,0,113,401,1,0,0,0,115,403, - 1,0,0,0,117,405,1,0,0,0,119,407,1,0,0,0,121,409,1,0,0,0,123,411, - 1,0,0,0,125,413,1,0,0,0,127,435,1,0,0,0,129,437,1,0,0,0,131,442, - 1,0,0,0,133,448,1,0,0,0,135,450,1,0,0,0,137,464,1,0,0,0,139,469, - 1,0,0,0,141,472,1,0,0,0,143,503,1,0,0,0,145,505,1,0,0,0,147,513, - 1,0,0,0,149,555,1,0,0,0,151,605,1,0,0,0,153,607,1,0,0,0,155,610, - 1,0,0,0,157,617,1,0,0,0,159,636,1,0,0,0,161,641,1,0,0,0,163,164, - 7,0,0,0,164,165,7,1,0,0,165,166,7,2,0,0,166,2,1,0,0,0,167,168,7, - 3,0,0,168,169,7,4,0,0,169,170,7,4,0,0,170,171,7,5,0,0,171,4,1,0, - 0,0,172,173,7,6,0,0,173,174,7,2,0,0,174,175,7,7,0,0,175,176,7,0, - 0,0,176,177,7,1,0,0,177,178,7,8,0,0,178,6,1,0,0,0,179,180,7,9,0, - 0,180,181,7,10,0,0,181,182,7,3,0,0,182,183,7,0,0,0,183,184,7,2,0, - 0,184,8,1,0,0,0,185,186,7,9,0,0,186,187,7,10,0,0,187,188,7,0,0,0, - 188,189,7,1,0,0,189,190,7,2,0,0,190,10,1,0,0,0,191,192,7,9,0,0,192, - 193,7,10,0,0,193,194,7,6,0,0,194,195,7,2,0,0,195,196,7,7,0,0,196, - 197,7,0,0,0,197,198,7,1,0,0,198,199,7,8,0,0,199,12,1,0,0,0,200,201, - 7,11,0,0,201,202,7,5,0,0,202,203,7,4,0,0,203,204,7,12,0,0,204,205, - 7,2,0,0,205,14,1,0,0,0,206,207,7,13,0,0,207,208,7,4,0,0,208,209, - 7,0,0,0,209,210,7,14,0,0,210,16,1,0,0,0,211,212,7,7,0,0,212,213, - 7,15,0,0,213,214,7,2,0,0,214,215,7,10,0,0,215,216,7,7,0,0,216,217, - 7,1,0,0,217,18,1,0,0,0,218,219,5,42,0,0,219,20,1,0,0,0,220,221,5, - 47,0,0,221,22,1,0,0,0,222,223,5,37,0,0,223,24,1,0,0,0,224,225,5, - 43,0,0,225,26,1,0,0,0,226,227,5,45,0,0,227,28,1,0,0,0,228,229,7, - 1,0,0,229,230,7,4,0,0,230,231,7,2,0,0,231,30,1,0,0,0,232,233,7,12, - 0,0,233,234,7,1,0,0,234,235,7,14,0,0,235,32,1,0,0,0,236,237,7,4, - 0,0,237,238,7,7,0,0,238,34,1,0,0,0,239,240,7,3,0,0,240,241,7,16, - 0,0,241,36,1,0,0,0,242,243,7,6,0,0,243,244,7,17,0,0,244,245,7,12, - 0,0,245,246,7,18,0,0,246,38,1,0,0,0,247,248,7,18,0,0,248,249,7,12, - 0,0,249,250,7,10,0,0,250,251,7,5,0,0,251,252,7,0,0,0,252,253,7,16, - 0,0,253,40,1,0,0,0,254,255,7,18,0,0,255,256,7,12,0,0,256,257,7,10, - 0,0,257,258,7,5,0,0,258,259,7,0,0,0,259,260,7,19,0,0,260,42,1,0, - 0,0,261,262,7,8,0,0,262,263,7,7,0,0,263,264,7,4,0,0,264,265,7,13, - 0,0,265,266,7,15,0,0,266,267,7,7,0,0,267,44,1,0,0,0,268,269,7,20, - 0,0,269,270,7,21,0,0,270,271,7,19,0,0,271,46,1,0,0,0,272,273,7,20, - 0,0,273,274,7,21,0,0,274,275,7,22,0,0,275,48,1,0,0,0,276,277,7,20, - 0,0,277,278,7,21,0,0,278,279,7,16,0,0,279,50,1,0,0,0,280,281,7,20, - 0,0,281,282,7,21,0,0,282,283,7,18,0,0,283,52,1,0,0,0,284,285,7,23, - 0,0,285,286,7,12,0,0,286,287,7,14,0,0,287,288,7,12,0,0,288,289,7, - 20,0,0,289,290,7,12,0,0,290,291,7,7,0,0,291,292,7,14,0,0,292,54, - 1,0,0,0,293,294,7,20,0,0,294,295,7,15,0,0,295,296,7,12,0,0,296,297, - 7,6,0,0,297,298,7,10,0,0,298,299,7,7,0,0,299,300,7,15,0,0,300,56, - 1,0,0,0,301,302,7,18,0,0,302,303,7,7,0,0,303,304,7,0,0,0,304,305, - 7,1,0,0,305,306,7,2,0,0,306,58,1,0,0,0,307,308,7,3,0,0,308,309,7, - 12,0,0,309,310,7,7,0,0,310,311,7,7,0,0,311,312,7,0,0,0,312,313,7, - 15,0,0,313,314,7,7,0,0,314,60,1,0,0,0,315,316,5,61,0,0,316,317,5, - 61,0,0,317,62,1,0,0,0,318,319,5,33,0,0,319,320,5,61,0,0,320,64,1, - 0,0,0,321,322,5,62,0,0,322,66,1,0,0,0,323,324,5,62,0,0,324,325,5, - 61,0,0,325,68,1,0,0,0,326,327,5,60,0,0,327,70,1,0,0,0,328,329,5, - 60,0,0,329,330,5,61,0,0,330,72,1,0,0,0,331,332,5,61,0,0,332,74,1, - 0,0,0,333,334,5,43,0,0,334,335,5,43,0,0,335,76,1,0,0,0,336,337,5, - 45,0,0,337,338,5,45,0,0,338,78,1,0,0,0,339,340,5,43,0,0,340,341, - 5,61,0,0,341,80,1,0,0,0,342,343,5,45,0,0,343,344,5,61,0,0,344,82, - 1,0,0,0,345,346,5,42,0,0,346,347,5,61,0,0,347,84,1,0,0,0,348,349, - 5,47,0,0,349,350,5,61,0,0,350,86,1,0,0,0,351,352,5,37,0,0,352,353, - 5,61,0,0,353,88,1,0,0,0,354,355,5,59,0,0,355,90,1,0,0,0,356,357, - 7,13,0,0,357,358,7,12,0,0,358,359,7,7,0,0,359,92,1,0,0,0,360,361, - 7,11,0,0,361,362,7,4,0,0,362,363,7,7,0,0,363,94,1,0,0,0,364,365, - 7,6,0,0,365,366,7,15,0,0,366,367,7,12,0,0,367,368,7,7,0,0,368,369, - 7,21,0,0,369,370,7,23,0,0,370,96,1,0,0,0,371,372,7,0,0,0,372,373, - 7,1,0,0,373,98,1,0,0,0,374,375,7,17,0,0,375,376,7,23,0,0,376,377, - 7,15,0,0,377,378,7,7,0,0,378,379,7,15,0,0,379,100,1,0,0,0,380,381, - 7,0,0,0,381,382,7,11,0,0,382,102,1,0,0,0,383,384,7,15,0,0,384,385, - 7,5,0,0,385,386,7,6,0,0,386,387,7,15,0,0,387,104,1,0,0,0,388,389, - 7,17,0,0,389,390,7,23,0,0,390,391,7,0,0,0,391,392,7,5,0,0,392,393, - 7,15,0,0,393,106,1,0,0,0,394,395,7,14,0,0,395,396,7,4,0,0,396,108, - 1,0,0,0,397,398,5,123,0,0,398,110,1,0,0,0,399,400,5,125,0,0,400, - 112,1,0,0,0,401,402,5,40,0,0,402,114,1,0,0,0,403,404,5,41,0,0,404, - 116,1,0,0,0,405,406,5,91,0,0,406,118,1,0,0,0,407,408,5,93,0,0,408, - 120,1,0,0,0,409,410,5,46,0,0,410,122,1,0,0,0,411,412,5,34,0,0,412, - 124,1,0,0,0,413,414,5,44,0,0,414,126,1,0,0,0,415,416,5,47,0,0,416, - 417,5,42,0,0,417,421,1,0,0,0,418,420,9,0,0,0,419,418,1,0,0,0,420, - 423,1,0,0,0,421,422,1,0,0,0,421,419,1,0,0,0,422,424,1,0,0,0,423, - 421,1,0,0,0,424,425,5,42,0,0,425,436,5,47,0,0,426,427,5,47,0,0,427, - 428,5,47,0,0,428,432,1,0,0,0,429,431,8,24,0,0,430,429,1,0,0,0,431, - 434,1,0,0,0,432,430,1,0,0,0,432,433,1,0,0,0,433,436,1,0,0,0,434, - 432,1,0,0,0,435,415,1,0,0,0,435,426,1,0,0,0,436,128,1,0,0,0,437, - 438,7,2,0,0,438,439,7,7,0,0,439,440,7,10,0,0,440,441,7,15,0,0,441, - 130,1,0,0,0,442,443,7,11,0,0,443,444,7,12,0,0,444,445,7,5,0,0,445, - 446,7,6,0,0,446,447,7,15,0,0,447,132,1,0,0,0,448,449,7,25,0,0,449, - 134,1,0,0,0,450,451,7,26,0,0,451,136,1,0,0,0,452,453,5,124,0,0,453, - 454,5,48,0,0,454,465,5,62,0,0,455,456,5,124,0,0,456,457,5,49,0,0, - 457,465,5,62,0,0,458,459,5,124,0,0,459,460,5,43,0,0,460,465,5,62, - 0,0,461,462,5,124,0,0,462,463,5,45,0,0,463,465,5,62,0,0,464,452, - 1,0,0,0,464,455,1,0,0,0,464,458,1,0,0,0,464,461,1,0,0,0,465,138, - 1,0,0,0,466,470,3,129,64,0,467,470,3,131,65,0,468,470,2,48,49,0, - 469,466,1,0,0,0,469,467,1,0,0,0,469,468,1,0,0,0,470,140,1,0,0,0, - 471,473,3,135,67,0,472,471,1,0,0,0,472,473,1,0,0,0,473,475,1,0,0, - 0,474,476,3,133,66,0,475,474,1,0,0,0,476,477,1,0,0,0,477,475,1,0, - 0,0,477,478,1,0,0,0,478,142,1,0,0,0,479,481,3,135,67,0,480,479,1, - 0,0,0,480,481,1,0,0,0,481,483,1,0,0,0,482,484,3,133,66,0,483,482, - 1,0,0,0,484,485,1,0,0,0,485,483,1,0,0,0,485,486,1,0,0,0,486,487, - 1,0,0,0,487,491,5,46,0,0,488,490,3,133,66,0,489,488,1,0,0,0,490, - 493,1,0,0,0,491,489,1,0,0,0,491,492,1,0,0,0,492,504,1,0,0,0,493, - 491,1,0,0,0,494,496,3,135,67,0,495,494,1,0,0,0,495,496,1,0,0,0,496, - 497,1,0,0,0,497,499,5,46,0,0,498,500,3,133,66,0,499,498,1,0,0,0, - 500,501,1,0,0,0,501,499,1,0,0,0,501,502,1,0,0,0,502,504,1,0,0,0, - 503,480,1,0,0,0,503,495,1,0,0,0,504,144,1,0,0,0,505,506,5,48,0,0, - 506,509,7,22,0,0,507,510,7,27,0,0,508,510,3,133,66,0,509,507,1,0, - 0,0,509,508,1,0,0,0,510,511,1,0,0,0,511,509,1,0,0,0,511,512,1,0, - 0,0,512,146,1,0,0,0,513,514,5,48,0,0,514,516,7,3,0,0,515,517,7,28, - 0,0,516,515,1,0,0,0,517,518,1,0,0,0,518,516,1,0,0,0,518,519,1,0, - 0,0,519,148,1,0,0,0,520,523,3,117,58,0,521,524,3,139,69,0,522,524, - 2,48,49,0,523,521,1,0,0,0,523,522,1,0,0,0,524,536,1,0,0,0,525,529, - 3,125,62,0,526,528,5,32,0,0,527,526,1,0,0,0,528,531,1,0,0,0,529, - 527,1,0,0,0,529,530,1,0,0,0,530,534,1,0,0,0,531,529,1,0,0,0,532, - 535,3,139,69,0,533,535,2,48,49,0,534,532,1,0,0,0,534,533,1,0,0,0, - 535,537,1,0,0,0,536,525,1,0,0,0,536,537,1,0,0,0,537,538,1,0,0,0, - 538,539,3,119,59,0,539,540,7,9,0,0,540,556,1,0,0,0,541,542,3,143, - 71,0,542,543,3,125,62,0,543,544,3,143,71,0,544,545,7,9,0,0,545,556, - 1,0,0,0,546,556,3,137,68,0,547,549,3,135,67,0,548,547,1,0,0,0,548, - 549,1,0,0,0,549,552,1,0,0,0,550,553,3,139,69,0,551,553,2,48,49,0, - 552,550,1,0,0,0,552,551,1,0,0,0,553,554,1,0,0,0,554,556,7,9,0,0, - 555,520,1,0,0,0,555,541,1,0,0,0,555,546,1,0,0,0,555,548,1,0,0,0, - 556,150,1,0,0,0,557,606,3,149,74,0,558,559,3,117,58,0,559,571,3, - 149,74,0,560,564,3,125,62,0,561,563,5,32,0,0,562,561,1,0,0,0,563, - 566,1,0,0,0,564,562,1,0,0,0,564,565,1,0,0,0,565,567,1,0,0,0,566, - 564,1,0,0,0,567,568,3,149,74,0,568,570,1,0,0,0,569,560,1,0,0,0,570, - 573,1,0,0,0,571,569,1,0,0,0,571,572,1,0,0,0,572,574,1,0,0,0,573, - 571,1,0,0,0,574,575,3,119,59,0,575,606,1,0,0,0,576,577,3,117,58, - 0,577,589,3,141,70,0,578,582,3,125,62,0,579,581,5,32,0,0,580,579, - 1,0,0,0,581,584,1,0,0,0,582,580,1,0,0,0,582,583,1,0,0,0,583,585, - 1,0,0,0,584,582,1,0,0,0,585,586,3,141,70,0,586,588,1,0,0,0,587,578, - 1,0,0,0,588,591,1,0,0,0,589,587,1,0,0,0,589,590,1,0,0,0,590,592, - 1,0,0,0,591,589,1,0,0,0,592,593,3,119,59,0,593,594,7,9,0,0,594,606, - 1,0,0,0,595,597,3,135,67,0,596,595,1,0,0,0,596,597,1,0,0,0,597,599, - 1,0,0,0,598,600,3,133,66,0,599,598,1,0,0,0,600,601,1,0,0,0,601,599, - 1,0,0,0,601,602,1,0,0,0,602,603,1,0,0,0,603,604,7,9,0,0,604,606, - 1,0,0,0,605,557,1,0,0,0,605,558,1,0,0,0,605,576,1,0,0,0,605,596, - 1,0,0,0,606,152,1,0,0,0,607,608,3,157,78,0,608,609,7,9,0,0,609,154, - 1,0,0,0,610,614,7,29,0,0,611,613,7,30,0,0,612,611,1,0,0,0,613,616, - 1,0,0,0,614,612,1,0,0,0,614,615,1,0,0,0,615,156,1,0,0,0,616,614, - 1,0,0,0,617,625,5,34,0,0,618,619,5,92,0,0,619,624,9,0,0,0,620,621, - 5,34,0,0,621,624,5,34,0,0,622,624,8,31,0,0,623,618,1,0,0,0,623,620, - 1,0,0,0,623,622,1,0,0,0,624,627,1,0,0,0,625,623,1,0,0,0,625,626, - 1,0,0,0,626,628,1,0,0,0,627,625,1,0,0,0,628,629,5,34,0,0,629,158, - 1,0,0,0,630,632,7,32,0,0,631,630,1,0,0,0,632,633,1,0,0,0,633,631, - 1,0,0,0,633,634,1,0,0,0,634,637,1,0,0,0,635,637,3,127,63,0,636,631, - 1,0,0,0,636,635,1,0,0,0,637,638,1,0,0,0,638,639,6,79,0,0,639,160, - 1,0,0,0,640,642,5,13,0,0,641,640,1,0,0,0,641,642,1,0,0,0,642,643, - 1,0,0,0,643,644,5,10,0,0,644,162,1,0,0,0,37,0,421,432,435,464,469, - 472,477,480,485,491,495,501,503,509,511,518,523,529,534,536,548, - 552,555,564,571,582,589,596,601,605,614,623,625,633,636,641,1,6, - 0,0 + 0,157,1,0,0,0,0,159,1,0,0,0,0,161,1,0,0,0,0,163,1,0,0,0,0,165,1, + 0,0,0,1,167,1,0,0,0,3,171,1,0,0,0,5,176,1,0,0,0,7,183,1,0,0,0,9, + 189,1,0,0,0,11,195,1,0,0,0,13,204,1,0,0,0,15,210,1,0,0,0,17,215, + 1,0,0,0,19,222,1,0,0,0,21,224,1,0,0,0,23,226,1,0,0,0,25,228,1,0, + 0,0,27,230,1,0,0,0,29,232,1,0,0,0,31,236,1,0,0,0,33,240,1,0,0,0, + 35,243,1,0,0,0,37,246,1,0,0,0,39,251,1,0,0,0,41,258,1,0,0,0,43,265, + 1,0,0,0,45,272,1,0,0,0,47,276,1,0,0,0,49,280,1,0,0,0,51,284,1,0, + 0,0,53,288,1,0,0,0,55,297,1,0,0,0,57,305,1,0,0,0,59,311,1,0,0,0, + 61,319,1,0,0,0,63,322,1,0,0,0,65,325,1,0,0,0,67,327,1,0,0,0,69,330, + 1,0,0,0,71,332,1,0,0,0,73,335,1,0,0,0,75,338,1,0,0,0,77,341,1,0, + 0,0,79,343,1,0,0,0,81,346,1,0,0,0,83,349,1,0,0,0,85,352,1,0,0,0, + 87,355,1,0,0,0,89,358,1,0,0,0,91,361,1,0,0,0,93,364,1,0,0,0,95,366, + 1,0,0,0,97,370,1,0,0,0,99,374,1,0,0,0,101,381,1,0,0,0,103,384,1, + 0,0,0,105,390,1,0,0,0,107,393,1,0,0,0,109,398,1,0,0,0,111,404,1, + 0,0,0,113,407,1,0,0,0,115,409,1,0,0,0,117,411,1,0,0,0,119,413,1, + 0,0,0,121,415,1,0,0,0,123,417,1,0,0,0,125,419,1,0,0,0,127,421,1, + 0,0,0,129,423,1,0,0,0,131,445,1,0,0,0,133,447,1,0,0,0,135,452,1, + 0,0,0,137,458,1,0,0,0,139,460,1,0,0,0,141,474,1,0,0,0,143,479,1, + 0,0,0,145,482,1,0,0,0,147,513,1,0,0,0,149,515,1,0,0,0,151,523,1, + 0,0,0,153,565,1,0,0,0,155,615,1,0,0,0,157,617,1,0,0,0,159,620,1, + 0,0,0,161,627,1,0,0,0,163,646,1,0,0,0,165,651,1,0,0,0,167,168,7, + 0,0,0,168,169,7,1,0,0,169,170,7,2,0,0,170,2,1,0,0,0,171,172,7,3, + 0,0,172,173,7,4,0,0,173,174,7,4,0,0,174,175,7,5,0,0,175,4,1,0,0, + 0,176,177,7,6,0,0,177,178,7,2,0,0,178,179,7,7,0,0,179,180,7,0,0, + 0,180,181,7,1,0,0,181,182,7,8,0,0,182,6,1,0,0,0,183,184,7,9,0,0, + 184,185,7,10,0,0,185,186,7,3,0,0,186,187,7,0,0,0,187,188,7,2,0,0, + 188,8,1,0,0,0,189,190,7,9,0,0,190,191,7,10,0,0,191,192,7,0,0,0,192, + 193,7,1,0,0,193,194,7,2,0,0,194,10,1,0,0,0,195,196,7,9,0,0,196,197, + 7,10,0,0,197,198,7,6,0,0,198,199,7,2,0,0,199,200,7,7,0,0,200,201, + 7,0,0,0,201,202,7,1,0,0,202,203,7,8,0,0,203,12,1,0,0,0,204,205,7, + 11,0,0,205,206,7,5,0,0,206,207,7,4,0,0,207,208,7,12,0,0,208,209, + 7,2,0,0,209,14,1,0,0,0,210,211,7,13,0,0,211,212,7,4,0,0,212,213, + 7,0,0,0,213,214,7,14,0,0,214,16,1,0,0,0,215,216,7,7,0,0,216,217, + 7,15,0,0,217,218,7,2,0,0,218,219,7,10,0,0,219,220,7,7,0,0,220,221, + 7,1,0,0,221,18,1,0,0,0,222,223,5,42,0,0,223,20,1,0,0,0,224,225,5, + 47,0,0,225,22,1,0,0,0,226,227,5,37,0,0,227,24,1,0,0,0,228,229,5, + 43,0,0,229,26,1,0,0,0,230,231,5,45,0,0,231,28,1,0,0,0,232,233,7, + 1,0,0,233,234,7,4,0,0,234,235,7,2,0,0,235,30,1,0,0,0,236,237,7,12, + 0,0,237,238,7,1,0,0,238,239,7,14,0,0,239,32,1,0,0,0,240,241,7,4, + 0,0,241,242,7,7,0,0,242,34,1,0,0,0,243,244,7,3,0,0,244,245,7,16, + 0,0,245,36,1,0,0,0,246,247,7,6,0,0,247,248,7,17,0,0,248,249,7,12, + 0,0,249,250,7,18,0,0,250,38,1,0,0,0,251,252,7,18,0,0,252,253,7,12, + 0,0,253,254,7,10,0,0,254,255,7,5,0,0,255,256,7,0,0,0,256,257,7,16, + 0,0,257,40,1,0,0,0,258,259,7,18,0,0,259,260,7,12,0,0,260,261,7,10, + 0,0,261,262,7,5,0,0,262,263,7,0,0,0,263,264,7,19,0,0,264,42,1,0, + 0,0,265,266,7,8,0,0,266,267,7,7,0,0,267,268,7,4,0,0,268,269,7,13, + 0,0,269,270,7,15,0,0,270,271,7,7,0,0,271,44,1,0,0,0,272,273,7,20, + 0,0,273,274,7,21,0,0,274,275,7,19,0,0,275,46,1,0,0,0,276,277,7,20, + 0,0,277,278,7,21,0,0,278,279,7,22,0,0,279,48,1,0,0,0,280,281,7,20, + 0,0,281,282,7,21,0,0,282,283,7,16,0,0,283,50,1,0,0,0,284,285,7,20, + 0,0,285,286,7,21,0,0,286,287,7,18,0,0,287,52,1,0,0,0,288,289,7,23, + 0,0,289,290,7,12,0,0,290,291,7,14,0,0,291,292,7,12,0,0,292,293,7, + 20,0,0,293,294,7,12,0,0,294,295,7,7,0,0,295,296,7,14,0,0,296,54, + 1,0,0,0,297,298,7,20,0,0,298,299,7,15,0,0,299,300,7,12,0,0,300,301, + 7,6,0,0,301,302,7,10,0,0,302,303,7,7,0,0,303,304,7,15,0,0,304,56, + 1,0,0,0,305,306,7,18,0,0,306,307,7,7,0,0,307,308,7,0,0,0,308,309, + 7,1,0,0,309,310,7,2,0,0,310,58,1,0,0,0,311,312,7,3,0,0,312,313,7, + 12,0,0,313,314,7,7,0,0,314,315,7,7,0,0,315,316,7,0,0,0,316,317,7, + 15,0,0,317,318,7,7,0,0,318,60,1,0,0,0,319,320,5,61,0,0,320,321,5, + 61,0,0,321,62,1,0,0,0,322,323,5,33,0,0,323,324,5,61,0,0,324,64,1, + 0,0,0,325,326,5,62,0,0,326,66,1,0,0,0,327,328,5,62,0,0,328,329,5, + 61,0,0,329,68,1,0,0,0,330,331,5,60,0,0,331,70,1,0,0,0,332,333,5, + 60,0,0,333,334,5,61,0,0,334,72,1,0,0,0,335,336,5,60,0,0,336,337, + 5,60,0,0,337,74,1,0,0,0,338,339,5,62,0,0,339,340,5,62,0,0,340,76, + 1,0,0,0,341,342,5,61,0,0,342,78,1,0,0,0,343,344,5,43,0,0,344,345, + 5,43,0,0,345,80,1,0,0,0,346,347,5,45,0,0,347,348,5,45,0,0,348,82, + 1,0,0,0,349,350,5,43,0,0,350,351,5,61,0,0,351,84,1,0,0,0,352,353, + 5,45,0,0,353,354,5,61,0,0,354,86,1,0,0,0,355,356,5,42,0,0,356,357, + 5,61,0,0,357,88,1,0,0,0,358,359,5,47,0,0,359,360,5,61,0,0,360,90, + 1,0,0,0,361,362,5,37,0,0,362,363,5,61,0,0,363,92,1,0,0,0,364,365, + 5,59,0,0,365,94,1,0,0,0,366,367,7,13,0,0,367,368,7,12,0,0,368,369, + 7,7,0,0,369,96,1,0,0,0,370,371,7,11,0,0,371,372,7,4,0,0,372,373, + 7,7,0,0,373,98,1,0,0,0,374,375,7,6,0,0,375,376,7,15,0,0,376,377, + 7,12,0,0,377,378,7,7,0,0,378,379,7,21,0,0,379,380,7,23,0,0,380,100, + 1,0,0,0,381,382,7,0,0,0,382,383,7,1,0,0,383,102,1,0,0,0,384,385, + 7,17,0,0,385,386,7,23,0,0,386,387,7,15,0,0,387,388,7,7,0,0,388,389, + 7,15,0,0,389,104,1,0,0,0,390,391,7,0,0,0,391,392,7,11,0,0,392,106, + 1,0,0,0,393,394,7,15,0,0,394,395,7,5,0,0,395,396,7,6,0,0,396,397, + 7,15,0,0,397,108,1,0,0,0,398,399,7,17,0,0,399,400,7,23,0,0,400,401, + 7,0,0,0,401,402,7,5,0,0,402,403,7,15,0,0,403,110,1,0,0,0,404,405, + 7,14,0,0,405,406,7,4,0,0,406,112,1,0,0,0,407,408,5,123,0,0,408,114, + 1,0,0,0,409,410,5,125,0,0,410,116,1,0,0,0,411,412,5,40,0,0,412,118, + 1,0,0,0,413,414,5,41,0,0,414,120,1,0,0,0,415,416,5,91,0,0,416,122, + 1,0,0,0,417,418,5,93,0,0,418,124,1,0,0,0,419,420,5,46,0,0,420,126, + 1,0,0,0,421,422,5,34,0,0,422,128,1,0,0,0,423,424,5,44,0,0,424,130, + 1,0,0,0,425,426,5,47,0,0,426,427,5,42,0,0,427,431,1,0,0,0,428,430, + 9,0,0,0,429,428,1,0,0,0,430,433,1,0,0,0,431,432,1,0,0,0,431,429, + 1,0,0,0,432,434,1,0,0,0,433,431,1,0,0,0,434,435,5,42,0,0,435,446, + 5,47,0,0,436,437,5,47,0,0,437,438,5,47,0,0,438,442,1,0,0,0,439,441, + 8,24,0,0,440,439,1,0,0,0,441,444,1,0,0,0,442,440,1,0,0,0,442,443, + 1,0,0,0,443,446,1,0,0,0,444,442,1,0,0,0,445,425,1,0,0,0,445,436, + 1,0,0,0,446,132,1,0,0,0,447,448,7,2,0,0,448,449,7,7,0,0,449,450, + 7,10,0,0,450,451,7,15,0,0,451,134,1,0,0,0,452,453,7,11,0,0,453,454, + 7,12,0,0,454,455,7,5,0,0,455,456,7,6,0,0,456,457,7,15,0,0,457,136, + 1,0,0,0,458,459,7,25,0,0,459,138,1,0,0,0,460,461,7,26,0,0,461,140, + 1,0,0,0,462,463,5,124,0,0,463,464,5,48,0,0,464,475,5,62,0,0,465, + 466,5,124,0,0,466,467,5,49,0,0,467,475,5,62,0,0,468,469,5,124,0, + 0,469,470,5,43,0,0,470,475,5,62,0,0,471,472,5,124,0,0,472,473,5, + 45,0,0,473,475,5,62,0,0,474,462,1,0,0,0,474,465,1,0,0,0,474,468, + 1,0,0,0,474,471,1,0,0,0,475,142,1,0,0,0,476,480,3,133,66,0,477,480, + 3,135,67,0,478,480,2,48,49,0,479,476,1,0,0,0,479,477,1,0,0,0,479, + 478,1,0,0,0,480,144,1,0,0,0,481,483,3,139,69,0,482,481,1,0,0,0,482, + 483,1,0,0,0,483,485,1,0,0,0,484,486,3,137,68,0,485,484,1,0,0,0,486, + 487,1,0,0,0,487,485,1,0,0,0,487,488,1,0,0,0,488,146,1,0,0,0,489, + 491,3,139,69,0,490,489,1,0,0,0,490,491,1,0,0,0,491,493,1,0,0,0,492, + 494,3,137,68,0,493,492,1,0,0,0,494,495,1,0,0,0,495,493,1,0,0,0,495, + 496,1,0,0,0,496,497,1,0,0,0,497,501,5,46,0,0,498,500,3,137,68,0, + 499,498,1,0,0,0,500,503,1,0,0,0,501,499,1,0,0,0,501,502,1,0,0,0, + 502,514,1,0,0,0,503,501,1,0,0,0,504,506,3,139,69,0,505,504,1,0,0, + 0,505,506,1,0,0,0,506,507,1,0,0,0,507,509,5,46,0,0,508,510,3,137, + 68,0,509,508,1,0,0,0,510,511,1,0,0,0,511,509,1,0,0,0,511,512,1,0, + 0,0,512,514,1,0,0,0,513,490,1,0,0,0,513,505,1,0,0,0,514,148,1,0, + 0,0,515,516,5,48,0,0,516,519,7,22,0,0,517,520,7,27,0,0,518,520,3, + 137,68,0,519,517,1,0,0,0,519,518,1,0,0,0,520,521,1,0,0,0,521,519, + 1,0,0,0,521,522,1,0,0,0,522,150,1,0,0,0,523,524,5,48,0,0,524,526, + 7,3,0,0,525,527,7,28,0,0,526,525,1,0,0,0,527,528,1,0,0,0,528,526, + 1,0,0,0,528,529,1,0,0,0,529,152,1,0,0,0,530,533,3,121,60,0,531,534, + 3,143,71,0,532,534,2,48,49,0,533,531,1,0,0,0,533,532,1,0,0,0,534, + 546,1,0,0,0,535,539,3,129,64,0,536,538,5,32,0,0,537,536,1,0,0,0, + 538,541,1,0,0,0,539,537,1,0,0,0,539,540,1,0,0,0,540,544,1,0,0,0, + 541,539,1,0,0,0,542,545,3,143,71,0,543,545,2,48,49,0,544,542,1,0, + 0,0,544,543,1,0,0,0,545,547,1,0,0,0,546,535,1,0,0,0,546,547,1,0, + 0,0,547,548,1,0,0,0,548,549,3,123,61,0,549,550,7,9,0,0,550,566,1, + 0,0,0,551,552,3,147,73,0,552,553,3,129,64,0,553,554,3,147,73,0,554, + 555,7,9,0,0,555,566,1,0,0,0,556,566,3,141,70,0,557,559,3,139,69, + 0,558,557,1,0,0,0,558,559,1,0,0,0,559,562,1,0,0,0,560,563,3,143, + 71,0,561,563,2,48,49,0,562,560,1,0,0,0,562,561,1,0,0,0,563,564,1, + 0,0,0,564,566,7,9,0,0,565,530,1,0,0,0,565,551,1,0,0,0,565,556,1, + 0,0,0,565,558,1,0,0,0,566,154,1,0,0,0,567,616,3,153,76,0,568,569, + 3,121,60,0,569,581,3,153,76,0,570,574,3,129,64,0,571,573,5,32,0, + 0,572,571,1,0,0,0,573,576,1,0,0,0,574,572,1,0,0,0,574,575,1,0,0, + 0,575,577,1,0,0,0,576,574,1,0,0,0,577,578,3,153,76,0,578,580,1,0, + 0,0,579,570,1,0,0,0,580,583,1,0,0,0,581,579,1,0,0,0,581,582,1,0, + 0,0,582,584,1,0,0,0,583,581,1,0,0,0,584,585,3,123,61,0,585,616,1, + 0,0,0,586,587,3,121,60,0,587,599,3,145,72,0,588,592,3,129,64,0,589, + 591,5,32,0,0,590,589,1,0,0,0,591,594,1,0,0,0,592,590,1,0,0,0,592, + 593,1,0,0,0,593,595,1,0,0,0,594,592,1,0,0,0,595,596,3,145,72,0,596, + 598,1,0,0,0,597,588,1,0,0,0,598,601,1,0,0,0,599,597,1,0,0,0,599, + 600,1,0,0,0,600,602,1,0,0,0,601,599,1,0,0,0,602,603,3,123,61,0,603, + 604,7,9,0,0,604,616,1,0,0,0,605,607,3,139,69,0,606,605,1,0,0,0,606, + 607,1,0,0,0,607,609,1,0,0,0,608,610,3,137,68,0,609,608,1,0,0,0,610, + 611,1,0,0,0,611,609,1,0,0,0,611,612,1,0,0,0,612,613,1,0,0,0,613, + 614,7,9,0,0,614,616,1,0,0,0,615,567,1,0,0,0,615,568,1,0,0,0,615, + 586,1,0,0,0,615,606,1,0,0,0,616,156,1,0,0,0,617,618,3,161,80,0,618, + 619,7,9,0,0,619,158,1,0,0,0,620,624,7,29,0,0,621,623,7,30,0,0,622, + 621,1,0,0,0,623,626,1,0,0,0,624,622,1,0,0,0,624,625,1,0,0,0,625, + 160,1,0,0,0,626,624,1,0,0,0,627,635,5,34,0,0,628,629,5,92,0,0,629, + 634,9,0,0,0,630,631,5,34,0,0,631,634,5,34,0,0,632,634,8,31,0,0,633, + 628,1,0,0,0,633,630,1,0,0,0,633,632,1,0,0,0,634,637,1,0,0,0,635, + 633,1,0,0,0,635,636,1,0,0,0,636,638,1,0,0,0,637,635,1,0,0,0,638, + 639,5,34,0,0,639,162,1,0,0,0,640,642,7,32,0,0,641,640,1,0,0,0,642, + 643,1,0,0,0,643,641,1,0,0,0,643,644,1,0,0,0,644,647,1,0,0,0,645, + 647,3,131,65,0,646,641,1,0,0,0,646,645,1,0,0,0,647,648,1,0,0,0,648, + 649,6,81,0,0,649,164,1,0,0,0,650,652,5,13,0,0,651,650,1,0,0,0,651, + 652,1,0,0,0,652,653,1,0,0,0,653,654,5,10,0,0,654,166,1,0,0,0,37, + 0,431,442,445,474,479,482,487,490,495,501,505,511,513,519,521,528, + 533,539,544,546,558,562,565,574,581,592,599,606,611,615,624,633, + 635,643,646,651,1,6,0,0 ] class qutes_lexer(Lexer): @@ -294,45 +297,47 @@ class qutes_lexer(Lexer): GREATEREQUAL = 34 LOWER = 35 LOWEREQUAL = 36 - ASSIGN = 37 - AUTO_INCREMENT = 38 - AUTO_DECREMENT = 39 - AUTO_SUM = 40 - AUTO_SUB = 41 - AUTO_MULTIPLY = 42 - AUTO_DIVIDE = 43 - AUTO_MODULE = 44 - END_OF_STATEMENT = 45 - VAR_STATEMENT = 46 - FOR_STATEMENT = 47 - SEARCH_STATEMENT = 48 - IN_STATEMENT = 49 - WHERE_STATEMENT = 50 - IF_STATEMENT = 51 - ELSE_STATEMENT = 52 - WHILE_STATEMENT = 53 - DO_STATEMENT = 54 - CURLY_PARENTHESIS_OPEN = 55 - CURLY_PARENTHESIS_CLOSE = 56 - ROUND_PARENTHESIS_OPEN = 57 - ROUND_PARENTHESIS_CLOSE = 58 - SQUARE_PARENTHESIS_OPEN = 59 - SQUARE_PARENTHESIS_CLOSE = 60 - DOT = 61 - STRING_ENCLOSURE = 62 - COMMA = 63 - BOOL_LITERAL = 64 - INT_LITERAL = 65 - FLOAT_LITERAL = 66 - HEX_LITERAL = 67 - BIN_LITERAL = 68 - QUBIT_LITERAL = 69 - QUINT_LITERAL = 70 - QUSTRING_LITERAL = 71 - SYMBOL_LITERAL = 72 - STRING_LITERAL = 73 - WS = 74 - NEWLINE = 75 + LSHIFT = 37 + RSHIFT = 38 + ASSIGN = 39 + AUTO_INCREMENT = 40 + AUTO_DECREMENT = 41 + AUTO_SUM = 42 + AUTO_SUB = 43 + AUTO_MULTIPLY = 44 + AUTO_DIVIDE = 45 + AUTO_MODULE = 46 + END_OF_STATEMENT = 47 + VAR_STATEMENT = 48 + FOR_STATEMENT = 49 + SEARCH_STATEMENT = 50 + IN_STATEMENT = 51 + WHERE_STATEMENT = 52 + IF_STATEMENT = 53 + ELSE_STATEMENT = 54 + WHILE_STATEMENT = 55 + DO_STATEMENT = 56 + CURLY_PARENTHESIS_OPEN = 57 + CURLY_PARENTHESIS_CLOSE = 58 + ROUND_PARENTHESIS_OPEN = 59 + ROUND_PARENTHESIS_CLOSE = 60 + SQUARE_PARENTHESIS_OPEN = 61 + SQUARE_PARENTHESIS_CLOSE = 62 + DOT = 63 + STRING_ENCLOSURE = 64 + COMMA = 65 + BOOL_LITERAL = 66 + INT_LITERAL = 67 + FLOAT_LITERAL = 68 + HEX_LITERAL = 69 + BIN_LITERAL = 70 + QUBIT_LITERAL = 71 + QUINT_LITERAL = 72 + QUSTRING_LITERAL = 73 + SYMBOL_LITERAL = 74 + STRING_LITERAL = 75 + WS = 76 + NEWLINE = 77 channelNames = [ u"DEFAULT_TOKEN_CHANNEL", u"HIDDEN" ] @@ -344,10 +349,11 @@ class qutes_lexer(Lexer): "'-'", "'not'", "'and'", "'or'", "'by'", "'swap'", "'pauliy'", "'pauliz'", "'grover'", "'mcz'", "'mcx'", "'mcy'", "'mcp'", "'hadamard'", "'measure'", "'print'", "'barrier'", "'=='", "'!='", - "'>'", "'>='", "'<'", "'<='", "'='", "'++'", "'--'", "'+='", - "'-='", "'*='", "'/='", "'%='", "';'", "'var'", "'for'", "'search'", - "'in'", "'where'", "'if'", "'else'", "'while'", "'do'", "'{'", - "'}'", "'('", "')'", "'['", "']'", "'.'", "'\"'", "','" ] + "'>'", "'>='", "'<'", "'<='", "'<<'", "'>>'", "'='", "'++'", + "'--'", "'+='", "'-='", "'*='", "'/='", "'%='", "';'", "'var'", + "'for'", "'search'", "'in'", "'where'", "'if'", "'else'", "'while'", + "'do'", "'{'", "'}'", "'('", "')'", "'['", "']'", "'.'", "'\"'", + "','" ] symbolicNames = [ "", "INT_TYPE", "BOOL_TYPE", "STRING_TYPE", "QUBIT_TYPE", "QUINT_TYPE", @@ -355,9 +361,9 @@ class qutes_lexer(Lexer): "DIVIDE", "MODULE", "ADD", "SUB", "NOT", "AND", "OR", "BY", "SWAP", "PAULIY", "PAULIZ", "GROVER", "MCZ", "MCX", "MCY", "MCP", "HADAMARD", "MEASURE", "PRINT", "BARRIER", "EQUAL", "NOT_EQUAL", - "GREATER", "GREATEREQUAL", "LOWER", "LOWEREQUAL", "ASSIGN", - "AUTO_INCREMENT", "AUTO_DECREMENT", "AUTO_SUM", "AUTO_SUB", - "AUTO_MULTIPLY", "AUTO_DIVIDE", "AUTO_MODULE", "END_OF_STATEMENT", + "GREATER", "GREATEREQUAL", "LOWER", "LOWEREQUAL", "LSHIFT", + "RSHIFT", "ASSIGN", "AUTO_INCREMENT", "AUTO_DECREMENT", "AUTO_SUM", + "AUTO_SUB", "AUTO_MULTIPLY", "AUTO_DIVIDE", "AUTO_MODULE", "END_OF_STATEMENT", "VAR_STATEMENT", "FOR_STATEMENT", "SEARCH_STATEMENT", "IN_STATEMENT", "WHERE_STATEMENT", "IF_STATEMENT", "ELSE_STATEMENT", "WHILE_STATEMENT", "DO_STATEMENT", "CURLY_PARENTHESIS_OPEN", "CURLY_PARENTHESIS_CLOSE", @@ -373,10 +379,10 @@ class qutes_lexer(Lexer): "NOT", "AND", "OR", "BY", "SWAP", "PAULIY", "PAULIZ", "GROVER", "MCZ", "MCX", "MCY", "MCP", "HADAMARD", "MEASURE", "PRINT", "BARRIER", "EQUAL", "NOT_EQUAL", "GREATER", "GREATEREQUAL", - "LOWER", "LOWEREQUAL", "ASSIGN", "AUTO_INCREMENT", "AUTO_DECREMENT", - "AUTO_SUM", "AUTO_SUB", "AUTO_MULTIPLY", "AUTO_DIVIDE", - "AUTO_MODULE", "END_OF_STATEMENT", "VAR_STATEMENT", "FOR_STATEMENT", - "SEARCH_STATEMENT", "IN_STATEMENT", "WHERE_STATEMENT", + "LOWER", "LOWEREQUAL", "LSHIFT", "RSHIFT", "ASSIGN", "AUTO_INCREMENT", + "AUTO_DECREMENT", "AUTO_SUM", "AUTO_SUB", "AUTO_MULTIPLY", + "AUTO_DIVIDE", "AUTO_MODULE", "END_OF_STATEMENT", "VAR_STATEMENT", + "FOR_STATEMENT", "SEARCH_STATEMENT", "IN_STATEMENT", "WHERE_STATEMENT", "IF_STATEMENT", "ELSE_STATEMENT", "WHILE_STATEMENT", "DO_STATEMENT", "CURLY_PARENTHESIS_OPEN", "CURLY_PARENTHESIS_CLOSE", "ROUND_PARENTHESIS_OPEN", "ROUND_PARENTHESIS_CLOSE", "SQUARE_PARENTHESIS_OPEN", diff --git a/src/qutes_antlr/qutes_lexer.tokens b/src/qutes_antlr/qutes_lexer.tokens index 2d74c03..9f5f556 100644 --- a/src/qutes_antlr/qutes_lexer.tokens +++ b/src/qutes_antlr/qutes_lexer.tokens @@ -34,45 +34,47 @@ GREATER=33 GREATEREQUAL=34 LOWER=35 LOWEREQUAL=36 -ASSIGN=37 -AUTO_INCREMENT=38 -AUTO_DECREMENT=39 -AUTO_SUM=40 -AUTO_SUB=41 -AUTO_MULTIPLY=42 -AUTO_DIVIDE=43 -AUTO_MODULE=44 -END_OF_STATEMENT=45 -VAR_STATEMENT=46 -FOR_STATEMENT=47 -SEARCH_STATEMENT=48 -IN_STATEMENT=49 -WHERE_STATEMENT=50 -IF_STATEMENT=51 -ELSE_STATEMENT=52 -WHILE_STATEMENT=53 -DO_STATEMENT=54 -CURLY_PARENTHESIS_OPEN=55 -CURLY_PARENTHESIS_CLOSE=56 -ROUND_PARENTHESIS_OPEN=57 -ROUND_PARENTHESIS_CLOSE=58 -SQUARE_PARENTHESIS_OPEN=59 -SQUARE_PARENTHESIS_CLOSE=60 -DOT=61 -STRING_ENCLOSURE=62 -COMMA=63 -BOOL_LITERAL=64 -INT_LITERAL=65 -FLOAT_LITERAL=66 -HEX_LITERAL=67 -BIN_LITERAL=68 -QUBIT_LITERAL=69 -QUINT_LITERAL=70 -QUSTRING_LITERAL=71 -SYMBOL_LITERAL=72 -STRING_LITERAL=73 -WS=74 -NEWLINE=75 +LSHIFT=37 +RSHIFT=38 +ASSIGN=39 +AUTO_INCREMENT=40 +AUTO_DECREMENT=41 +AUTO_SUM=42 +AUTO_SUB=43 +AUTO_MULTIPLY=44 +AUTO_DIVIDE=45 +AUTO_MODULE=46 +END_OF_STATEMENT=47 +VAR_STATEMENT=48 +FOR_STATEMENT=49 +SEARCH_STATEMENT=50 +IN_STATEMENT=51 +WHERE_STATEMENT=52 +IF_STATEMENT=53 +ELSE_STATEMENT=54 +WHILE_STATEMENT=55 +DO_STATEMENT=56 +CURLY_PARENTHESIS_OPEN=57 +CURLY_PARENTHESIS_CLOSE=58 +ROUND_PARENTHESIS_OPEN=59 +ROUND_PARENTHESIS_CLOSE=60 +SQUARE_PARENTHESIS_OPEN=61 +SQUARE_PARENTHESIS_CLOSE=62 +DOT=63 +STRING_ENCLOSURE=64 +COMMA=65 +BOOL_LITERAL=66 +INT_LITERAL=67 +FLOAT_LITERAL=68 +HEX_LITERAL=69 +BIN_LITERAL=70 +QUBIT_LITERAL=71 +QUINT_LITERAL=72 +QUSTRING_LITERAL=73 +SYMBOL_LITERAL=74 +STRING_LITERAL=75 +WS=76 +NEWLINE=77 'int'=1 'bool'=2 'string'=3 @@ -109,30 +111,32 @@ NEWLINE=75 '>='=34 '<'=35 '<='=36 -'='=37 -'++'=38 -'--'=39 -'+='=40 -'-='=41 -'*='=42 -'/='=43 -'%='=44 -';'=45 -'var'=46 -'for'=47 -'search'=48 -'in'=49 -'where'=50 -'if'=51 -'else'=52 -'while'=53 -'do'=54 -'{'=55 -'}'=56 -'('=57 -')'=58 -'['=59 -']'=60 -'.'=61 -'"'=62 -','=63 +'<<'=37 +'>>'=38 +'='=39 +'++'=40 +'--'=41 +'+='=42 +'-='=43 +'*='=44 +'/='=45 +'%='=46 +';'=47 +'var'=48 +'for'=49 +'search'=50 +'in'=51 +'where'=52 +'if'=53 +'else'=54 +'while'=55 +'do'=56 +'{'=57 +'}'=58 +'('=59 +')'=60 +'['=61 +']'=62 +'.'=63 +'"'=64 +','=65 diff --git a/src/qutes_antlr/qutes_parser.py b/src/qutes_antlr/qutes_parser.py index e1f9997..47cb278 100644 --- a/src/qutes_antlr/qutes_parser.py +++ b/src/qutes_antlr/qutes_parser.py @@ -10,7 +10,7 @@ def serializedATN(): return [ - 4,1,75,232,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, + 4,1,77,235,2,0,7,0,2,1,7,1,2,2,7,2,2,3,7,3,2,4,7,4,2,5,7,5,2,6,7, 6,2,7,7,7,2,8,7,8,2,9,7,9,2,10,7,10,2,11,7,11,2,12,7,12,2,13,7,13, 2,14,7,14,2,15,7,15,2,16,7,16,2,17,7,17,2,18,7,18,2,19,7,19,1,0, 5,0,42,8,0,10,0,12,0,45,9,0,1,0,1,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1, @@ -21,79 +21,80 @@ def serializedATN(): 3,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,3,4,125,8,4,1,4,1,4,1, 4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,3,4,144, 8,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4, - 1,4,1,4,1,4,1,4,1,4,5,4,166,8,4,10,4,12,4,169,9,4,1,5,1,5,3,5,173, - 8,5,1,5,1,5,3,5,177,8,5,1,6,1,6,3,6,181,8,6,1,6,1,6,3,6,185,8,6, - 1,7,1,7,3,7,189,8,7,1,8,1,8,1,9,1,9,1,9,5,9,196,8,9,10,9,12,9,199, - 9,9,1,9,1,9,3,9,203,8,9,1,10,1,10,1,11,1,11,1,12,1,12,1,12,1,12, - 1,12,1,12,1,12,3,12,216,8,12,1,13,1,13,1,14,1,14,1,15,1,15,1,16, - 1,16,1,17,1,17,1,18,1,18,1,19,1,19,1,19,0,1,8,20,0,2,4,6,8,10,12, - 14,16,18,20,22,24,26,28,30,32,34,36,38,0,11,2,0,28,28,30,30,2,0, - 13,15,38,39,2,0,19,19,23,25,2,0,20,21,27,29,1,0,10,12,1,0,13,14, - 1,0,33,36,1,0,31,32,1,0,38,39,1,0,1,8,2,0,65,65,67,68,257,0,43,1, - 0,0,0,2,101,1,0,0,0,4,103,1,0,0,0,6,108,1,0,0,0,8,143,1,0,0,0,10, - 172,1,0,0,0,12,180,1,0,0,0,14,188,1,0,0,0,16,190,1,0,0,0,18,202, - 1,0,0,0,20,204,1,0,0,0,22,206,1,0,0,0,24,215,1,0,0,0,26,217,1,0, - 0,0,28,219,1,0,0,0,30,221,1,0,0,0,32,223,1,0,0,0,34,225,1,0,0,0, - 36,227,1,0,0,0,38,229,1,0,0,0,40,42,3,2,1,0,41,40,1,0,0,0,42,45, - 1,0,0,0,43,41,1,0,0,0,43,44,1,0,0,0,44,46,1,0,0,0,45,43,1,0,0,0, - 46,47,5,0,0,1,47,1,1,0,0,0,48,49,5,51,0,0,49,50,3,8,4,0,50,51,3, - 2,1,0,51,102,1,0,0,0,52,53,5,51,0,0,53,54,3,8,4,0,54,55,3,2,1,0, - 55,56,5,52,0,0,56,57,3,2,1,0,57,102,1,0,0,0,58,59,5,53,0,0,59,60, - 3,8,4,0,60,61,3,2,1,0,61,102,1,0,0,0,62,63,5,54,0,0,63,64,3,2,1, - 0,64,65,5,53,0,0,65,66,3,8,4,0,66,102,1,0,0,0,67,71,5,55,0,0,68, - 70,3,2,1,0,69,68,1,0,0,0,70,73,1,0,0,0,71,69,1,0,0,0,71,72,1,0,0, - 0,72,74,1,0,0,0,73,71,1,0,0,0,74,102,5,56,0,0,75,76,3,14,7,0,76, - 77,3,22,11,0,77,79,5,57,0,0,78,80,3,4,2,0,79,78,1,0,0,0,79,80,1, - 0,0,0,80,81,1,0,0,0,81,82,5,58,0,0,82,83,3,2,1,0,83,102,1,0,0,0, - 84,85,3,6,3,0,85,86,5,45,0,0,86,102,1,0,0,0,87,88,3,18,9,0,88,89, - 5,37,0,0,89,90,3,8,4,0,90,91,5,45,0,0,91,102,1,0,0,0,92,93,5,9,0, - 0,93,94,3,8,4,0,94,95,5,45,0,0,95,102,1,0,0,0,96,97,3,8,4,0,97,98, - 5,45,0,0,98,102,1,0,0,0,99,102,7,0,0,0,100,102,5,45,0,0,101,48,1, - 0,0,0,101,52,1,0,0,0,101,58,1,0,0,0,101,62,1,0,0,0,101,67,1,0,0, - 0,101,75,1,0,0,0,101,84,1,0,0,0,101,87,1,0,0,0,101,92,1,0,0,0,101, - 96,1,0,0,0,101,99,1,0,0,0,101,100,1,0,0,0,102,3,1,0,0,0,103,106, - 3,6,3,0,104,105,5,63,0,0,105,107,3,4,2,0,106,104,1,0,0,0,106,107, - 1,0,0,0,107,5,1,0,0,0,108,109,3,14,7,0,109,112,3,20,10,0,110,111, - 5,37,0,0,111,113,3,8,4,0,112,110,1,0,0,0,112,113,1,0,0,0,113,7,1, - 0,0,0,114,115,6,4,-1,0,115,116,5,57,0,0,116,117,3,8,4,0,117,118, - 5,58,0,0,118,144,1,0,0,0,119,144,3,24,12,0,120,144,3,18,9,0,121, - 122,3,22,11,0,122,124,5,57,0,0,123,125,3,10,5,0,124,123,1,0,0,0, - 124,125,1,0,0,0,125,126,1,0,0,0,126,127,5,58,0,0,127,144,1,0,0,0, - 128,129,7,1,0,0,129,144,3,8,4,11,130,131,7,2,0,0,131,144,3,12,6, - 0,132,133,7,3,0,0,133,144,3,8,4,3,134,135,5,26,0,0,135,136,3,12, - 6,0,136,137,5,18,0,0,137,138,3,8,4,2,138,144,1,0,0,0,139,140,3,12, - 6,0,140,141,5,49,0,0,141,142,3,18,9,0,142,144,1,0,0,0,143,114,1, - 0,0,0,143,119,1,0,0,0,143,120,1,0,0,0,143,121,1,0,0,0,143,128,1, - 0,0,0,143,130,1,0,0,0,143,132,1,0,0,0,143,134,1,0,0,0,143,139,1, - 0,0,0,144,167,1,0,0,0,145,146,10,10,0,0,146,147,7,4,0,0,147,166, - 3,8,4,11,148,149,10,9,0,0,149,150,7,5,0,0,150,166,3,8,4,10,151,152, - 10,8,0,0,152,153,7,6,0,0,153,166,3,8,4,9,154,155,10,7,0,0,155,156, - 7,7,0,0,156,166,3,8,4,8,157,158,10,6,0,0,158,159,5,16,0,0,159,166, - 3,8,4,7,160,161,10,5,0,0,161,162,5,17,0,0,162,166,3,8,4,6,163,164, - 10,12,0,0,164,166,7,8,0,0,165,145,1,0,0,0,165,148,1,0,0,0,165,151, - 1,0,0,0,165,154,1,0,0,0,165,157,1,0,0,0,165,160,1,0,0,0,165,163, - 1,0,0,0,166,169,1,0,0,0,167,165,1,0,0,0,167,168,1,0,0,0,168,9,1, - 0,0,0,169,167,1,0,0,0,170,173,3,24,12,0,171,173,3,18,9,0,172,170, - 1,0,0,0,172,171,1,0,0,0,173,176,1,0,0,0,174,175,5,63,0,0,175,177, - 3,10,5,0,176,174,1,0,0,0,176,177,1,0,0,0,177,11,1,0,0,0,178,181, - 3,24,12,0,179,181,3,18,9,0,180,178,1,0,0,0,180,179,1,0,0,0,181,184, - 1,0,0,0,182,183,5,63,0,0,183,185,3,12,6,0,184,182,1,0,0,0,184,185, - 1,0,0,0,185,13,1,0,0,0,186,189,3,16,8,0,187,189,3,18,9,0,188,186, - 1,0,0,0,188,187,1,0,0,0,189,15,1,0,0,0,190,191,7,9,0,0,191,17,1, - 0,0,0,192,197,5,72,0,0,193,194,5,61,0,0,194,196,5,72,0,0,195,193, - 1,0,0,0,196,199,1,0,0,0,197,195,1,0,0,0,197,198,1,0,0,0,198,203, - 1,0,0,0,199,197,1,0,0,0,200,203,3,20,10,0,201,203,3,22,11,0,202, - 192,1,0,0,0,202,200,1,0,0,0,202,201,1,0,0,0,203,19,1,0,0,0,204,205, - 5,72,0,0,205,21,1,0,0,0,206,207,5,72,0,0,207,23,1,0,0,0,208,216, - 3,38,19,0,209,216,3,36,18,0,210,216,3,34,17,0,211,216,3,28,14,0, - 212,216,3,30,15,0,213,216,3,32,16,0,214,216,3,26,13,0,215,208,1, - 0,0,0,215,209,1,0,0,0,215,210,1,0,0,0,215,211,1,0,0,0,215,212,1, - 0,0,0,215,213,1,0,0,0,215,214,1,0,0,0,216,25,1,0,0,0,217,218,5,73, - 0,0,218,27,1,0,0,0,219,220,5,69,0,0,220,29,1,0,0,0,221,222,5,70, - 0,0,222,31,1,0,0,0,223,224,5,71,0,0,224,33,1,0,0,0,225,226,5,66, - 0,0,226,35,1,0,0,0,227,228,7,10,0,0,228,37,1,0,0,0,229,230,5,64, - 0,0,230,39,1,0,0,0,18,43,71,79,101,106,112,124,143,165,167,172,176, - 180,184,188,197,202,215 + 1,4,1,4,1,4,1,4,1,4,1,4,1,4,1,4,5,4,169,8,4,10,4,12,4,172,9,4,1, + 5,1,5,3,5,176,8,5,1,5,1,5,3,5,180,8,5,1,6,1,6,3,6,184,8,6,1,6,1, + 6,3,6,188,8,6,1,7,1,7,3,7,192,8,7,1,8,1,8,1,9,1,9,1,9,5,9,199,8, + 9,10,9,12,9,202,9,9,1,9,1,9,3,9,206,8,9,1,10,1,10,1,11,1,11,1,12, + 1,12,1,12,1,12,1,12,1,12,1,12,3,12,219,8,12,1,13,1,13,1,14,1,14, + 1,15,1,15,1,16,1,16,1,17,1,17,1,18,1,18,1,19,1,19,1,19,0,1,8,20, + 0,2,4,6,8,10,12,14,16,18,20,22,24,26,28,30,32,34,36,38,0,12,2,0, + 28,28,30,30,2,0,13,15,40,41,2,0,19,19,23,25,2,0,20,21,27,29,1,0, + 10,12,1,0,13,14,1,0,37,38,1,0,33,36,1,0,31,32,1,0,40,41,1,0,1,8, + 2,0,67,67,69,70,261,0,43,1,0,0,0,2,101,1,0,0,0,4,103,1,0,0,0,6,108, + 1,0,0,0,8,143,1,0,0,0,10,175,1,0,0,0,12,183,1,0,0,0,14,191,1,0,0, + 0,16,193,1,0,0,0,18,205,1,0,0,0,20,207,1,0,0,0,22,209,1,0,0,0,24, + 218,1,0,0,0,26,220,1,0,0,0,28,222,1,0,0,0,30,224,1,0,0,0,32,226, + 1,0,0,0,34,228,1,0,0,0,36,230,1,0,0,0,38,232,1,0,0,0,40,42,3,2,1, + 0,41,40,1,0,0,0,42,45,1,0,0,0,43,41,1,0,0,0,43,44,1,0,0,0,44,46, + 1,0,0,0,45,43,1,0,0,0,46,47,5,0,0,1,47,1,1,0,0,0,48,49,5,53,0,0, + 49,50,3,8,4,0,50,51,3,2,1,0,51,102,1,0,0,0,52,53,5,53,0,0,53,54, + 3,8,4,0,54,55,3,2,1,0,55,56,5,54,0,0,56,57,3,2,1,0,57,102,1,0,0, + 0,58,59,5,55,0,0,59,60,3,8,4,0,60,61,3,2,1,0,61,102,1,0,0,0,62,63, + 5,56,0,0,63,64,3,2,1,0,64,65,5,55,0,0,65,66,3,8,4,0,66,102,1,0,0, + 0,67,71,5,57,0,0,68,70,3,2,1,0,69,68,1,0,0,0,70,73,1,0,0,0,71,69, + 1,0,0,0,71,72,1,0,0,0,72,74,1,0,0,0,73,71,1,0,0,0,74,102,5,58,0, + 0,75,76,3,14,7,0,76,77,3,22,11,0,77,79,5,59,0,0,78,80,3,4,2,0,79, + 78,1,0,0,0,79,80,1,0,0,0,80,81,1,0,0,0,81,82,5,60,0,0,82,83,3,2, + 1,0,83,102,1,0,0,0,84,85,3,6,3,0,85,86,5,47,0,0,86,102,1,0,0,0,87, + 88,3,18,9,0,88,89,5,39,0,0,89,90,3,8,4,0,90,91,5,47,0,0,91,102,1, + 0,0,0,92,93,5,9,0,0,93,94,3,8,4,0,94,95,5,47,0,0,95,102,1,0,0,0, + 96,97,3,8,4,0,97,98,5,47,0,0,98,102,1,0,0,0,99,102,7,0,0,0,100,102, + 5,47,0,0,101,48,1,0,0,0,101,52,1,0,0,0,101,58,1,0,0,0,101,62,1,0, + 0,0,101,67,1,0,0,0,101,75,1,0,0,0,101,84,1,0,0,0,101,87,1,0,0,0, + 101,92,1,0,0,0,101,96,1,0,0,0,101,99,1,0,0,0,101,100,1,0,0,0,102, + 3,1,0,0,0,103,106,3,6,3,0,104,105,5,65,0,0,105,107,3,4,2,0,106,104, + 1,0,0,0,106,107,1,0,0,0,107,5,1,0,0,0,108,109,3,14,7,0,109,112,3, + 20,10,0,110,111,5,39,0,0,111,113,3,8,4,0,112,110,1,0,0,0,112,113, + 1,0,0,0,113,7,1,0,0,0,114,115,6,4,-1,0,115,116,5,59,0,0,116,117, + 3,8,4,0,117,118,5,60,0,0,118,144,1,0,0,0,119,144,3,24,12,0,120,144, + 3,18,9,0,121,122,3,22,11,0,122,124,5,59,0,0,123,125,3,10,5,0,124, + 123,1,0,0,0,124,125,1,0,0,0,125,126,1,0,0,0,126,127,5,60,0,0,127, + 144,1,0,0,0,128,129,7,1,0,0,129,144,3,8,4,12,130,131,7,2,0,0,131, + 144,3,12,6,0,132,133,7,3,0,0,133,144,3,8,4,3,134,135,5,26,0,0,135, + 136,3,12,6,0,136,137,5,18,0,0,137,138,3,8,4,2,138,144,1,0,0,0,139, + 140,3,12,6,0,140,141,5,51,0,0,141,142,3,18,9,0,142,144,1,0,0,0,143, + 114,1,0,0,0,143,119,1,0,0,0,143,120,1,0,0,0,143,121,1,0,0,0,143, + 128,1,0,0,0,143,130,1,0,0,0,143,132,1,0,0,0,143,134,1,0,0,0,143, + 139,1,0,0,0,144,170,1,0,0,0,145,146,10,11,0,0,146,147,7,4,0,0,147, + 169,3,8,4,12,148,149,10,10,0,0,149,150,7,5,0,0,150,169,3,8,4,11, + 151,152,10,9,0,0,152,153,7,6,0,0,153,169,3,8,4,10,154,155,10,8,0, + 0,155,156,7,7,0,0,156,169,3,8,4,9,157,158,10,7,0,0,158,159,7,8,0, + 0,159,169,3,8,4,8,160,161,10,6,0,0,161,162,5,16,0,0,162,169,3,8, + 4,7,163,164,10,5,0,0,164,165,5,17,0,0,165,169,3,8,4,6,166,167,10, + 13,0,0,167,169,7,9,0,0,168,145,1,0,0,0,168,148,1,0,0,0,168,151,1, + 0,0,0,168,154,1,0,0,0,168,157,1,0,0,0,168,160,1,0,0,0,168,163,1, + 0,0,0,168,166,1,0,0,0,169,172,1,0,0,0,170,168,1,0,0,0,170,171,1, + 0,0,0,171,9,1,0,0,0,172,170,1,0,0,0,173,176,3,24,12,0,174,176,3, + 18,9,0,175,173,1,0,0,0,175,174,1,0,0,0,176,179,1,0,0,0,177,178,5, + 65,0,0,178,180,3,10,5,0,179,177,1,0,0,0,179,180,1,0,0,0,180,11,1, + 0,0,0,181,184,3,24,12,0,182,184,3,18,9,0,183,181,1,0,0,0,183,182, + 1,0,0,0,184,187,1,0,0,0,185,186,5,65,0,0,186,188,3,12,6,0,187,185, + 1,0,0,0,187,188,1,0,0,0,188,13,1,0,0,0,189,192,3,16,8,0,190,192, + 3,18,9,0,191,189,1,0,0,0,191,190,1,0,0,0,192,15,1,0,0,0,193,194, + 7,10,0,0,194,17,1,0,0,0,195,200,5,74,0,0,196,197,5,63,0,0,197,199, + 5,74,0,0,198,196,1,0,0,0,199,202,1,0,0,0,200,198,1,0,0,0,200,201, + 1,0,0,0,201,206,1,0,0,0,202,200,1,0,0,0,203,206,3,20,10,0,204,206, + 3,22,11,0,205,195,1,0,0,0,205,203,1,0,0,0,205,204,1,0,0,0,206,19, + 1,0,0,0,207,208,5,74,0,0,208,21,1,0,0,0,209,210,5,74,0,0,210,23, + 1,0,0,0,211,219,3,38,19,0,212,219,3,36,18,0,213,219,3,34,17,0,214, + 219,3,28,14,0,215,219,3,30,15,0,216,219,3,32,16,0,217,219,3,26,13, + 0,218,211,1,0,0,0,218,212,1,0,0,0,218,213,1,0,0,0,218,214,1,0,0, + 0,218,215,1,0,0,0,218,216,1,0,0,0,218,217,1,0,0,0,219,25,1,0,0,0, + 220,221,5,75,0,0,221,27,1,0,0,0,222,223,5,71,0,0,223,29,1,0,0,0, + 224,225,5,72,0,0,225,31,1,0,0,0,226,227,5,73,0,0,227,33,1,0,0,0, + 228,229,5,68,0,0,229,35,1,0,0,0,230,231,7,11,0,0,231,37,1,0,0,0, + 232,233,5,66,0,0,233,39,1,0,0,0,18,43,71,79,101,106,112,124,143, + 168,170,175,179,183,187,191,200,205,218 ] class qutes_parser ( Parser ): @@ -112,11 +113,11 @@ class qutes_parser ( Parser ): "'or'", "'by'", "'swap'", "'pauliy'", "'pauliz'", "'grover'", "'mcz'", "'mcx'", "'mcy'", "'mcp'", "'hadamard'", "'measure'", "'print'", "'barrier'", "'=='", "'!='", "'>'", "'>='", - "'<'", "'<='", "'='", "'++'", "'--'", "'+='", "'-='", - "'*='", "'/='", "'%='", "';'", "'var'", "'for'", "'search'", - "'in'", "'where'", "'if'", "'else'", "'while'", "'do'", - "'{'", "'}'", "'('", "')'", "'['", "']'", "'.'", "'\"'", - "','" ] + "'<'", "'<='", "'<<'", "'>>'", "'='", "'++'", "'--'", + "'+='", "'-='", "'*='", "'/='", "'%='", "';'", "'var'", + "'for'", "'search'", "'in'", "'where'", "'if'", "'else'", + "'while'", "'do'", "'{'", "'}'", "'('", "')'", "'['", + "']'", "'.'", "'\"'", "','" ] symbolicNames = [ "", "INT_TYPE", "BOOL_TYPE", "STRING_TYPE", "QUBIT_TYPE", "QUINT_TYPE", "QUSTRING_TYPE", "FLOAT_TYPE", @@ -125,18 +126,19 @@ class qutes_parser ( Parser ): "PAULIZ", "GROVER", "MCZ", "MCX", "MCY", "MCP", "HADAMARD", "MEASURE", "PRINT", "BARRIER", "EQUAL", "NOT_EQUAL", "GREATER", "GREATEREQUAL", "LOWER", "LOWEREQUAL", - "ASSIGN", "AUTO_INCREMENT", "AUTO_DECREMENT", "AUTO_SUM", - "AUTO_SUB", "AUTO_MULTIPLY", "AUTO_DIVIDE", "AUTO_MODULE", - "END_OF_STATEMENT", "VAR_STATEMENT", "FOR_STATEMENT", - "SEARCH_STATEMENT", "IN_STATEMENT", "WHERE_STATEMENT", - "IF_STATEMENT", "ELSE_STATEMENT", "WHILE_STATEMENT", - "DO_STATEMENT", "CURLY_PARENTHESIS_OPEN", "CURLY_PARENTHESIS_CLOSE", - "ROUND_PARENTHESIS_OPEN", "ROUND_PARENTHESIS_CLOSE", - "SQUARE_PARENTHESIS_OPEN", "SQUARE_PARENTHESIS_CLOSE", - "DOT", "STRING_ENCLOSURE", "COMMA", "BOOL_LITERAL", - "INT_LITERAL", "FLOAT_LITERAL", "HEX_LITERAL", "BIN_LITERAL", - "QUBIT_LITERAL", "QUINT_LITERAL", "QUSTRING_LITERAL", - "SYMBOL_LITERAL", "STRING_LITERAL", "WS", "NEWLINE" ] + "LSHIFT", "RSHIFT", "ASSIGN", "AUTO_INCREMENT", "AUTO_DECREMENT", + "AUTO_SUM", "AUTO_SUB", "AUTO_MULTIPLY", "AUTO_DIVIDE", + "AUTO_MODULE", "END_OF_STATEMENT", "VAR_STATEMENT", + "FOR_STATEMENT", "SEARCH_STATEMENT", "IN_STATEMENT", + "WHERE_STATEMENT", "IF_STATEMENT", "ELSE_STATEMENT", + "WHILE_STATEMENT", "DO_STATEMENT", "CURLY_PARENTHESIS_OPEN", + "CURLY_PARENTHESIS_CLOSE", "ROUND_PARENTHESIS_OPEN", + "ROUND_PARENTHESIS_CLOSE", "SQUARE_PARENTHESIS_OPEN", + "SQUARE_PARENTHESIS_CLOSE", "DOT", "STRING_ENCLOSURE", + "COMMA", "BOOL_LITERAL", "INT_LITERAL", "FLOAT_LITERAL", + "HEX_LITERAL", "BIN_LITERAL", "QUBIT_LITERAL", "QUINT_LITERAL", + "QUSTRING_LITERAL", "SYMBOL_LITERAL", "STRING_LITERAL", + "WS", "NEWLINE" ] RULE_program = 0 RULE_statement = 1 @@ -202,45 +204,47 @@ class qutes_parser ( Parser ): GREATEREQUAL=34 LOWER=35 LOWEREQUAL=36 - ASSIGN=37 - AUTO_INCREMENT=38 - AUTO_DECREMENT=39 - AUTO_SUM=40 - AUTO_SUB=41 - AUTO_MULTIPLY=42 - AUTO_DIVIDE=43 - AUTO_MODULE=44 - END_OF_STATEMENT=45 - VAR_STATEMENT=46 - FOR_STATEMENT=47 - SEARCH_STATEMENT=48 - IN_STATEMENT=49 - WHERE_STATEMENT=50 - IF_STATEMENT=51 - ELSE_STATEMENT=52 - WHILE_STATEMENT=53 - DO_STATEMENT=54 - CURLY_PARENTHESIS_OPEN=55 - CURLY_PARENTHESIS_CLOSE=56 - ROUND_PARENTHESIS_OPEN=57 - ROUND_PARENTHESIS_CLOSE=58 - SQUARE_PARENTHESIS_OPEN=59 - SQUARE_PARENTHESIS_CLOSE=60 - DOT=61 - STRING_ENCLOSURE=62 - COMMA=63 - BOOL_LITERAL=64 - INT_LITERAL=65 - FLOAT_LITERAL=66 - HEX_LITERAL=67 - BIN_LITERAL=68 - QUBIT_LITERAL=69 - QUINT_LITERAL=70 - QUSTRING_LITERAL=71 - SYMBOL_LITERAL=72 - STRING_LITERAL=73 - WS=74 - NEWLINE=75 + LSHIFT=37 + RSHIFT=38 + ASSIGN=39 + AUTO_INCREMENT=40 + AUTO_DECREMENT=41 + AUTO_SUM=42 + AUTO_SUB=43 + AUTO_MULTIPLY=44 + AUTO_DIVIDE=45 + AUTO_MODULE=46 + END_OF_STATEMENT=47 + VAR_STATEMENT=48 + FOR_STATEMENT=49 + SEARCH_STATEMENT=50 + IN_STATEMENT=51 + WHERE_STATEMENT=52 + IF_STATEMENT=53 + ELSE_STATEMENT=54 + WHILE_STATEMENT=55 + DO_STATEMENT=56 + CURLY_PARENTHESIS_OPEN=57 + CURLY_PARENTHESIS_CLOSE=58 + ROUND_PARENTHESIS_OPEN=59 + ROUND_PARENTHESIS_CLOSE=60 + SQUARE_PARENTHESIS_OPEN=61 + SQUARE_PARENTHESIS_CLOSE=62 + DOT=63 + STRING_ENCLOSURE=64 + COMMA=65 + BOOL_LITERAL=66 + INT_LITERAL=67 + FLOAT_LITERAL=68 + HEX_LITERAL=69 + BIN_LITERAL=70 + QUBIT_LITERAL=71 + QUINT_LITERAL=72 + QUSTRING_LITERAL=73 + SYMBOL_LITERAL=74 + STRING_LITERAL=75 + WS=76 + NEWLINE=77 def __init__(self, input:TokenStream, output:TextIO = sys.stdout): super().__init__(input, output) @@ -298,7 +302,7 @@ def program(self): self.state = 43 self._errHandler.sync(self) _la = self._input.LA(1) - while (((_la) & ~0x3f) == 0 and ((1 << _la) & 209453393821361150) != 0) or ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & 1023) != 0): + while (((_la) & ~0x3f) == 0 and ((1 << _la) & 837813568856974334) != 0) or ((((_la - 66)) & ~0x3f) == 0 and ((1 << (_la - 66)) & 1023) != 0): self.state = 40 self.statement() self.state = 45 @@ -763,7 +767,7 @@ def statement(self): self.state = 71 self._errHandler.sync(self) _la = self._input.LA(1) - while (((_la) & ~0x3f) == 0 and ((1 << _la) & 209453393821361150) != 0) or ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & 1023) != 0): + while (((_la) & ~0x3f) == 0 and ((1 << _la) & 837813568856974334) != 0) or ((((_la - 66)) & ~0x3f) == 0 and ((1 << (_la - 66)) & 1023) != 0): self.state = 68 self.statement() self.state = 73 @@ -786,7 +790,7 @@ def statement(self): self.state = 79 self._errHandler.sync(self) _la = self._input.LA(1) - if (((_la) & ~0x3f) == 0 and ((1 << _la) & 510) != 0) or _la==72: + if (((_la) & ~0x3f) == 0 and ((1 << _la) & 510) != 0) or _la==74: self.state = 78 self.functionDeclarationParams() @@ -918,7 +922,7 @@ def functionDeclarationParams(self): self.state = 106 self._errHandler.sync(self) _la = self._input.LA(1) - if _la==63: + if _la==65: self.state = 104 self.match(qutes_parser.COMMA) self.state = 105 @@ -990,7 +994,7 @@ def variableDeclaration(self): self.state = 112 self._errHandler.sync(self) _la = self._input.LA(1) - if _la==37: + if _la==39: self.state = 110 self.match(qutes_parser.ASSIGN) self.state = 111 @@ -1466,6 +1470,39 @@ def accept(self, visitor:ParseTreeVisitor): return visitor.visitChildren(self) + class ShiftOperatorContext(ExprContext): + + def __init__(self, parser, ctx:ParserRuleContext): # actually a qutes_parser.ExprContext + super().__init__(parser) + self.op = None # Token + self.copyFrom(ctx) + + def expr(self, i:int=None): + if i is None: + return self.getTypedRuleContexts(qutes_parser.ExprContext) + else: + return self.getTypedRuleContext(qutes_parser.ExprContext,i) + + def LSHIFT(self): + return self.getToken(qutes_parser.LSHIFT, 0) + def RSHIFT(self): + return self.getToken(qutes_parser.RSHIFT, 0) + + def enterRule(self, listener:ParseTreeListener): + if hasattr( listener, "enterShiftOperator" ): + listener.enterShiftOperator(self) + + def exitRule(self, listener:ParseTreeListener): + if hasattr( listener, "exitShiftOperator" ): + listener.exitShiftOperator(self) + + def accept(self, visitor:ParseTreeVisitor): + if hasattr( visitor, "visitShiftOperator" ): + return visitor.visitShiftOperator(self) + else: + return visitor.visitChildren(self) + + class UnaryOperatorContext(ExprContext): def __init__(self, parser, ctx:ParserRuleContext): # actually a qutes_parser.ExprContext @@ -1587,7 +1624,7 @@ def expr(self, _p:int=0): self.state = 124 self._errHandler.sync(self) _la = self._input.LA(1) - if ((((_la - 64)) & ~0x3f) == 0 and ((1 << (_la - 64)) & 1023) != 0): + if ((((_la - 66)) & ~0x3f) == 0 and ((1 << (_la - 66)) & 1023) != 0): self.state = 123 self.functionCallParams() @@ -1603,13 +1640,13 @@ def expr(self, _p:int=0): self.state = 128 localctx.op = self._input.LT(1) _la = self._input.LA(1) - if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 824633778176) != 0)): + if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 3298534940672) != 0)): localctx.op = self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) self.consume() self.state = 129 - self.expr(11) + self.expr(12) pass elif la_ == 6: @@ -1672,7 +1709,7 @@ def expr(self, _p:int=0): self._ctx.stop = self._input.LT(-1) - self.state = 167 + self.state = 170 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,9,self._ctx) while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: @@ -1680,16 +1717,16 @@ def expr(self, _p:int=0): if self._parseListeners is not None: self.triggerExitRuleEvent() _prevctx = localctx - self.state = 165 + self.state = 168 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,8,self._ctx) if la_ == 1: localctx = qutes_parser.MultiplicativeOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) self.state = 145 - if not self.precpred(self._ctx, 10): + if not self.precpred(self._ctx, 11): from antlr4.error.Errors import FailedPredicateException - raise FailedPredicateException(self, "self.precpred(self._ctx, 10)") + raise FailedPredicateException(self, "self.precpred(self._ctx, 11)") self.state = 146 localctx.op = self._input.LT(1) _la = self._input.LA(1) @@ -1699,16 +1736,16 @@ def expr(self, _p:int=0): self._errHandler.reportMatch(self) self.consume() self.state = 147 - self.expr(11) + self.expr(12) pass elif la_ == 2: localctx = qutes_parser.SumOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) self.state = 148 - if not self.precpred(self._ctx, 9): + if not self.precpred(self._ctx, 10): from antlr4.error.Errors import FailedPredicateException - raise FailedPredicateException(self, "self.precpred(self._ctx, 9)") + raise FailedPredicateException(self, "self.precpred(self._ctx, 10)") self.state = 149 localctx.op = self._input.LT(1) _la = self._input.LA(1) @@ -1718,17 +1755,36 @@ def expr(self, _p:int=0): self._errHandler.reportMatch(self) self.consume() self.state = 150 - self.expr(10) + self.expr(11) pass elif la_ == 3: - localctx = qutes_parser.RelationalOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) + localctx = qutes_parser.ShiftOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) self.state = 151 + if not self.precpred(self._ctx, 9): + from antlr4.error.Errors import FailedPredicateException + raise FailedPredicateException(self, "self.precpred(self._ctx, 9)") + self.state = 152 + localctx.op = self._input.LT(1) + _la = self._input.LA(1) + if not(_la==37 or _la==38): + localctx.op = self._errHandler.recoverInline(self) + else: + self._errHandler.reportMatch(self) + self.consume() + self.state = 153 + self.expr(10) + pass + + elif la_ == 4: + localctx = qutes_parser.RelationalOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) + self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) + self.state = 154 if not self.precpred(self._ctx, 8): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 8)") - self.state = 152 + self.state = 155 localctx.op = self._input.LT(1) _la = self._input.LA(1) if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 128849018880) != 0)): @@ -1736,18 +1792,18 @@ def expr(self, _p:int=0): else: self._errHandler.reportMatch(self) self.consume() - self.state = 153 + self.state = 156 self.expr(9) pass - elif la_ == 4: + elif la_ == 5: localctx = qutes_parser.EqualityOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) - self.state = 154 + self.state = 157 if not self.precpred(self._ctx, 7): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 7)") - self.state = 155 + self.state = 158 localctx.op = self._input.LT(1) _la = self._input.LA(1) if not(_la==31 or _la==32): @@ -1755,47 +1811,47 @@ def expr(self, _p:int=0): else: self._errHandler.reportMatch(self) self.consume() - self.state = 156 + self.state = 159 self.expr(8) pass - elif la_ == 5: + elif la_ == 6: localctx = qutes_parser.LogicAndOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) - self.state = 157 + self.state = 160 if not self.precpred(self._ctx, 6): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 6)") - self.state = 158 + self.state = 161 localctx.op = self.match(qutes_parser.AND) - self.state = 159 + self.state = 162 self.expr(7) pass - elif la_ == 6: + elif la_ == 7: localctx = qutes_parser.LogicOrOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) - self.state = 160 + self.state = 163 if not self.precpred(self._ctx, 5): from antlr4.error.Errors import FailedPredicateException raise FailedPredicateException(self, "self.precpred(self._ctx, 5)") - self.state = 161 + self.state = 164 localctx.op = self.match(qutes_parser.OR) - self.state = 162 + self.state = 165 self.expr(6) pass - elif la_ == 7: + elif la_ == 8: localctx = qutes_parser.PostfixOperatorContext(self, qutes_parser.ExprContext(self, _parentctx, _parentState)) self.pushNewRecursionContext(localctx, _startState, self.RULE_expr) - self.state = 163 - if not self.precpred(self._ctx, 12): + self.state = 166 + if not self.precpred(self._ctx, 13): from antlr4.error.Errors import FailedPredicateException - raise FailedPredicateException(self, "self.precpred(self._ctx, 12)") - self.state = 164 + raise FailedPredicateException(self, "self.precpred(self._ctx, 13)") + self.state = 167 localctx.op = self._input.LT(1) _la = self._input.LA(1) - if not(_la==38 or _la==39): + if not(_la==40 or _la==41): localctx.op = self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -1803,7 +1859,7 @@ def expr(self, _p:int=0): pass - self.state = 169 + self.state = 172 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,9,self._ctx) @@ -1865,27 +1921,27 @@ def functionCallParams(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 172 + self.state = 175 self._errHandler.sync(self) token = self._input.LA(1) - if token in [64, 65, 66, 67, 68, 69, 70, 71, 73]: - self.state = 170 + if token in [66, 67, 68, 69, 70, 71, 72, 73, 75]: + self.state = 173 self.literal() pass - elif token in [72]: - self.state = 171 + elif token in [74]: + self.state = 174 self.qualifiedName() pass else: raise NoViableAltException(self) - self.state = 176 + self.state = 179 self._errHandler.sync(self) _la = self._input.LA(1) - if _la==63: - self.state = 174 + if _la==65: + self.state = 177 self.match(qutes_parser.COMMA) - self.state = 175 + self.state = 178 self.functionCallParams() @@ -1946,27 +2002,27 @@ def termList(self): self.enterRule(localctx, 12, self.RULE_termList) try: self.enterOuterAlt(localctx, 1) - self.state = 180 + self.state = 183 self._errHandler.sync(self) token = self._input.LA(1) - if token in [64, 65, 66, 67, 68, 69, 70, 71, 73]: - self.state = 178 + if token in [66, 67, 68, 69, 70, 71, 72, 73, 75]: + self.state = 181 self.literal() pass - elif token in [72]: - self.state = 179 + elif token in [74]: + self.state = 182 self.qualifiedName() pass else: raise NoViableAltException(self) - self.state = 184 + self.state = 187 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,13,self._ctx) if la_ == 1: - self.state = 182 + self.state = 185 self.match(qutes_parser.COMMA) - self.state = 183 + self.state = 186 self.termList() @@ -2019,17 +2075,17 @@ def variableType(self): localctx = qutes_parser.VariableTypeContext(self, self._ctx, self.state) self.enterRule(localctx, 14, self.RULE_variableType) try: - self.state = 188 + self.state = 191 self._errHandler.sync(self) token = self._input.LA(1) if token in [1, 2, 3, 4, 5, 6, 7, 8]: self.enterOuterAlt(localctx, 1) - self.state = 186 + self.state = 189 self.type_() pass - elif token in [72]: + elif token in [74]: self.enterOuterAlt(localctx, 2) - self.state = 187 + self.state = 190 self.qualifiedName() pass else: @@ -2102,7 +2158,7 @@ def type_(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 190 + self.state = 193 _la = self._input.LA(1) if not((((_la) & ~0x3f) == 0 and ((1 << _la) & 510) != 0)): self._errHandler.recoverInline(self) @@ -2170,23 +2226,23 @@ def qualifiedName(self): localctx = qutes_parser.QualifiedNameContext(self, self._ctx, self.state) self.enterRule(localctx, 18, self.RULE_qualifiedName) try: - self.state = 202 + self.state = 205 self._errHandler.sync(self) la_ = self._interp.adaptivePredict(self._input,16,self._ctx) if la_ == 1: self.enterOuterAlt(localctx, 1) - self.state = 192 + self.state = 195 self.match(qutes_parser.SYMBOL_LITERAL) - self.state = 197 + self.state = 200 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,15,self._ctx) while _alt!=2 and _alt!=ATN.INVALID_ALT_NUMBER: if _alt==1: - self.state = 193 + self.state = 196 self.match(qutes_parser.DOT) - self.state = 194 + self.state = 197 self.match(qutes_parser.SYMBOL_LITERAL) - self.state = 199 + self.state = 202 self._errHandler.sync(self) _alt = self._interp.adaptivePredict(self._input,15,self._ctx) @@ -2194,13 +2250,13 @@ def qualifiedName(self): elif la_ == 2: self.enterOuterAlt(localctx, 2) - self.state = 200 + self.state = 203 self.variableName() pass elif la_ == 3: self.enterOuterAlt(localctx, 3) - self.state = 201 + self.state = 204 self.functionName() pass @@ -2250,7 +2306,7 @@ def variableName(self): self.enterRule(localctx, 20, self.RULE_variableName) try: self.enterOuterAlt(localctx, 1) - self.state = 204 + self.state = 207 self.match(qutes_parser.SYMBOL_LITERAL) except RecognitionException as re: localctx.exception = re @@ -2297,7 +2353,7 @@ def functionName(self): self.enterRule(localctx, 22, self.RULE_functionName) try: self.enterOuterAlt(localctx, 1) - self.state = 206 + self.state = 209 self.match(qutes_parser.SYMBOL_LITERAL) except RecognitionException as re: localctx.exception = re @@ -2368,42 +2424,42 @@ def literal(self): localctx = qutes_parser.LiteralContext(self, self._ctx, self.state) self.enterRule(localctx, 24, self.RULE_literal) try: - self.state = 215 + self.state = 218 self._errHandler.sync(self) token = self._input.LA(1) - if token in [64]: + if token in [66]: self.enterOuterAlt(localctx, 1) - self.state = 208 + self.state = 211 self.boolean() pass - elif token in [65, 67, 68]: + elif token in [67, 69, 70]: self.enterOuterAlt(localctx, 2) - self.state = 209 + self.state = 212 self.integer() pass - elif token in [66]: + elif token in [68]: self.enterOuterAlt(localctx, 3) - self.state = 210 + self.state = 213 self.float_() pass - elif token in [69]: + elif token in [71]: self.enterOuterAlt(localctx, 4) - self.state = 211 + self.state = 214 self.qubit() pass - elif token in [70]: + elif token in [72]: self.enterOuterAlt(localctx, 5) - self.state = 212 + self.state = 215 self.quint() pass - elif token in [71]: + elif token in [73]: self.enterOuterAlt(localctx, 6) - self.state = 213 + self.state = 216 self.qustring() pass - elif token in [73]: + elif token in [75]: self.enterOuterAlt(localctx, 7) - self.state = 214 + self.state = 217 self.string() pass else: @@ -2454,7 +2510,7 @@ def string(self): self.enterRule(localctx, 26, self.RULE_string) try: self.enterOuterAlt(localctx, 1) - self.state = 217 + self.state = 220 self.match(qutes_parser.STRING_LITERAL) except RecognitionException as re: localctx.exception = re @@ -2501,7 +2557,7 @@ def qubit(self): self.enterRule(localctx, 28, self.RULE_qubit) try: self.enterOuterAlt(localctx, 1) - self.state = 219 + self.state = 222 self.match(qutes_parser.QUBIT_LITERAL) except RecognitionException as re: localctx.exception = re @@ -2548,7 +2604,7 @@ def quint(self): self.enterRule(localctx, 30, self.RULE_quint) try: self.enterOuterAlt(localctx, 1) - self.state = 221 + self.state = 224 self.match(qutes_parser.QUINT_LITERAL) except RecognitionException as re: localctx.exception = re @@ -2595,7 +2651,7 @@ def qustring(self): self.enterRule(localctx, 32, self.RULE_qustring) try: self.enterOuterAlt(localctx, 1) - self.state = 223 + self.state = 226 self.match(qutes_parser.QUSTRING_LITERAL) except RecognitionException as re: localctx.exception = re @@ -2642,7 +2698,7 @@ def float_(self): self.enterRule(localctx, 34, self.RULE_float) try: self.enterOuterAlt(localctx, 1) - self.state = 225 + self.state = 228 self.match(qutes_parser.FLOAT_LITERAL) except RecognitionException as re: localctx.exception = re @@ -2696,9 +2752,9 @@ def integer(self): self._la = 0 # Token type try: self.enterOuterAlt(localctx, 1) - self.state = 227 + self.state = 230 _la = self._input.LA(1) - if not(((((_la - 65)) & ~0x3f) == 0 and ((1 << (_la - 65)) & 13) != 0)): + if not(((((_la - 67)) & ~0x3f) == 0 and ((1 << (_la - 67)) & 13) != 0)): self._errHandler.recoverInline(self) else: self._errHandler.reportMatch(self) @@ -2748,7 +2804,7 @@ def boolean(self): self.enterRule(localctx, 38, self.RULE_boolean) try: self.enterOuterAlt(localctx, 1) - self.state = 229 + self.state = 232 self.match(qutes_parser.BOOL_LITERAL) except RecognitionException as re: localctx.exception = re @@ -2772,31 +2828,35 @@ def sempred(self, localctx:RuleContext, ruleIndex:int, predIndex:int): def expr_sempred(self, localctx:ExprContext, predIndex:int): if predIndex == 0: - return self.precpred(self._ctx, 10) + return self.precpred(self._ctx, 11) if predIndex == 1: - return self.precpred(self._ctx, 9) + return self.precpred(self._ctx, 10) if predIndex == 2: - return self.precpred(self._ctx, 8) + return self.precpred(self._ctx, 9) if predIndex == 3: - return self.precpred(self._ctx, 7) + return self.precpred(self._ctx, 8) if predIndex == 4: - return self.precpred(self._ctx, 6) + return self.precpred(self._ctx, 7) if predIndex == 5: - return self.precpred(self._ctx, 5) + return self.precpred(self._ctx, 6) if predIndex == 6: - return self.precpred(self._ctx, 12) + return self.precpred(self._ctx, 5) + + + if predIndex == 7: + return self.precpred(self._ctx, 13) diff --git a/src/qutes_antlr/qutes_parser.tokens b/src/qutes_antlr/qutes_parser.tokens index 2d74c03..9f5f556 100644 --- a/src/qutes_antlr/qutes_parser.tokens +++ b/src/qutes_antlr/qutes_parser.tokens @@ -34,45 +34,47 @@ GREATER=33 GREATEREQUAL=34 LOWER=35 LOWEREQUAL=36 -ASSIGN=37 -AUTO_INCREMENT=38 -AUTO_DECREMENT=39 -AUTO_SUM=40 -AUTO_SUB=41 -AUTO_MULTIPLY=42 -AUTO_DIVIDE=43 -AUTO_MODULE=44 -END_OF_STATEMENT=45 -VAR_STATEMENT=46 -FOR_STATEMENT=47 -SEARCH_STATEMENT=48 -IN_STATEMENT=49 -WHERE_STATEMENT=50 -IF_STATEMENT=51 -ELSE_STATEMENT=52 -WHILE_STATEMENT=53 -DO_STATEMENT=54 -CURLY_PARENTHESIS_OPEN=55 -CURLY_PARENTHESIS_CLOSE=56 -ROUND_PARENTHESIS_OPEN=57 -ROUND_PARENTHESIS_CLOSE=58 -SQUARE_PARENTHESIS_OPEN=59 -SQUARE_PARENTHESIS_CLOSE=60 -DOT=61 -STRING_ENCLOSURE=62 -COMMA=63 -BOOL_LITERAL=64 -INT_LITERAL=65 -FLOAT_LITERAL=66 -HEX_LITERAL=67 -BIN_LITERAL=68 -QUBIT_LITERAL=69 -QUINT_LITERAL=70 -QUSTRING_LITERAL=71 -SYMBOL_LITERAL=72 -STRING_LITERAL=73 -WS=74 -NEWLINE=75 +LSHIFT=37 +RSHIFT=38 +ASSIGN=39 +AUTO_INCREMENT=40 +AUTO_DECREMENT=41 +AUTO_SUM=42 +AUTO_SUB=43 +AUTO_MULTIPLY=44 +AUTO_DIVIDE=45 +AUTO_MODULE=46 +END_OF_STATEMENT=47 +VAR_STATEMENT=48 +FOR_STATEMENT=49 +SEARCH_STATEMENT=50 +IN_STATEMENT=51 +WHERE_STATEMENT=52 +IF_STATEMENT=53 +ELSE_STATEMENT=54 +WHILE_STATEMENT=55 +DO_STATEMENT=56 +CURLY_PARENTHESIS_OPEN=57 +CURLY_PARENTHESIS_CLOSE=58 +ROUND_PARENTHESIS_OPEN=59 +ROUND_PARENTHESIS_CLOSE=60 +SQUARE_PARENTHESIS_OPEN=61 +SQUARE_PARENTHESIS_CLOSE=62 +DOT=63 +STRING_ENCLOSURE=64 +COMMA=65 +BOOL_LITERAL=66 +INT_LITERAL=67 +FLOAT_LITERAL=68 +HEX_LITERAL=69 +BIN_LITERAL=70 +QUBIT_LITERAL=71 +QUINT_LITERAL=72 +QUSTRING_LITERAL=73 +SYMBOL_LITERAL=74 +STRING_LITERAL=75 +WS=76 +NEWLINE=77 'int'=1 'bool'=2 'string'=3 @@ -109,30 +111,32 @@ NEWLINE=75 '>='=34 '<'=35 '<='=36 -'='=37 -'++'=38 -'--'=39 -'+='=40 -'-='=41 -'*='=42 -'/='=43 -'%='=44 -';'=45 -'var'=46 -'for'=47 -'search'=48 -'in'=49 -'where'=50 -'if'=51 -'else'=52 -'while'=53 -'do'=54 -'{'=55 -'}'=56 -'('=57 -')'=58 -'['=59 -']'=60 -'.'=61 -'"'=62 -','=63 +'<<'=37 +'>>'=38 +'='=39 +'++'=40 +'--'=41 +'+='=42 +'-='=43 +'*='=44 +'/='=45 +'%='=46 +';'=47 +'var'=48 +'for'=49 +'search'=50 +'in'=51 +'where'=52 +'if'=53 +'else'=54 +'while'=55 +'do'=56 +'{'=57 +'}'=58 +'('=59 +')'=60 +'['=61 +']'=62 +'.'=63 +'"'=64 +','=65 diff --git a/src/qutes_antlr/qutes_parserListener.py b/src/qutes_antlr/qutes_parserListener.py index 903f88a..bd7d433 100644 --- a/src/qutes_antlr/qutes_parserListener.py +++ b/src/qutes_antlr/qutes_parserListener.py @@ -269,6 +269,15 @@ def exitMultiplicativeOperator(self, ctx:qutes_parser.MultiplicativeOperatorCont pass + # Enter a parse tree produced by qutes_parser#ShiftOperator. + def enterShiftOperator(self, ctx:qutes_parser.ShiftOperatorContext): + pass + + # Exit a parse tree produced by qutes_parser#ShiftOperator. + def exitShiftOperator(self, ctx:qutes_parser.ShiftOperatorContext): + pass + + # Enter a parse tree produced by qutes_parser#UnaryOperator. def enterUnaryOperator(self, ctx:qutes_parser.UnaryOperatorContext): pass diff --git a/src/qutes_antlr/qutes_parserVisitor.py b/src/qutes_antlr/qutes_parserVisitor.py index afe65a0..cff0cb9 100644 --- a/src/qutes_antlr/qutes_parserVisitor.py +++ b/src/qutes_antlr/qutes_parserVisitor.py @@ -154,6 +154,11 @@ def visitMultiplicativeOperator(self, ctx:qutes_parser.MultiplicativeOperatorCon return self.visitChildren(ctx) + # Visit a parse tree produced by qutes_parser#ShiftOperator. + def visitShiftOperator(self, ctx:qutes_parser.ShiftOperatorContext): + return self.visitChildren(ctx) + + # Visit a parse tree produced by qutes_parser#UnaryOperator. def visitUnaryOperator(self, ctx:qutes_parser.UnaryOperatorContext): return self.visitChildren(ctx) diff --git a/src/tests/test_operations.py b/src/tests/test_operations.py new file mode 100644 index 0000000..e671cb2 --- /dev/null +++ b/src/tests/test_operations.py @@ -0,0 +1,77 @@ +from .qutes_base_test import QutesBaseTest + +class TestOperation(QutesBaseTest): + TOKEN_AST_INDEX_FOR_TESTS = 100000 + + def assert_operation_test(self, code, var_name, expected_value_of_var): + result = self.parse_qutes_code(code) + actual_value_of_var = str(result.variables_handler.get_variable_symbol(var_name, self.TOKEN_AST_INDEX_FOR_TESTS).value) + self.assertEqual(actual_value_of_var, str(expected_value_of_var), f"Expected value: {expected_value_of_var}, actual value: {actual_value_of_var}") + + def test_left_shift_return_expected_value(self): + params = [ + ("\"01111111\"", "0", "01111111"), + ("\"0111111\"", "0", "0111111"), + ("\"01111111\"", "1", "11111110"), + ("\"0111111\"", "1", "1111110"), + ("\"01111111\"", "2", "11111101"), + ("\"0111111\"", "2", "1111101"), + ("\"01111111\"", "3", "11111011"), + ("\"0111111\"", "3", "1111011"), + ("\"01111111\"", "4", "11110111"), + ("\"0111111\"", "4", "1110111"), + ("\"01111111\"", "5", "11101111"), + ("\"0111111\"", "5", "1101111"), + ("\"01111111\"", "6", "11011111"), + ("\"0111111\"", "6", "1011111"), + ("\"01111111\"", "7", "10111111"), + ("\"0111111\"", "7", "0111111"), + ("\"01111111\"", "8", "01111111"), + ("\"0111111\"", "8", "1111110"), + ("\"01111111\"", "9", "11111110"), + ("\"0111111\"", "9", "1111101"), + ] + var_name = "a" + var_result_name = "result" + for init_string, n_shift, expected_value_of_var in params: + with self.subTest(init_string=init_string, n_shift=n_shift, expected_value_of_var=expected_value_of_var): + code = f""" + qustring {var_name} = {init_string}; + {var_name} >> {n_shift}; + string {var_result_name} = {var_name}; + """ + self.assert_operation_test(code, var_result_name, expected_value_of_var) + + def test_right_shift_return_expected_value(self): + params = [ + ("\"01111111\"", "0", "01111111"), + ("\"0111111\"", "0", "0111111"), + ("\"01111111\"", "1", "10111111"), + ("\"0111111\"", "1", "1011111"), + ("\"01111111\"", "2", "11011111"), + ("\"0111111\"", "2", "1101111"), + ("\"01111111\"", "3", "11101111"), + ("\"0111111\"", "3", "1110111"), + ("\"01111111\"", "4", "11110111"), + ("\"0111111\"", "4", "1111011"), + ("\"01111111\"", "5", "11111011"), + ("\"0111111\"", "5", "1111101"), + ("\"01111111\"", "6", "11111101"), + ("\"0111111\"", "6", "1111110"), + ("\"01111111\"", "7", "11111110"), + ("\"0111111\"", "7", "0111111"), + ("\"01111111\"", "8", "01111111"), + ("\"0111111\"", "8", "1011111"), + ("\"01111111\"", "9", "10111111"), + ("\"0111111\"", "9", "1101111"), + ] + var_name = "a" + var_result_name = "result" + for init_string, n_shift, expected_value_of_var in params: + with self.subTest(init_string=init_string, n_shift=n_shift, expected_value_of_var=expected_value_of_var): + code = f""" + qustring {var_name} = {init_string}; + {var_name} << {n_shift}; + string {var_result_name} = {var_name}; + """ + self.assert_operation_test(code, var_result_name, expected_value_of_var)