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

Idea: Allow for negative indices in argument and sub- indices to allow for pythoninc interface to picking up items from the end #38

Open
mpourmpoulis opened this issue Aug 3, 2020 · 2 comments
Assignees
Labels
enhancement New feature or request Naming Conventions How things should be named New Positional Description
Milestone

Comments

@mpourmpoulis
Copy link
Owner

No description provided.

@mpourmpoulis mpourmpoulis changed the title Idea Idea: Allow for negative indices in argument and sub- indices to allow for pythoninc interface to picking up items from the end Aug 3, 2020
@mpourmpoulis
Copy link
Owner Author

This idea has been on my mind for quite a while but will require little bit of code on the grammar side because the IntegerRef Does not support negative integers.

as for the spoken form, Probably something like

argument minus one

Be appropriate

@mpourmpoulis mpourmpoulis self-assigned this Aug 3, 2020
@mpourmpoulis mpourmpoulis added enhancement New feature or request Naming Conventions How things should be named New Positional Description labels Aug 3, 2020
@mpourmpoulis mpourmpoulis added this to the v0.2.0 milestone Aug 3, 2020
mpourmpoulis added a commit that referenced this issue Aug 22, 2020
…t block to make it more idiomatic and handle better negative indices

#38
mpourmpoulis added a commit that referenced this issue Aug 22, 2020
mpourmpoulis added a commit that referenced this issue Aug 22, 2020
…except block and Make support for negative indices proper

#38
@mpourmpoulis
Copy link
Owner Author

This is now possible for argument queries and subindexing In nondedicated queries

You can say something like argument minus 1 to pick the last argument

This can be achieved by changing IntegerRefST with a specially crafted dragonfly compound

def positive_negative_integer(name,value):
    return Compound(
    name=name,
    spec="([<minus>] <i>)",
    extras = [IntegerRefST("i",0,value),Choice("minus",{"minus":-1},default=1)],
    value_func = lambda node,extras: extras["minus"]*extras["i"],

)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Naming Conventions How things should be named New Positional Description
Projects
None yet
Development

No branches or pull requests

1 participant