def _unlock_command(self): """ Matches based on the rule # unlock -> UNLOCK "(" primary ")" ; """ self._consume(TokenType.LEFT_PAREN, "Except '(' after unlock .") _key = self._primary() self._consume(TokenType.RIGHT_PAREN, "Except ')' after unlock.") return grammar.Command(CommandType.UNLOCK_COMMAND, (_key, ))
def _subscribe_command(self): """ Matches based on the rule # subscribe -> SUBSCRIBE "(" primary ")" ; """ self._consume(TokenType.LEFT_PAREN, "Except '(' after remove.") _key = self._primary() self._consume(TokenType.RIGHT_PAREN, "Except ')' after remove.") return grammar.Command(CommandType.SUBSCRIBE_COMMAND, (_key, ))
def _publish_command(self): """ Matches based on the rule # publish -> PUBLISH "(" python_ref")" ; """ self._consume(TokenType.LEFT_PAREN, "Except '(' after remove.") _value = self._primary() self._consume(TokenType.RIGHT_PAREN, "Except ')' after remove.") return grammar.Command(CommandType.PUBLISH_COMMAND, (_value, ))
def _register_command(self): """ Matches based on the rule # register -> REGISTER "(" primary ")" ; """ self._consume(TokenType.LEFT_PAREN, "Except '(' after remove.") _key = self._primary() self._consume(TokenType.RIGHT_PAREN, "Except ')' after remove.") return grammar.Command(CommandType.REGISTER_COMMAND, (_key, ))
def _read_command(self): """ Matches based on the rule # read -> READ "(" primary ")" ; """ self._consume(TokenType.LEFT_PAREN, "Except '(' after read.") _key = self._primary() self._consume(TokenType.RIGHT_PAREN, "Except ')' after read.") return grammar.Command(CommandType.GET_COMMAND, (_key, )) # have it in a tuble: immutable list
def _write_command(self): """ Matches based on the rule # write -> WRITE "(" primary "," expression | python_ref")" ; """ self._consume(TokenType.LEFT_PAREN, "Except '(' after write.") _key = self._primary() self._consume(TokenType.COMMA, "Except ',' after command's key.") if self._check(TokenType.AT): _value = self._python_ref() else: _value = self._expression() self._consume(TokenType.RIGHT_PAREN, "Except ')' after command's key.") return grammar.Command(CommandType.PUT_COMMAND, (_key, _value))