• Join/Login
  • Business Software
  • Open Source Software
  • For Vendors
  • Blog
  • About
  • More
    • Articles
    • Create
    • SourceForge Podcast
    • Site Documentation
    • Subscribe to our Newsletter
    • Support Request
SourceForge logo
For Vendors Help Create Join Login
SourceForge logo
Business Software
Open Source Software
SourceForge Podcast
Resources
  • Articles
  • Case Studies
  • Blog
Menu
  • Help
  • Create
  • Join
  • Login
  • Home
  • Browse
  • FMSLogo
  • Code
FMSLogo

FMSLogo Code

A Logo programming environment for Microsoft Windows

Brought to you by: david_costanzo
  • Summary
  • Files
  • Reviews
  • Support
  • Tickets ▾
    • Feature Requests
    • Bugs
    • Support Requests
  • Discussion
  • Code
Menu ▾ ▴
 
  • Browse Commits
  • Browse Files

Commit [r6000]  Maximize  Restore  History

Fix Bug #589; The operator precedence of a negation operator no longer spread to its right.

For example, "2 *-1 + 100" now evaluates to 98, not 194.

The core of the bug is that the parenthesizer rewrote "-X" as "0 - X", which would then
be parsed as normal, with any following infix operators being applied. So the expression
"2 *-1 + 100" would be parenthesized as (2 * (0 - 1 + 100)) instead of ((2 * -1) + 100).

Fixing this required more changes than I had hoped for. In the end, I found the "0 - X"
rewrite to be inherently faulty. A special case is still necessary because "-" is, by default,
classified as an infix operator and the rest of the code assumes that infix operators are
infix and have a higher binding priority than normal procedures.

The new logic has two special cases for this rewrite, same as the old logic. However, the
new code localizes both to paren.cpp instead of implementing the same idea in both the
runparser and the parenthesizer. It's cleaner to put this in paren.cpp because the runparser
treats the word as a list of tokens and it's not possible to know when "-" is infix or prefix
without a parse tree.

david_costanzo 2023-12-03

Browse code at this revision

Parent: [r5999]

Child: [r6001]

changed /logo/trunk/src/CHANGELOG.TXT
changed /logo/trunk/src/paren.cpp
changed /logo/trunk/src/parse.cpp
changed /logo/trunk/src/test/parse.lgo
/logo/trunk/src/CHANGELOG.TXT Diff Switch to side-by-side view
Loading...
/logo/trunk/src/paren.cpp Diff Switch to side-by-side view
Loading...
/logo/trunk/src/parse.cpp Diff Switch to side-by-side view
Loading...
/logo/trunk/src/test/parse.lgo Diff Switch to side-by-side view
Loading...
SourceForge
  • Create a Project
  • Open Source Software
  • Business Software
  • Top Downloaded Projects
Company
  • About
  • Team
  • SourceForge Headquarters
    1320 Columbia Street Suite 310
    San Diego, CA 92101
    +1 (858) 422-6466
Resources
  • Support
  • Site Documentation
  • Site Status
  • SourceForge Reviews
SourceForge logo
© 2026 Slashdot Media. All Rights Reserved.
Terms Privacy Opt Out Advertise
mdb logo