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

Allow $ as a character to terminate expressions in castext #1019

Open
sangwinc opened this issue Aug 23, 2023 · 1 comment
Open

Allow $ as a character to terminate expressions in castext #1019

sangwinc opened this issue Aug 23, 2023 · 1 comment
Labels

Comments

@sangwinc
Copy link
Member

This change will match core Maxima syntax.

@aharjula
Copy link
Member

aharjula commented Aug 23, 2023

We currently have no multi-statement CAS expressions in CASText, but if we did, those would probably use keyvals as their basis. So the keyval parsing/validation is the place where this matters the most.

One other reason we might want this is the edge case of having multi-statement localised parsing (which we probably do not have a use-case for), where we could move ; to be a list separator and use $ for the statement separator. Like this:

> php cli/parser_tester.php --string="[1 234,56;x^2,3]$ 1  234 x"  --only=FI
Testing with '[1 234,56;x^2,3]$ 1  234 x'

Token output tests:

 FI:
  [ [              , SYMBOL          ,1:1:1,1,]
  [ 1234.56        , FLOAT           ,1:2:2,8,]
  [ ;              , LIST_SEP        ,1:10:10,1,]
  [ x              , ID              ,1:11:11,1,]
  [ ^              , SYMBOL          ,1:12:12,1,]
  [ 2.3            , FLOAT           ,1:13:13,3,]
  [ ]              , SYMBOL          ,1:16:16,1,]
  [ $              , END_TOKEN       ,1:17:17,1,]
  [                , WS              ,1:18:17,1,]
  [ 1              , INT             ,1:19:19,1,]
  [                , WS              ,1:20:19,2,]
  [ 234            , INT             ,1:22:22,3,]
  [                , WS              ,1:25:24,1,]
  [ x              , ID              ,1:26:26,1,]

Parser output tests:

 FI:

  Root:
[1 234,56;x^2,3]$ 1  234 x
-------------------------- MP_Root
----------------           MP_Statement
----------------           MP_List
 --------                  MP_Float 1234.56
          -----            MP_Operation ^
          -                MP_Identifier x
            ---            MP_Float 2.3
                  -------- MP_Statement
                  -------- MP_Operation * [fixspaces]
                  -        MP_Integer 1
                     ----- MP_Operation * [fixspaces]
                     ---   MP_Integer 234
                         - MP_Identifier x
 toString():
[1234.56,x^2.3];1*234*x;

Note the nice fixspaces issue related to space as the digit grouping char, there... basically, single space is digit grouping there but two is no longer valid for that and needs to be fixed...

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

No branches or pull requests

2 participants