1252884aeSStefan Eßer /* 2252884aeSStefan Eßer * ***************************************************************************** 3252884aeSStefan Eßer * 43aa99676SStefan Eßer * SPDX-License-Identifier: BSD-2-Clause 5252884aeSStefan Eßer * 6a970610aSStefan Eßer * Copyright (c) 2018-2024 Gavin D. Howard and contributors. 7252884aeSStefan Eßer * 8252884aeSStefan Eßer * Redistribution and use in source and binary forms, with or without 9252884aeSStefan Eßer * modification, are permitted provided that the following conditions are met: 10252884aeSStefan Eßer * 11252884aeSStefan Eßer * * Redistributions of source code must retain the above copyright notice, this 12252884aeSStefan Eßer * list of conditions and the following disclaimer. 13252884aeSStefan Eßer * 14252884aeSStefan Eßer * * Redistributions in binary form must reproduce the above copyright notice, 15252884aeSStefan Eßer * this list of conditions and the following disclaimer in the documentation 16252884aeSStefan Eßer * and/or other materials provided with the distribution. 17252884aeSStefan Eßer * 18252884aeSStefan Eßer * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" 19252884aeSStefan Eßer * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20252884aeSStefan Eßer * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21252884aeSStefan Eßer * ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE 22252884aeSStefan Eßer * LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 23252884aeSStefan Eßer * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF 24252884aeSStefan Eßer * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 25252884aeSStefan Eßer * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 26252884aeSStefan Eßer * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 27252884aeSStefan Eßer * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE 28252884aeSStefan Eßer * POSSIBILITY OF SUCH DAMAGE. 29252884aeSStefan Eßer * 30252884aeSStefan Eßer * ***************************************************************************** 31252884aeSStefan Eßer * 3244d4804dSStefan Eßer * Definitions for dc only. 33252884aeSStefan Eßer * 34252884aeSStefan Eßer */ 35252884aeSStefan Eßer 36252884aeSStefan Eßer #ifndef BC_DC_H 37252884aeSStefan Eßer #define BC_DC_H 38252884aeSStefan Eßer 39252884aeSStefan Eßer #if DC_ENABLED 40252884aeSStefan Eßer 41252884aeSStefan Eßer #include <status.h> 42252884aeSStefan Eßer #include <lex.h> 43252884aeSStefan Eßer #include <parse.h> 44252884aeSStefan Eßer 4544d4804dSStefan Eßer /** 4644d4804dSStefan Eßer * The main function for dc. It just sets variables and passes its arguments 4744d4804dSStefan Eßer * through to @a bc_vm_boot(). 48a970610aSStefan Eßer * @return A status. 4944d4804dSStefan Eßer */ 50a970610aSStefan Eßer BcStatus 51*12e0d316SStefan Eßer dc_main(int argc, const char* argv[]); 52252884aeSStefan Eßer 5344d4804dSStefan Eßer // A reference to the dc help text. 54252884aeSStefan Eßer extern const char dc_help[]; 55252884aeSStefan Eßer 5644d4804dSStefan Eßer /** 5744d4804dSStefan Eßer * The @a BcLexNext function for dc. (See include/lex.h for a definition of 5844d4804dSStefan Eßer * @a BcLexNext.) 5944d4804dSStefan Eßer * @param l The lexer. 6044d4804dSStefan Eßer */ 6178bc019dSStefan Eßer void 6278bc019dSStefan Eßer dc_lex_token(BcLex* l); 6344d4804dSStefan Eßer 6444d4804dSStefan Eßer /** 6544d4804dSStefan Eßer * Returns true if the negative char `_` should be treated as a command or not. 6644d4804dSStefan Eßer * dc considers negative a command if it does *not* immediately proceed a 6744d4804dSStefan Eßer * number. Otherwise, it's just considered a negative. 6844d4804dSStefan Eßer * @param l The lexer. 6944d4804dSStefan Eßer * @return True if a negative should be treated as a command, false if it 7044d4804dSStefan Eßer * should be treated as a negative sign on a number. 7144d4804dSStefan Eßer */ 7278bc019dSStefan Eßer bool 7378bc019dSStefan Eßer dc_lex_negCommand(BcLex* l); 74252884aeSStefan Eßer 7544d4804dSStefan Eßer // References to the signal message and its length. 76252884aeSStefan Eßer extern const char dc_sig_msg[]; 77252884aeSStefan Eßer extern const uchar dc_sig_msg_len; 78252884aeSStefan Eßer 7944d4804dSStefan Eßer // References to an array and its length. This array is an array of lex tokens 8044d4804dSStefan Eßer // that, when encountered, should be treated as commands that take a register. 81252884aeSStefan Eßer extern const uint8_t dc_lex_regs[]; 82252884aeSStefan Eßer extern const size_t dc_lex_regs_len; 83252884aeSStefan Eßer 8444d4804dSStefan Eßer // References to an array of tokens and its length. This array corresponds to 8544d4804dSStefan Eßer // the ASCII table, starting at double quotes. This makes it easy to look up 8644d4804dSStefan Eßer // tokens for characters. 87252884aeSStefan Eßer extern const uint8_t dc_lex_tokens[]; 88252884aeSStefan Eßer extern const uint8_t dc_parse_insts[]; 89252884aeSStefan Eßer 9044d4804dSStefan Eßer /** 9144d4804dSStefan Eßer * The @a BcParseParse function for dc. (See include/parse.h for a definition of 9244d4804dSStefan Eßer * @a BcParseParse.) 9344d4804dSStefan Eßer * @param p The parser. 9444d4804dSStefan Eßer */ 9578bc019dSStefan Eßer void 9678bc019dSStefan Eßer dc_parse_parse(BcParse* p); 9744d4804dSStefan Eßer 9844d4804dSStefan Eßer /** 9944d4804dSStefan Eßer * The @a BcParseExpr function for dc. (See include/parse.h for a definition of 10044d4804dSStefan Eßer * @a BcParseExpr.) 10144d4804dSStefan Eßer * @param p The parser. 10244d4804dSStefan Eßer * @param flags Flags that define the requirements that the parsed code must 10344d4804dSStefan Eßer * meet or an error will result. See @a BcParseExpr for more info. 10444d4804dSStefan Eßer */ 10578bc019dSStefan Eßer void 10678bc019dSStefan Eßer dc_parse_expr(BcParse* p, uint8_t flags); 107252884aeSStefan Eßer 108252884aeSStefan Eßer #endif // DC_ENABLED 109252884aeSStefan Eßer 110252884aeSStefan Eßer #endif // BC_DC_H 111