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

Default arguments support #24 #62

Open
wants to merge 25 commits into
base: main
Choose a base branch
from

Commits on Dec 31, 2023

  1. feat: Attach default arguments to AST

    Macro extension is done in two phases, attaching arguments and expanding
    macros. Only in the first phase has a call to `parseArgspec`, so it
    seems natural to deal with default arguments in the first phase. We
    additionally attach default arguments to the AST during attachMacroArgs
    and then it will be picked up by existing macro expanders. This breaks
    an invariant that printRaw(attachArgs(X)) = printRaw(X).
    theseanl committed Dec 31, 2023
    Configuration menu
    Copy the full SHA
    ee4c8e5 View commit details
    Browse the repository at this point in the history

Commits on Jan 2, 2024

  1. feat: Support default arguments for embellishments

    Doing so required a rewrite of pegjs grammar use for parsing xparse
    argument specifications. Previously, a lot of things were modeled by an
    ArgSpec struct `Group`, but in the end those used in O,R,D and those for
    e,E,u required different behavior in many aspects, so the pegjs grammar
    now differentiate them via `group` and `collection`. Also, the ArgSpec
    does not have Group anymore, everything is parsed to an array of
    strings.
    
    This should fix siefkenj#46.
    theseanl committed Jan 2, 2024
    Configuration menu
    Copy the full SHA
    58077cd View commit details
    Browse the repository at this point in the history
  2. test: add macro with default argument case in CLI test, make it work on

    Windows
    
    Previously, the test was failing when run on Windows terminals due to
    how it treats quotes passed as arguments. We now use 'cross-spawn'
    module to get around of this issue.
    theseanl committed Jan 2, 2024
    Configuration menu
    Copy the full SHA
    76d88c1 View commit details
    Browse the repository at this point in the history

Commits on Jan 3, 2024

  1. Configuration menu
    Copy the full SHA
    48c30a7 View commit details
    Browse the repository at this point in the history

Commits on Jan 5, 2024

  1. Configuration menu
    Copy the full SHA
    c07f7b8 View commit details
    Browse the repository at this point in the history

Commits on Jan 17, 2024

  1. [WIP] fix 'until' behavior, support multi-token stop

    Initially we have assumed that 'until's token list can be parsed in a
    way similar to that of embellishments, but it turned out that there are
    some differences. Thus, I have simplified pegjs grammar for until and
    also worked out to make multi-token stop work.
    theseanl committed Jan 17, 2024
    Configuration menu
    Copy the full SHA
    af91693 View commit details
    Browse the repository at this point in the history

Commits on Jan 20, 2024

  1. build: Switch to nodejs export conditions from TS project references

    Previously, typescript project references were used to wire imports
    between workspace packages. Now this is done by package.json export
    conditions. This nodejs feature has already been used to support
    consuming packages in both esm and cjs format. We add an artificial
    condition "_bundle", and use the respective bundler's export conditions
    feature https://esbuild.github.io/api/#conditions and https://www.typescriptlang.org/tsconfig#customConditions
    to achieve that IDE and TS compiler resolve any workspace package
    imports to their respective Typescript source file, not their build
    output .d.ts files.
    
    This has an additional benefit of reducing bundle size of cjs build.
    Previously, CJS build operated on ESM build output; They fed
    dist/index.js files to esbuild. This changes this so that esbuild
    directly operates on Typescript source files even in CJS build. As
    esbuild will have more information, it will be able to better tree-shake
    unused codes.
    theseanl committed Jan 20, 2024
    Configuration menu
    Copy the full SHA
    0c3e598 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    da0e74c View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    b69517b View commit details
    Browse the repository at this point in the history
  4. chore: make prettier format json

    also used double quotes for interoparabilities with Windows
    theseanl committed Jan 20, 2024
    Configuration menu
    Copy the full SHA
    9035e2a View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    768a308 View commit details
    Browse the repository at this point in the history
  6. Configuration menu
    Copy the full SHA
    191c53c View commit details
    Browse the repository at this point in the history
  7. feat: support multi-stop token in 'until', macro delimiters

    Until argspec's behavior was fixed, and while doing so, a support for
    multi-token stops was added. Also, now it properly supports macro
    delimiters (which was really just a by-product of applying uniform
    treatment to any logic related to finding braces). This fixes
    siefkenj#46.
    theseanl committed Jan 20, 2024
    Configuration menu
    Copy the full SHA
    2067555 View commit details
    Browse the repository at this point in the history

Commits on Jan 21, 2024

  1. refactor: move default argument logic to expandMacros

    In order to deal with default arguments referencing other arguments, it
    seems to be better to move the logic from attachArgs to expandMacros.
    theseanl committed Jan 21, 2024
    Configuration menu
    Copy the full SHA
    6cb5599 View commit details
    Browse the repository at this point in the history
  2. feat: Support default arguments referencing other arguments

    Now expandMacros can correctly expand macros whose default arguments
    reference other arguments. A special care was taken in order to follow
    the behavior of xparse in case of circular references. In most of the
    cases, xparse throws a compilation error, but it works in case like
    `O{siefkenj#2} O{siefkenj#1}`. From this, we can reasonably guess that xparse treats
    default arguments that directly copies another argument's value in a
    special way. This behavior was implemented with a simple algorithm, and
    it turns out to be consistent with xparse's behavior in cases considered
    in unit tests.
    theseanl committed Jan 21, 2024
    Configuration menu
    Copy the full SHA
    20976aa View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    21a1733 View commit details
    Browse the repository at this point in the history

Commits on Jan 22, 2024

  1. Configuration menu
    Copy the full SHA
    bd1f972 View commit details
    Browse the repository at this point in the history
  2. chore: simplify codes

    theseanl committed Jan 22, 2024
    Configuration menu
    Copy the full SHA
    7d12d13 View commit details
    Browse the repository at this point in the history

Commits on Jan 23, 2024

  1. build: use import instead of _bundle

    Since package.json is re-written before publishing, we are free to point
    `import` condition to `.ts` source files. However, CLI tests need to be
    able to resolve to `dist/*.js` files, so a custom condition `prebuilt`
    pointing to those are kept in every package.json.
    theseanl committed Jan 23, 2024
    Configuration menu
    Copy the full SHA
    af5e25d View commit details
    Browse the repository at this point in the history

Commits on Jan 24, 2024

  1. Configuration menu
    Copy the full SHA
    8de3294 View commit details
    Browse the repository at this point in the history
  2. Configuration menu
    Copy the full SHA
    d63b24e View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    dcb22be View commit details
    Browse the repository at this point in the history

Commits on Jan 25, 2024

  1. Configuration menu
    Copy the full SHA
    916e10f View commit details
    Browse the repository at this point in the history

Commits on Jan 29, 2024

  1. Configuration menu
    Copy the full SHA
    38a18e2 View commit details
    Browse the repository at this point in the history
  2. fix: optional argument without default value

    The code path for optional argument without a default value wasn't being
    tested. Added a test and fixed it so that it properly expands to
    -NoValue-.
    theseanl committed Jan 29, 2024
    Configuration menu
    Copy the full SHA
    6b9e249 View commit details
    Browse the repository at this point in the history