Code Monkey home page Code Monkey logo

hledger-parser's Introduction

hledger-parser

Project Status NPM Version Release Conventional Commits LICENSE

hledger-parser logo

A parser for hledger journal files based on Chevrotain.

Grammar

🏗️ Parsing diagram

Installation

npm install hledger-parser

Usage

import { parseLedgerToCooked } from 'hledger-parser';

const parseResult = parseLedgerToCooked(sourceCode);

console.log(`Lexing errors: ${parseResult.lexErrors.length}`);
console.log(`Parsing errors: ${parseResult.parseErrors.length}`);
console.log('Result:', parseResult.cookedJournal);

// Output:
// => Lexing errors: 0
// => Parsing errors: 0
// => Result: {
// =>   transactions: [
// =>     {
// =>       date: [Object],
// =>       status: 'unmarked',
// =>       description: 'Transaction',
// =>       postings: [Array],
// =>       tags: []
// =>     }
// =>   ],
// =>   accounts: [],
// =>   prices: []
// => }

Contributors

Contributing

Contributions, issues and feature requests are welcome!
Feel free to check the issues page. You can also take a look at the contributing guide.

Project roadmap

Please see the roadmap for project status and a list of features to be implemented.

Note

This is a detached fork of the original hledger-parser, and is in active development. Special thanks goes out to @jonestristand for all the initial work he put into this project!

Show your support

Give a ⭐️ if this project helped you!

License

Copyright © 2022 Tristan Jones [email protected].
Copyright © 2024 Daryl G. Wright [email protected].
This project is MIT licensed.

hledger-parser's People

Contributors

darylwright avatar jonestristand avatar semantic-release-bot avatar

Stargazers

 avatar

Watchers

 avatar  avatar

hledger-parser's Issues

Timeclock format

Summary

Implement timeclock format as per the hledger spec.

All work on dates should be completed before starting work on this feature.

Needs #6, #12, #15, and #16.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

File imports

Originally submitted by @jonestristand

I'm submitting a ...

  • [ ] bug report
  • [ * ] feature request
  • [ ] question about the decisions made in the repository
  • [ ] question about how to use this project

Summary
Needs to respect include statements. My idea would be that the raw version of the ledger just indicates that there is an include statement in the syntax tree, while the cooked version would include all of the syntax tree from the included file attached at the node where the include statement is located. Any thoughts about alternatives?

Other information (e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Alias directive

Summary

Implement the alias directive as per the project roadmap documentation:

This feature enabled the use of account name aliases. This is an odd feature since it allows for
regular expressions, which in and of itself needs to be parsed with regular expressions. This is the
only tricky part of this feature. Otherwise, this can be implemented independently of any other feature.
Documentation

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Simple dates

I'm submitting a ...

  • [ ] bug report
  • [ * ] feature request
  • [ ] question about the decisions made in the repository
  • [ ] question about how to use this project

Summary

Implement simple date format as per project roadmap documentation.

Dates can be of the following formats:

  • YYYY-MM-DD
  • YYYY/MM/DD
  • YYYY.MM.DD

Leading zeroes are optional for month and day. The year can also be omitted for simple dates, with the current year inferred either by the system clock, or the Y directive.
Documentation

Other information

Note that the JournalDate type will have to be split into SimpleDate and SmartDate types. See #15 for information on smart dates.

Smart dates

Summary

Implement smart dates as per project roadmap documentation:

Smart dates use a complex set of syntax to add flexibility to date reporting in hledger. We need to
determine where smart dates are valid and only parse them in those cases. Otherwise, simple dates are
assumed. This means we need to split the current JournalDate type in hledger-parser into simple
and smart dates. Documentation

This issue requires completion of #12.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Payee directive

Summary

Implement the payee directive as per the hledger spec.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Periodic transactions

Summary

Implement periodic transactions as per the project roadmap documentation:

Periodic transactions use smart dates and period expressions. Those features need to be implemented
before work on this feature is started. Periodic transactions are used for budgeting and forecasting.

Documentation.
More documentation.

This issue requires completion of #16.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Date tags

I'm submitting a ...

  • [ ] bug report
  • [ * ] feature request
  • [ ] question about the decisions made in the repository
  • [ ] question about how to use this project

Summary

Implement the date: tag as per the project roadmap documentation:

The date tag needs to be handled differently from other regular tags. This is used for posting dates where an individual posting can have a different date than the parent transaction. The date: tag cannot be empty and must contain a simple date. Testing is required to determine whether the date: tag behaves the same outside of transaction postings or not.

This requires completion of #12 .

Other information

(e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Y directive

I'm submitting a ...

  • [ ] bug report
  • [ * ] feature request
  • [ ] question about the decisions made in the repository
  • [ ] question about how to use this project

Summary

Implement the Y (year) directive as per the project roadmap documentation:

This sets the default year in journals that use the short form of dates (month and day only).
Documentation

This issue requires completion of #12.

Other information

(e.g. detailed explanation, stack traces, related issues, suggestions how to fix, links for us to have context, eg. StackOverflow, personal fork, etc.)

Period expressions

Summary

Implement period expressions as described in the project roadmap documentation:

Period expressions use smart dates to create a new date type that denotes a range between two different
points of time. This also includes 'Q' syntax that denotes a quarter in a year (e.g. q4, 2009Q1). There
are also a range of period keywords used that are similar in function to those in smart dates. All of
these need to be implemented. Additionally, weekday and month names are part of some period expressions
and need to be accounted for as well.
Documentation

This issue requires completion of #15.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Implement price directive inline comments

Summary

Currently, hledger-parser doesn't support inline comments on the same line as the price directive. This must be implemented in the parser and CST visitors.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Timedot format

Summary

Implement timedot format as per hledger spec. Requires completion of #18.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Tag directive

Summary

Implement the tag directive as per the hledger spec.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Auto posting directive

Summary

Implement the auto posting directive as per the hledger spec.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Refactor lexer tests to expose test function

Summary

Use the example herehere to refactor the lexer tests so that the test function is exposed in those suites. This allows the IDE to detect tests for better integration and runnability. Also determine if Ava has native support for repeating tests on different data.

Other Information

No response

Code of Conduct

  • I agree to follow this project's Code of Conduct

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.