2 Package com
.interrupt
.bookkeeping
.cc
;
9 lowercase
= ['a' .. 'z'];
10 uppercase
= ['A' .. 'Z'];
12 hex_digit
= [ digit
+ [['a' .. 'f'] + ['A' .. 'F']] ];
17 eol
= cr lf
| cr
| lf
; // This takes care of different platforms
31 lsquare_bracket
= '[';
32 rsquare_bracket
= ']';
38 ws
= (' ' | tab
| eol
);
43 bkeeping
, freetext
; // we need a way to ignore commands in freetext
50 {bkeeping
} var
= 'var';
54 {bkeeping
} create
= 'create';
55 {bkeeping
} add
= 'add';
56 {bkeeping
} update
= 'update';
57 {bkeeping
} remove
= 'remove';
58 {bkeeping
} reverse
= 'reverse';
59 {bkeeping
} find
= 'find';
60 {bkeeping
} list
= 'list';
62 {bkeeping
} print
= 'print';
63 {bkeeping
} commit
= 'commit';
65 {bkeeping
} load
= 'load';
66 {bkeeping
} login
= 'login';
67 {bkeeping
} logout
= 'logout';
68 {bkeeping
} exit
= 'exit';
70 {bkeeping
} semicolon
= ( 59 )?;
72 whitespace
= (' ' | tab
| eol
);
73 comment_line
= forwardslash forwardslash all
* eol
;
74 comment_block
= forwardslash asterix all
* asterix forwardslash
;
78 entry_opt
= '-entry' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
79 entryid_opt
= '-entryid' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
80 account_opt
= '-account' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
81 accountid_opt
= '-accountid' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
82 journal_opt
= '-journal' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
83 name_opt
= '-name' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
84 type_opt
= '-type' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
85 counterweight_opt
= '-counterWeight' ws
+ lowercase
+;
86 amount_opt
= '-amount' ws
+ digit
+'.'digit
+;
87 id_opt
= '-id' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
88 entrynum_opt
= '-entrynum' ws
+ digit
*;
89 date_opt
= '-date' ws
+ digit
+'/'digit
+'/'digit
+;
90 file_opt
= '-F' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
92 group_opt
= '-group' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
93 uname_opt
= '-username' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
94 passwd_opt
= '-password' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
95 groupid_opt
= '-groupid' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
96 userid_opt
= '-userid' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
97 currency_opt
= '-currency' ws
+ ( lowercase
| uppercase
| dash
| colon_helper
| ats
| underscore
| digit
| dot
)*;
102 system_tok
= 'system';
104 credit_tok
= 'credit';
106 entries_tok
= 'entries';
107 journal_tok
= 'journal';
108 journals_tok
= 'journals';
109 transaction_tok
= 'transaction';
110 account_tok
= 'account';
111 accounts_tok
= 'accounts';
116 groups_tok
= 'groups';
118 allowedactions_tok
= 'allowedActions';
119 command_tok
= 'command';
120 profiledetails_tok
= 'profileDetails';
121 profiledetail_tok
= 'profileDetail';
122 usersession_tok
= 'userSession';
132 doubledash
= dash dash
;
135 lbracket
= left_bracket
;
136 rbracket
= right_bracket
;
137 //lsbracket = lsquare_bracket;
138 //rsbracket = rsquare_bracket;
140 equals
= equals_helper
;
141 fslash
= forwardslash
;
143 colon
= colon_helper
;
145 {bkeeping
-> freetext
, freetext
-> bkeeping
} quote
= ( double_quote
| single_quote
);
146 {bkeeping
-> freetext
, freetext
-> bkeeping
} backquote
= '`';
148 word
= ( lowercase
| uppercase
| dash
| underscore
| digit
| dot
)+;
150 //xpath_chars = ( ats | forwardslash | colon_helper | left_bracket | right_bracket | lsquare_bracket | rsquare_bracket | equals_helper | double_quote | single_quote );
151 xpath_chars
= ( colon_helper
| left_bracket
| right_bracket
| lsquare_bracket
| rsquare_bracket
);
156 decl_dtd
= 'DOCTYPE';
157 eoll
= (cr
| lf
| cr lf
)?;
170 expr
= {cmd
} command semicolon
|
171 {thexpr
} twohandexpr semicolon
;
173 /***************************
180 twohandexpr
= var word equals command
; // assigning results to variables
181 varname
= atsign word
?; // put an '@' sign in front of variable name to reference it
184 /***************************
187 * add ((token.literal) token.literal, ...)
188 * update ((token.literal) token.literal, ...)
189 * remove ((token.literal) token.literal, ...)
191 * reverse ((token.literal) (token.literal) token.literal)
194 * find ((token.literal) token -opts)
195 * list ((token.literal) token -opts)
197 * create (token -opts)
199 * load (token -opts) <-- DB
200 * commit (token.literal) <-- DB
202 * print (token.literal)
204 * login (token -opts) <-- DB
209 command
= {c1
} command1
|
218 command1
= {add
} add
[lbdepth1
]:lbracket
[lbdepth2
]:lbracket command_input
[rbdepth2
]:rbracket ilist
* [rbdepth1
]:rbracket
|
219 {update
} update
[lbdepth1
]:lbracket
[lbdepth2
]:lbracket
[c1
]:command_input
[rbdepth2
]:rbracket
[c2
]:command_input
[rbdepth1
]:rbracket
|
220 {remove
} remove
[lbdepth1
]:lbracket
[lbdepth2
]:lbracket command_input
[rbdepth2
]:rbracket ilist
* [rbdepth1
]:rbracket
;
222 command5
= {reverse
} reverse
[lbdepth1
]:lbracket
[lbdepth2
]:lbracket
[ci1
]:command_input
[rbdepth2
]:rbracket
[lbdepth3
]:lbracket
[ci2
]:command_input
[rbdepth3
]:rbracket
[ci3
]:command_input
[rbdepth1
]:rbracket
;
224 //** input list & delimiter
225 ilist
= command_input ilistpart
*;
226 ilistpart
= listdelimiter command_input
;
229 command2
= {find
} find
[lbdepth1
]:lbracket
[lbdepth2
]:lbracket
[c1
]:command_input
[rbdepth2
]:rbracket
[c2
]:command_input
[rbdepth1
]:rbracket
|
230 {list
} list
[lbdepth1
]:lbracket
[lbdepth2
]:lbracket
[c1
]:command_input
[rbdepth2
]:rbracket
[c2
]:command_input
[rbdepth1
]:rbracket
;
232 command3
= {load
} load lbracket command_input rbracket
|
233 {create
} create lbracket command_input rbracket
|
234 {login
} login lbracket command_input rbracket
;
236 command4
= {logout
} logout
|
239 command6
= {print
} print lbracket command_input rbracket
;
241 command7
= {commit
} commit
[lbdepth1
]:lbracket
[lbdepth2
]:lbracket
[input1
]:command_input
[rbdepth2
]:rbracket
[input2
]:command_input
[rbdepth1
]:rbracket
;
245 /**************************
248 command_input
= {var
} varname
|
250 {opts
} input_option
|
256 input_option
= commandtoken commandoption
*;
259 xpath
= [left
]:backquote xpath_part
* [right
]:backquote
;
260 xpath_part
= {wd
} wordetal
|
269 /***************************
272 commandoption
= {entry
} entry_opt
|
273 {entryid
} entryid_opt
|
274 {account
} account_opt
|
275 {accountid
} accountid_opt
|
276 {journal
} journal_opt
|
279 {cweight
} counterweight_opt
|
280 {amount
} amount_opt
|
282 {entrynum
} entrynum_opt
|
287 {passwd
} passwd_opt
|
288 {groupid
} groupid_opt
|
289 {userid
} userid_opt
|
290 {currency
} currency_opt
;
294 /***************************
297 xmlblock
= xml_decl
? fulltag
;
299 fulltag
= {fulltag
} opentag fulltag
* wordetal
* closetag
|
300 {emptytag
} emptytag
|
301 {comment
} xmlcomment
;
303 opentag
= lparen nsprefix
? wordetal attribute
* rparen
;
304 emptytag
= lparen nsprefix
? wordetal attribute
* fslash rparen
;
305 closetag
= lparen fslash nsprefix
? wordetal rparen
;
309 xml_decl
= {xml_schem
} xml_decl_schem
|
310 {xml_dtd
} xml_decl_dtd
;
312 // <?xml version="1.0" encoding="iso8859-1" ?>
313 xml_decl_schem
= lparen
[left
]:question wordetal attribute
+ [right
]:question rparen
;
315 // <!DOCTYPE greeting SYSTEM "hello.dtd" >
316 xml_decl_dtd
= lparen exclamation word_dtd
+ rparen
;
317 word_dtd
= {attrhs
} attributerhs
|
321 attribute
= nsprefix
? attributelhs equals attributerhs
;
322 attributelhs
= wordetal
;
323 attributerhs
= [left
]:quote zzz
* [right
]:quote
;
325 nsprefix
= wordetal colon
;
327 xmlcomment
= xml_opencomment wordetal
* xml_closecomment
;
329 xml_opencomment
= lparen exclamation doubledash
;
330 xml_closecomment
= doubledash rparen
;
333 zzz
= {one
} wordetal
|
336 wordetal
= {word
} word
|
337 {ctoken
} commandtoken
;
341 /***************************
344 commandtoken
= {system
} system_tok
|
346 {credit
} credit_tok
|
348 {entries
} entries_tok
|
349 {journal
} journal_tok
|
350 {journals
} journals_tok
|
351 {transaction
} transaction_tok
|
352 {accounts
} accounts_tok
|
353 {account
} account_tok
|
357 {groups
} groups_tok
|
358 {allowedactions
} allowedactions_tok
|
359 {command
} command_tok
|
360 {profiledetails
} profiledetails_tok
|
361 {profiledetail
} profiledetail_tok
|
362 {usersession
} usersession_tok
;
368 // 7. include CDATA blocks
369 // <a> <![CDATA[ do something ]]> </a>
380 // <xml> lorem ipsum some text </xml>
381 // <xml attr1="" attr2="wert" />
382 // <xml attr1="" attr2="wert" > </xml>
385 // <xml:xml></xml:xml>
387 // <xml:xml attr1="" attr2="wert" />
388 // <xml:xml attr1="" attr2="wert" ></xml:xml>
390 // <xml:xml attr1="" attr2="wert" > <a> <b/> </a> lorem ipsum some text </xml:xml>
391 // <xml:xml attr1="" attr2="wert" > <a> <!-- this is comments --> <b/> </a> lorem ipsum some text </xml:xml>
392 // <xml:xml pre:attr1="" pref:attr2="wert" > <a> <!-- this is comments --> <b/> </a> lorem ipsum some text </xml:xml>
394 // <?xml version="1.0" encoding="iso8859-1" ?> <xml:xml attr1="" attr2="wert" > <a> <!-- this is comments --> <b/> </a> lorem ipsum some text </xml:xml>
395 // <!DOCTYPE greeting SYSTEM "hello.dtd" > <xml:xml attr1="" attr2="wert" > <a> <!-- this is comments --> <b/> </a> lorem ipsum some text </xml:xml>
397 // <debit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' entryid='e1' accountid='2' />
398 // <?xml version="1.0" encoding="iso8859-1" ?><credit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' entryid='e1' accountid='2' />
400 // <account xmlns='com/interrupt/bookkeeping/account' id='1' name='office equipment' type='asset' counterWeight='debit' ><debit xmlns='com/interrupt/bookkeeping/account' id='' amount='10.00' entryid='' accountid='1' /></account>
407 // <lebit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' entryid='e1' accountid='2' />
408 // <lebit xmlns='comaccount' id='def' amount='1.50' entryid='e1' accountid='2' />
409 // <debit xmlns='comaccount' id='def' amount='1.50' entryid='e1' accountid='2' />
410 // <xml:xml attr1="com/interrupt/bookkeeping/account" attr2="wert" > <a> <b/> </a> lorem ipsum some text </xml:xml>
411 // <xml attr1="com/interrupt/bookkeeping/account" attr2="wert" > <a> <b/> </a> lorem ipsum some text </xml>
412 // <xml attr1="com/interrupt/bookkeeping/account" attr2="wert" > <a> <b/> </a> </xml>
414 // <xml attr1="comaccount" attr2="wert" > <a> <b/> </a> </xml>
415 // <xml attr1="comaccount" attr2="wert" > <a> <b/> </a> lorem ipsum </xml>
416 // <xml attr1="com/interrupt/bookkeeping/account" attr2="wert" > <a> <b/> </a> lorem ipsum </xml>
418 // <debit attr1="com/interrupt/bookkeeping/account" attr2="wert" > <a> <b/> </a> </debit>
419 // <debit attr1="com/interrupt/bookkeeping/account" attr2="wert" > </debit>
428 // -type type -name some
429 // -type type -name some -id qerfb1435c -date 06/24/2003
431 //[X] -account "account name"
432 //[X] -journal journal name -entry journal
434 // -counterWeight debit
442 // login ( user -username root -password password );
443 // load ( users -id aauth.users );
446 //** create ( debit -id erfg -amount 123.33 );
447 // create ( <debit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' /> );
450 // load ( users -id aauth.users );
451 // load ( debit -amount 10.00 );
452 // load ( debit -id abc -amount 10.00 );
453 // load ( <debit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' /> );
456 //** add ((create ( entry -id ez ) ) create ( debit -id dbzz -amount 10.00 ) );
457 // add ((create ( entry -id ez ) ) load ( debit -id abc -amount 10.00 ) );
459 // add ((create ( entry -id ez -currency CDN ) ) create ( <debit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' currency='CDN' /> ) );
462 // remove ( (load ( entry -id e1 )) );
463 // remove ( (load ( entry -id e1 )) load ( debit -id abc -amount 10.00 ) );
467 <entries xmlns='com/interrupt/bookkeeping/journal' id='' >
468 <entry xmlns='com/interrupt/bookkeeping/journal' id='e1' entrynum='' state='closed' journalid='' date='' >
469 <debit xmlns='com/interrupt/bookkeeping/account' id='abc' amount='10.00' entryid='e1' accountid='1' />
470 <debit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' entryid='e1' accountid='2' />
471 <credit xmlns='com/interrupt/bookkeeping/account' id='ghi' amount='11.50' entryid='e1' accountid='3' />
476 <entry xmlns='com/interrupt/bookkeeping/journal' id='e1' entrynum='' state='closed' journalid='' date='' >
477 <debit xmlns='com/interrupt/bookkeeping/account' id='abc' amount='10.00' entryid='e1' accountid='1' />
478 <debit xmlns='com/interrupt/bookkeeping/account' id='def' amount='1.50' entryid='e1' accountid='2' />
479 <credit xmlns='com/interrupt/bookkeeping/account' id='ghi' amount='11.50' entryid='e1' accountid='3' />
482 <entry xmlns='com/interrupt/bookkeeping/journal' id='ereverse' entrynum='' state='closed' journalid='' date='' >
483 <debit xmlns='com/interrupt/bookkeeping/account' id='reverseabc' amount='11.50' entryid='ereverse' accountid='1' />
484 <credit xmlns='com/interrupt/bookkeeping/account' id='reverseghi' amount='11.50' entryid='ereverse' accountid='3' />
488 // reverse ( (entries -id es1) (entry -id e1) <entry xmlns='com/interrupt/bookkeeping/journal' id='newid' state='closed' > </entry> );
491 // find ( (load ( account -id 2 )) load ( debit -amount 1.50 ) );
494 // list ( (load ( entry -id e1 )) load ( debit -entryid e1) );
495 //** list ( (load ( entry -id e1 )) <debit xmlns='com/interrupt/bookkeeping/account' / > );
496 // list ( (load ( entry -id e1 )) <debit xmlns='com/interrupt/bookkeeping/account' entryid='e1' / > );
501 // var timmy = list ( (load ( entry -id e1 )) <debit xmlns='com/interrupt/bookkeeping/account' / > );
502 // find ( (load ( entry -id e1 )) @timmy );
509 add ( (load ( entries -id es1 ))
511 (create ( entry -id e2 ))
512 create (debit -id nsfada -entryid e2 -amount 52.30 -accountid 1 ),
513 create (credit -id efiafd -entryid e2 -amount 52.30 -accountid 3 )
518 // add ( ( create (entries) ) create ( entry ) );
519 // add ( ( create (entries) ) create ( entry ), create ( entry ) );
524 (create ( entry -id e2 ))
525 create (debit -id nsfada -entryid e2 -amount 52.30 -accountid 1 ),
526 create (credit -id efiafd -entryid e2 -amount 52.30 -accountid 3 )
529 // var result = add ( (load ( entries -id es1 )) @tim );
530 // commit ( @result );
536 // * Tokens cannot use other tokens
538 // [OK] multiple attributes
539 // [OK] include 2 tokens in a production rule
541 // [OK] include xml comments
544 // [OK] include namespace declarations; namespace usage in tags and attributes
545 // xmlns='' xmlns:ans='' <ans:tagname att='' />
547 // [OK] text in open/close tags
554 // [OK] include document declaration ( DTD & schema )
555 // <?xml version="1.0" encoding="iso8859-1" **allow any and all characters between** ?>
556 // <!DOCTYPE greeting SYSTEM "hello.dtd" **allow any and all characters between** >
558 // [OK] implement token & options (this will also be the short form of inputs )