Implement C++ pretty-printer

This commit is contained in:
2021-09-08 01:32:08 -04:00
parent 67b309a0b7
commit bac1a7b876
9 changed files with 322 additions and 454 deletions

View File

@@ -20,6 +20,15 @@ void luai_writestring(const char *s, size_t len);
void luai_writeline();
}
// Output a simple value to a stream.
//
// If the value is a string, number, boolean, or nil, it is
// quoted and output to the stream, and this function returns
// true. Otherwise, this function returns false and nothing
// is sent to the stream.
//
bool string_quote(LuaStack &LS, LuaSlot val, std::ostream *os);
// Pretty print to a stream.
//
// If indent is >=0, the output is indented. If indent<0, then
@@ -32,15 +41,15 @@ void pprint(LuaStack &LS, LuaSlot val, int indent, int maxlen, std::ostream *os)
// The following lua interfaces to this code are included:
//
// pprint(expr)
// pprint(expr, expr, expr...)
//
// - pretty print the specified expression to stdout.
//
// string.pprint(expr, indent, maxlen)
// string.pprint(expr, indent)
//
// - pretty print the specified expression, return the result as a string.
//
void pprint_pprint(lua_State *L);
void string_pprint(lua_State *L);
int lfn_pprint_pprint(lua_State *L);
int lfn_string_pprint(lua_State *L);
#endif // PRINT_HPP