Wayback Machinekoobas.hobune.stream
May JUN Jul
Previous capture 12 Next capture
2021 2022 2023
1 capture
12 Jun 22 - 12 Jun 22
sparklines
Close Help
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by yoannG · Apr 09, 2018 at 08:55 AM · parserexpression

B83 Expression parser problem

Hi ! Newbie here =)

I am creating a calculator, using the Expression parser of @Bunny83 : http://wiki.unity3d.com/index.php/ExpressionParser

When i want to compute 3+4*5, and change f.e the value 4 to a negative number like -1, no problem arise. Though, if i change the value 5 for a negative number, i get the exception "Reached unexpected end within the parsing tree".

In the same way, if i have x*y*z and change x and y values to become negative it will be fine. It's only if the last member becomes negative that the exception is thrown.

The piece of code containing the multiply operation is the following, but i see nothing to incriminate..

             else if (aExpression.Contains('*'))
             {
                 string[] parts = aExpression.Split('*');
                 List<IValue> exp = new List<IValue>(parts.Length);
                 for (int i = 0; i < parts.Length; i++)
                 {
                     exp.Add(Parse(parts[i]));
                 }
                 if (exp.Count == 1)
                     return exp[0];
                 return new OperationProduct(exp.ToArray());
             }

![alt text][1]

Notice in the image of my Console that i won't be able to pass the value 0 to set it to a lower value (i decrement my number by 1 with a keyboard key).. [1]: /storage/temp/114544-problemparser.png

problemparser.png (64.6 kB)
Comment
Add comment
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users

1 Reply

· Add your reply
  • Sort: 
avatar image
0
Best Answer

Answer by Bunny83 · Apr 10, 2018 at 01:32 AM

So you didn't read the additional notes? ^^ Especially the last paragraph:

The parser uses a quite strict syntax. As mentioned earlier brackets must not be empty, so you can't use a custom method without a parameter. The "unary minus" has to be wrapped with brackets. The parser doesn't support things like: 5 * -4. This should be 5 * (-4)

The unary minus create countless problems. This parser doesn't parse the expression linearly from left to right but simply splits the expression at operators starting at the low priority operators

Comment
Add comment · Show 1 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image yoannG · Apr 10, 2018 at 03:49 AM 0
Share

oh i see ! I did not pay attention to your additional notes, sorry about that. I was busy trying to figure this all out ^^. I think that what puzzled me is that the problem would only occur with the last member, so i had dropped the idea that it was a bracket problem.. i was more into thinking that it was maybe due to the way i was myself concatenating my string or something before to feed it to your expression parser.

Your code is extremely advanced to me. I have a hard time reading it :D. I literally stop at every line to try to figure it out ! Sorry about that ! I am still really new at program$$anonymous$$g.

Your answer

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this Question

Answers Answers and Comments

76 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

Expression denotes C# 1 Answer

Remove TAB from parsed string 2 Answers

Performance impact of blend shapes 0 Answers

PC RSS Feed Get Xml Data Works , but not on android? 0 Answers

Simple XML reading? (only string/numerical data needed) 1 Answer


Enterprise
Social Q&A

Social
Subscribe on YouTube social-youtube Follow on LinkedIn social-linkedin Follow on Twitter social-twitter Follow on Facebook social-facebook Follow on Instagram social-instagram

Footer

  • Purchase
    • Products
    • Subscription
    • Asset Store
    • Unity Gear
    • Resellers
  • Education
    • Students
    • Educators
    • Certification
    • Learn
    • Center of Excellence
  • Download
    • Unity
    • Beta Program
  • Unity Labs
    • Labs
    • Publications
  • Resources
    • Learn platform
    • Community
    • Documentation
    • Unity QA
    • FAQ
    • Services Status
    • Connect
  • About Unity
    • About Us
    • Blog
    • Events
    • Careers
    • Contact
    • Press
    • Partners
    • Affiliates
    • Security
Copyright © 2020 Unity Technologies
  • Legal
  • Privacy Policy
  • Cookies
  • Do Not Sell My Personal Information
  • Cookies Settings
"Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges