Skip to content

allow nonspace operators. sys command args. dict use: #103

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

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

Conversation

superiums
Copy link

this branch fix symbols:

  • allow nonspace operators.
    such as let a=2+3; a>3 let add=x->x+1

but space is needed when you need to differ negtive numbers with operator:
such as let a=2+ -3

  • allow args in command.
    such as ls -l --color=auto /tmp

    • short args: -c
    • long args: --chars
    • paths: ./dir or /dir or ..

    but unfortunlately, single / is not added currently, as this may be used as operator someday.

    single . was ignored and default to cwd.

  • allow : to define dict.
    let dict={x:1,y:2} as well as the old one :
    let dict={x=1,y=2}

@superiums
Copy link
Author

tested with the following cases:

echo allow whitespace be skipped on operator;
echo

echo 0 testing negtive number ;
echo -1 ;
echo 3 + -1 ;
5 * -1 ;

echo;
echo 1 testing operator;
let a=10;
echo a+1 a-1 a*3 a//2 ;
let b=a+3-4*5//2 ;
echo b;
echo a%2 ;

echo;
echo 2 tesing lambda;
let add=x->x+100;
echo add a;

echo;
echo 3 testing overload;
let ++ =x->x+1;
++ a;

echo;
echo 4 testing command;
ls -l --color=auto ;
ls -l --color=auto /tmp ;


echo  "--testing dict with : " ;
let z = {x:1,y:3} ;
echo z;
echo z@x;

let z = {x=11,y=13} ;
echo z;
echo z@y;
echo finished.

@adam-mcdaniel
Copy link
Owner

Wow, thank you so so much!! I really appreciate the effort!! I'll take a look in the morning and merge if everything is in order!

@adam-mcdaniel
Copy link
Owner

adam-mcdaniel commented Apr 1, 2025

Hmm the one issue I see with this is the // operator changing to /. The reason is, / as a symbol should mean the root path, which should not evaluate to a function -- that's the reason why I chose // as the operator instead of the /

@superiums
Copy link
Author

superiums commented Apr 2, 2025

paths was recognized when : / folling a space and followed by some latter. (see parse_argument).

operator / was recognized when: / with space surround. or letters surround.

eg:

ls /bin , /bin as path

ls /local/bin , /local/bin as path

cd ./local , ./local as path

cd ../bin , ../bin as path.

a/b, / as operator

a / b , / as operator.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants