Commit graph

66 commits

Author SHA1 Message Date
John Wiegley
0951bcebef Bump copyright information to 2013 2013-02-18 06:51:21 -06:00
John Wiegley
4681e58d7f Converted the Ledger build system to use CMake 2012-05-20 04:48:05 -05:00
John Wiegley
08f65eeadc Allow serialization to be enabled again 2012-03-29 15:35:20 -05:00
John Wiegley
22505d9527 Always call TRACE_CTOR at the end of constructors 2012-03-20 02:10:40 -05:00
John Wiegley
f9088f8836 Added --verify-memory and missing TRACE_[CD]TOR calls 2012-03-18 01:01:30 -05:00
John Wiegley
a9c387377b Made join_args() a global function 2012-03-13 10:34:16 -05:00
John Wiegley
234348f7fa Fixed a bug that was breaking optimized builds 2012-03-11 04:30:08 -05:00
John Wiegley
7e250696e0 Many options now have additive effect
For example, -A and -V used to override each other, whereas now:

  -A    report the average amount
  -V    report all amounts at current value
  -AV   report the current value of the average
  -VA   report the average of all current values
2012-03-07 12:46:46 -06:00
John Wiegley
28b3453f50 Added a DEBUG statement 2012-03-07 11:31:08 -06:00
John Wiegley
f525dabf39 Removed unnecessary method definition 2012-03-07 11:31:02 -06:00
John Wiegley
2b108c66cc Added an empty_scope_t utility class 2012-03-07 05:16:34 -06:00
John Wiegley
c86bbd4547 Whitespace fixes 2012-03-07 03:38:09 -06:00
John Wiegley
488355e5d9 Added symbol_t::operator==() 2012-03-06 04:13:54 -06:00
John Wiegley
4a93a8313e Whitespace fix 2012-03-06 04:13:46 -06:00
John Wiegley
c8c2a17e28 Fixed invocation of lambda expressions
foo = x, y, z -> print(x, y, z)
  foo(1, 2, 3)

However, this still does not work:

  (x, y, z -> print(x, y, z))(1, 2, 3)
2012-03-05 05:03:51 -06:00
John Wiegley
4e37748999 Re-enabled some necessary code 2012-03-01 22:09:42 -06:00
John Wiegley
944e580825 Refactored the notion of "the current parsing context" 2012-03-01 03:31:28 -06:00
John Wiegley
e2afc783db Increased file copyrights to 2012 2012-02-29 22:32:23 -06:00
John Wiegley
822919984e Comment out unneeded code 2012-02-27 03:55:20 -06:00
John Wiegley
1837e32391 The new SCOPE mechanism is working 2012-02-21 01:45:26 -06:00
John Wiegley
ed6df84473 Fixes for variable shadowing (24/28) 2012-02-17 15:06:26 -06:00
John Wiegley
f0791bbd72 Cleanup whitespace 2011-08-18 14:48:38 -04:00
John Wiegley
20f4ccde96 Added some debug code 2011-02-10 23:00:36 -05:00
John Wiegley
2f50e30b89 Scopes can now provide a description of themselves
This isn't being used yet, but it likely will to improve the information
presented to users if their value expressions fail to compile or
evaluate.
2010-06-24 19:53:59 -04:00
John Wiegley
bc51cd4651 Value scopes now take a parent scope for chaining 2010-06-24 19:40:16 -04:00
John Wiegley
a961f15f00 Fixed bug that had broken any() and all() 2010-06-18 07:27:53 -04:00
John Wiegley
2ea075dc4f Report error context in expressions more precisely 2010-06-13 18:39:26 -04:00
John Wiegley
2dec00a882 Fixes to scope.h for the sake of Boost.Serialization 2010-06-13 05:31:39 -04:00
John Wiegley
ea1642b3f9 Completely reworked argument passing in expressions 2010-06-13 05:02:14 -04:00
John Wiegley
1bc5b894df Expression evaluations now have a "type context"
Thus, an expression can know if the context in which it's being
evaluated requires a string, and if so, determine it's output
accordingly.  For example:

  account       ; returns the full name of the posting's account
  account.total ; here the context is SCOPE, so account is an obj
2010-06-13 01:03:48 -04:00
John Wiegley
dea2aed0b5 Untabified all source files 2010-06-11 17:02:25 -04:00
John Wiegley
4d372a8e1e Added value_scope_t, for wrapping a value in a scope
The value expression "value" may be used to extract the wrapped value.
This is currently only used by the upcoming --group-title-format option.
2010-05-30 02:38:32 -06:00
John Wiegley
04cfa7ab71 Added more iterator methods to call_scope_t 2010-05-08 02:24:36 -04:00
John Wiegley
ab416f759f Updated copyrights to 2003-2010 2010-03-05 22:14:10 -05:00
John Wiegley
11a217a481 Very minor but easy optimization for symbol_scope_t
Lots of symbol_scope_t throwaway objects get created during value
expression calculation, and 99% of them are never used.  Therefore, the
std::map which each contains is now within an optional<> wrapper, so
that no constructor happens unless one is actually used.
2009-11-24 04:14:34 -05:00
John Wiegley
fb8be53edb Redesigned the format_t class 2009-11-09 02:06:08 -05:00
John Wiegley
394c7bd8df Removed a bunch of empty comments 2009-11-08 14:59:11 -05:00
John Wiegley
34ee358f5e Moved journal reading code into journal_t 2009-11-05 02:27:42 -05:00
John Wiegley
78e6770c4c Segregated symbols into 5 separate namespaces
The different namespaces are:

  Function      Value expression functions, which receive a "context"
  Option        Command-line options
  Precommand    Commands which are invoked before reading the journal
  Command       Commands which are invoked after reading the journal
  Directive     Directives that occur at column 0 in a data file

This greatly eases the ability for Python uses to add intercept hooks to
change how the basic Ledger module functions.  An example of what should
be possible soon:

  import ledger

  def my_foo_handler(value):
      print "--foo received:", value

  ledger.add_handler(ledger.Option, "foo=", my_foo_handler)
2009-11-04 20:40:48 -05:00
John Wiegley
4a14f3224b Added value_t::push_front 2009-11-04 20:40:45 -05:00
John Wiegley
b14c814fec Whitespace fix 2009-11-04 20:40:42 -05:00
John Wiegley
de3893a08a Added missing TRACE_CTOR calls 2009-11-01 06:01:11 -05:00
John Wiegley
a757b19f51 Added serialization methods for most type
This allows journal_t objects to be completed serialized to disk and
deserialized.
2009-10-30 18:06:37 -04:00
John Wiegley
c11d325712 Reduced the #include dependency tree to a minimum 2009-03-04 23:53:43 -04:00
John Wiegley
238bd7f8a5 Marked all strings needing internationalization
These strings are now collected automagically in the file po/ledger.pot.
If you'd like to produce a translation, just run this command after
building Ledger:

    msginit -l LOCALE -o LANG.po -i po/ledger.pot

Where LOCALE is a string like de or en_GB, and LANG is a short
descriptive word for your language.

Then send me this .po file so I can commit it to the Ledger sources
(alternatively, you could maintain the file in a fork on GitHub), and
setup the build script to format and install your new message catalog
during a "make install".
2009-02-25 03:51:42 -04:00
John Wiegley
6d880c2728 Removed some dead code 2009-02-24 20:25:49 -04:00
John Wiegley
1f39d4148e Create a new interactive_t helper class
The purpose of this class is much like Emacs' (interactive) form: it
allows a value expression function to declare exactly how many
arguments, and of what type, it intends to receive.  It then offers
type-safe access to theese arguments in a consistent manner.

An example value expression function definition in C++:

    value_t fn_foo(call_scope_t& scope) {
      // We expect a string, an integer, and an optional date
      interactive_t args(scope, "sl&d");

      std::cout << "String  = " << args.get<string>(0)
                << "Integer = " << args.get<long>(1) << std::endl;

      if (args.has(2)) // was a date provided?
        std::cout << "Date    = " << args.get<date_t>(2) << std::endl;

      return NULL_VALUE;
    }

There is also an in_context_t<T> template, which finds the context type
T in the current scope hierarchy.  The in_context_t then also acts as a
smart pointer to reference this context object, in addition to serving
the same duty as interactive_t.  This combination of intent is solely
for the sake of brevity.

    value_t fn_bar(call_scope_t& scope) {
      in_context_t<account_t> env(scope, "sl&d");
      std::cout << "Account name = " << env->fullname()
                << "String arg   = " << env.get<string>(0)
                << std::endl;
      return NULL_VALUE;
    }

As you can see here, 'env' acts as a smart pointer to the required
context, and an object to extract the typed arguments.
2009-02-21 18:49:43 -04:00
John Wiegley
4ec2dfeef1 Added --flat option, to flatten the balance report 2009-02-17 21:19:31 -04:00
John Wiegley
d0a664d102 Fixed several unused value and param warnings 2009-02-16 16:55:18 -04:00
John Wiegley
4365d9e3fc Moved around some functions for clarity 2009-02-16 04:10:22 -04:00