Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fixes, improvements, optimization & refactoring before parser generation #288

Merged

Commits on Dec 5, 2022

  1. Fix bad float conformation error message + add coverage

    Peter Dolak authored and petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    5fa25c2 View commit details
    Browse the repository at this point in the history
  2. Remove duplicit information from int/float conversion errors

    Both strconv.ParseInt and strconv.ParseFloat already report the input.
    The word invalid isn't always true - it could also just be out of range.
    The type is contained within the Parse* function being called. So as the
    extra context added nothing useful, I decided to remove it altogether,
    making things much easier for the generated parser.
    petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    2795a9d View commit details
    Browse the repository at this point in the history
  3. Fix possible panic when optional groups are used within a capture

    If an optional group within a capture matches no input (either because
    of an unexpected token or EOF), obtaining partial AST can cause
    `setField` to be called with no tokens, causing a panic. Fixed by not
    doing anything.
    petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    ad1557e View commit details
    Browse the repository at this point in the history
  4. Improve mismatch error message for negation & negative lookahead group

    It didn't properly escape the token, the error would be malformed if the
    token contained single quotes. It also used a custom error instead of
    `UnexpectedTokenError` for no good reason.
    petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    5e400b6 View commit details
    Browse the repository at this point in the history
  5. Improve the choice of error reporting after optional branches

    The last error in the added test explains the difference. Without this
    change, it would have been `1:15: unexpected token "(" (expected ";")`,
    which would be very confusing as '(' was actually allowed after the
    class name.
    
    After this change, it's `1:20: unexpected token ")" (expected <ident>)`,
    pointing out the real problem - that an identifier was expected after
    the comma.
    petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    3de599c View commit details
    Browse the repository at this point in the history
  6. Optimize string field accumulation to do fewer allocations

    Peter Dolak authored and petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    d03a0d2 View commit details
    Browse the repository at this point in the history
  7. Optimize finding case insensitive tokens to be done at parser constru…

    …ction
    
    Optimize finding case insensitive tokens to be done at parser construction
    
    Doing it before each parsing was unnecessary. One could worry the
    results would be different if `ParseFromLexer` was called with a
    different lexer than used to build the grammar, but then case-insentive
    tokens would be the least of our problems - literal & reference would
    check agaist the wrong TokenType.
    Peter Dolak authored and petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    b36c8c7 View commit details
    Browse the repository at this point in the history
  8. Avoid an allocation in newParseContext

    Not very significant for the reflective parser, more significant for the
    generated one.
    petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    bb4e748 View commit details
    Browse the repository at this point in the history
  9. Include explicit disjunction in the union node

    The generated parser would be the second place that would construct a
    temporary disjunction in the implementation, I think it might as well
    contain the disjunction directly.
    petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    bf35800 View commit details
    Browse the repository at this point in the history
  10. Remove unused optional and repetition grammar nodes

    They could never be created and were private, so this certainly can't
    break anything.
    Peter Dolak authored and petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    9aefebf View commit details
    Browse the repository at this point in the history
  11. Change the receiver name of lookaheadGroup from n to l

    It was n probably because I copied it from negation and assumed n was
    for node. Naming it l is more consistent with the convention for other
    nodes.
    petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    8854a6d View commit details
    Browse the repository at this point in the history
  12. Keep track of the number of usages of a strct node

    Peter Dolak authored and petee-d committed Dec 5, 2022
    Configuration menu
    Copy the full SHA
    af8a3d3 View commit details
    Browse the repository at this point in the history
  13. Configuration menu
    Copy the full SHA
    a61174d View commit details
    Browse the repository at this point in the history