Commit graph

80 commits

Author SHA1 Message Date
John Wiegley
b17b6cd9d4 Fixed parameter and argument scoping for O_CALL nodes 2012-03-07 05:38:13 -06:00
John Wiegley
65835a89cc Dump IDENT referral values in op_t::dump 2012-03-07 05:21:40 -06:00
John Wiegley
71d0033b6f Corrected several compile and link problems 2012-03-06 23:04:27 -06:00
John Wiegley
acb5e1beea Generalized function call parsing
Directly calling a lambda now works:

  (x -> x + 10)(10) => 20
2012-03-05 22:01:41 -06:00
John Wiegley
fa3805282a Added an assert 2012-03-05 05:53:41 -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
cfd7ffb126 Provide more context if a valexpr function call fails 2012-03-01 22:20:38 -06:00
John Wiegley
e2afc783db Increased file copyrights to 2012 2012-02-29 22:32:23 -06:00
John Wiegley
c47350dce9 Corrected handling of nested definitions 2012-02-21 03:53:00 -06:00
John Wiegley
1837e32391 The new SCOPE mechanism is working 2012-02-21 01:45:26 -06:00
John Wiegley
bc9ff7095f Introduced a new SCOPE expression terminal 2012-02-20 17:20:22 -06:00
John Wiegley
5e3e204766 Do not evaluate strings as booleans 2012-02-11 16:53:31 -10:00
John Wiegley
f0791bbd72 Cleanup whitespace 2011-08-18 14:48:38 -04:00
John Wiegley
c4a3a7bbe5 Changed an assert into a proper exception 2011-07-17 15:28:11 -05:00
John Wiegley
976ba4907d O_DEFINE operator should always return NULL_VALUE 2011-07-17 15:28:02 -05:00
John Wiegley
20f4ccde96 Added some debug code 2011-02-10 23:00:36 -05:00
John Wiegley
84780270f9 Added initial support for lambda functions 2010-09-06 00:56:00 -04:00
John Wiegley
e162455ebb Minor simplifications to valexpr parser
The most significant change is the way CONS sequences are parsed, and
that now instead of =/:=, the operators are ==/=.
2010-09-05 01:38:47 -04:00
John Wiegley
011bf030a2 Generalized the semantics of FOO.BAR in valexprs
Previously, FOO was evaluated to return a scope, and BAR was an
identifier looked up in that scope.  However, this prevented scope-local
functions from being called (since that is a CALL, not a plain IDENT).

Now the meaning of the "." operator is that it evaluates the left
operand in a scope type context, pushes that scope as the current object
context, and then evaluates BAR in that context.

Thus the bare word "amount" in an account context calls the same
function that "account.amount" would if evaluated in a posting context.
2010-06-24 20:37:12 -04:00
John Wiegley
024fb4f3e0 Fixed how valexpr function defs and calls work 2010-06-24 20:22:11 -04:00
John Wiegley
968a6f3c0a Changes for building with Visual Studio 2008 2010-06-15 05:14:00 -04:00
John Wiegley
2ea075dc4f Report error context in expressions more precisely 2010-06-13 18:39:26 -04:00
John Wiegley
ea1642b3f9 Completely reworked argument passing in expressions 2010-06-13 05:02:14 -04:00
John Wiegley
dcdd9c4a56 If a type context exists, confirm the result matches 2010-06-13 01:03:49 -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
b848ace768 Allow opt -NDEBUG build to complete without warnings 2010-06-04 06:02:00 -04:00
John Wiegley
d5f8c3bc57 Added O_EXPAND operator, to handle macros 2010-05-08 02:02:10 -04:00
John Wiegley
ab416f759f Updated copyrights to 2003-2010 2010-03-05 22:14:10 -05:00
John Wiegley
4e30fcdf40 Many improvements to Ledger's Python bindings 2009-11-19 22:24:24 -05:00
John Wiegley
bf24b93818 Fixes to the value expression parser and evaluator 2009-11-10 02:26:20 -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
7ca80112fc Change the value_t::POINTER type to value_t::SCOPE
scope_t pointers are the only kind that are ever stored in value
objects, so there was no need to make it generic and use boost::any.
2009-10-30 17:57:29 -04:00
John Wiegley
5ddb0e9bfb Output pointer values correctly for 64-bit systems 2009-10-27 04:00:35 -04:00
John Wiegley
9b13e77ff5 Improved debug output of "--debug expr.calc" 2009-10-25 05:01:47 -04:00
John Wiegley
991e3a3eaf Split commodity.h/cc into three files
commodity.h - code for commodity_t
annotate.h  - commodity annotations
pool.h      - commodity pool management
2009-06-24 16:43:46 +01:00
John Wiegley
521b935aa8 Restored --percent option, added baseline test 2009-06-21 18:07:27 +01:00
John Wiegley
110f0b8023 Enabled use of pre-compiled headers by default 2009-03-10 17:02:03 -04:00
John Wiegley
c11d325712 Reduced the #include dependency tree to a minimum 2009-03-04 23:53:43 -04:00
John Wiegley
e2c30cf6e4 Added ; as a sequencing operator in valexprs 2009-03-03 16:05:04 -04:00
John Wiegley
098e3b0043 Fixed parsing of '(1, 2, (3, 4))' 2009-03-03 16:02:34 -04:00
John Wiegley
19cfd9e23b Fixed the printing of O_CONS nodes 2009-02-28 06:13:49 -04:00
John Wiegley
0efe0c63ce Corrected output of O_CALL nodes 2009-02-27 14:06:52 -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
e919f53c99 Renamed O_COMMA to O_CONS, and changed semantics
In the old scheme, nested values would simply flatten and concatenate,
so that '((1, 2), 3) = (1, 2, 3)'.  Now sublists are preserved, so that
sequences may be passed as arguments to functions.
2009-02-23 15:04:07 -04:00
John Wiegley
fc349389e3 Restored the --budget option 2009-02-20 23:12:23 -04:00
John Wiegley
6f7f87699c Parse '/' in an operator context as "div" 2009-02-15 16:34:34 -04:00
John Wiegley
94aa8e5a91 Changed debug category op.calc to expr.calc 2009-02-15 15:42:12 -04:00
John Wiegley
b53f844129 Removed an excessive error check. 2009-02-12 02:34:54 -04:00
John Wiegley
e777abe854 Revert "If a valexpr identifier is unknown at calc time, re-compile at that point."
This reverts commit 4a463aca3b.
2009-02-09 00:29:51 -04:00