aboutsummaryrefslogtreecommitdiffstats
path: root/include
diff options
context:
space:
mode:
authorGavin Howard <gavin@yzena.com>2021-07-21 21:34:57 -0600
committerGavin Howard <gavin@yzena.com>2021-07-21 21:34:57 -0600
commit54f887af733b2327f264f9b20c4e6ef0ca40dc34 (patch)
treebbdb07b9fef25d83b36f300ede9e44775340975c /include
parent1975395e9b3dd8b53a984b143c040df5930134c0 (diff)
downloadplatform_external_bc-54f887af733b2327f264f9b20c4e6ef0ca40dc34.tar.gz
platform_external_bc-54f887af733b2327f264f9b20c4e6ef0ca40dc34.tar.bz2
platform_external_bc-54f887af733b2327f264f9b20c4e6ef0ca40dc34.zip
Add asciify() and stream
Signed-off-by: Gavin Howard <gavin@yzena.com>
Diffstat (limited to 'include')
-rw-r--r--include/bc.h4
-rw-r--r--include/lang.h18
-rw-r--r--include/lex.h25
-rw-r--r--include/program.h10
4 files changed, 33 insertions, 24 deletions
diff --git a/include/bc.h b/include/bc.h
index c2404352..2b47ea7b 100644
--- a/include/bc.h
+++ b/include/bc.h
@@ -94,13 +94,13 @@ typedef struct BcLexKeyword {
/// A macro for the number of keywords bc has. This has to be updated if any are
/// added. This is for the redefined_kws field of the BcVm struct.
-#define BC_LEX_NKWS (30)
+#define BC_LEX_NKWS (32)
#else // BC_ENABLE_EXTRA_MATH
/// A macro for the number of keywords bc has. This has to be updated if any are
/// added. This is for the redefined_kws field of the BcVm struct.
-#define BC_LEX_NKWS (26)
+#define BC_LEX_NKWS (28)
#endif // BC_ENABLE_EXTRA_MATH
diff --git a/include/lang.h b/include/lang.h
index 0a71c612..9850549c 100644
--- a/include/lang.h
+++ b/include/lang.h
@@ -181,6 +181,9 @@ typedef enum BcInst {
BC_INST_IRAND,
#endif // BC_ENABLE_EXTRA_MATH
+ /// Asciify.
+ BC_INST_ASCIIFY,
+
/// Another builtin function.
BC_INST_READ,
@@ -242,12 +245,18 @@ typedef enum BcInst {
/// Pop an item off of the results stack.
BC_INST_POP,
+ /// Swaps the top two items on the results stack.
+ BC_INST_SWAP,
+
/// Modular exponentiation.
BC_INST_MODEXP,
/// Do divide and modulus at the same time.
BC_INST_DIVMOD,
+ /// Turns a number into a string and prints it.
+ BC_INST_PRINT_STREAM,
+
#if DC_ENABLED
/// dc's return; it pops an executing string off of the stack.
@@ -259,12 +268,6 @@ typedef enum BcInst {
/// Conditionally execute a string.
BC_INST_EXEC_COND,
- /// Asciify.
- BC_INST_ASCIIFY,
-
- /// Turns a number into a string and prints it.
- BC_INST_PRINT_STREAM,
-
/// Prints each item on the results stack, separated by newlines.
BC_INST_PRINT_STACK,
@@ -281,9 +284,6 @@ typedef enum BcInst {
/// results stack.
BC_INST_DUPLICATE,
- /// Swaps the top two items on the results stack.
- BC_INST_SWAP,
-
/// Copies the value in a register and pushes the copy onto the results
/// stack.
BC_INST_LOAD,
diff --git a/include/lex.h b/include/lex.h
index 60c86e6b..ca529b05 100644
--- a/include/lex.h
+++ b/include/lex.h
@@ -321,6 +321,9 @@ typedef enum BcLexType {
#endif // BC_ENABLE_EXTRA_MATH
+ /// bc asciffy keyword.
+ BC_LEX_KW_ASCIIFY,
+
/// bc modexp keyword.
BC_LEX_KW_MODEXP,
@@ -354,6 +357,9 @@ typedef enum BcLexType {
BC_LEX_KW_MAXRAND,
#endif // BC_ENABLE_EXTRA_MATH
+ /// bc stream keyword.
+ BC_LEX_KW_STREAM,
+
/// bc else keyword.
BC_LEX_KW_ELSE,
@@ -389,12 +395,6 @@ typedef enum BcLexType {
/// Pop (remove) command.
BC_LEX_POP,
- /// Asciify command.
- BC_LEX_ASCIIFY,
-
- /// Print stream command.
- BC_LEX_PRINT_STREAM,
-
/// Store ibase command.
BC_LEX_STORE_IBASE,
@@ -408,12 +408,25 @@ typedef enum BcLexType {
/// Store seed command.
BC_LEX_STORE_SEED,
#endif // BC_ENABLE_EXTRA_MATH
+
+ /// Load variable onto stack command.
BC_LEX_LOAD,
+
+ /// Pop off of variable stack onto results stack command.
BC_LEX_LOAD_POP,
+
+ /// Push onto variable stack command.
BC_LEX_STORE_PUSH,
+
+ /// Print with pop command.
BC_LEX_PRINT_POP,
+
+ /// Parameterized quit command.
BC_LEX_NQUIT,
+
+ /// Scale of number command.
BC_LEX_SCALE_FACTOR,
+
#endif // DC_ENABLED
} BcLexType;
diff --git a/include/program.h b/include/program.h
index ccfe6a1a..bbeb12c9 100644
--- a/include/program.h
+++ b/include/program.h
@@ -116,11 +116,11 @@ typedef struct BcProgram {
/// because of pushing more and more string executions on the stack.
BcVec tail_calls;
- /// A BcNum that has the proper base for asciify for dc.
- BcNum strmb;
-
#endif // DC_ENABLED
+ /// A BcNum that has the proper base for asciify.
+ BcNum strmb;
+
#if BC_ENABLED
/// The last printed value for bc.
@@ -128,15 +128,11 @@ typedef struct BcProgram {
#endif // BC_ENABLED
-#if DC_ENABLED
-
// The BcDig array for strmb. This uses BC_NUM_LONG_LOG10 because it is used
// in bc_num_ulong2num(), which attempts to realloc, unless it is big
// enough. This is big enough.
BcDig strmb_num[BC_NUM_BIGDIG_LOG10];
-#endif // DC_ENABLED
-
} BcProgram;
/**