Giter Club home page Giter Club logo

Comments (7)

flaviojs avatar flaviojs commented on May 28, 2024
; workaround 2 -just use a function
#fn value(x) => x

    bc 4 2 value(-5)

from customasm.

flaviojs avatar flaviojs commented on May 28, 2024
; workaround 3 - add commas
#ruledef {
    bcx {BO: u5}, {BI: u5}, {BD: i14}, {AA: u1}, {LK: u1} => 0b010000 @ BO @ BI @ BD @ AA @ LK
    bc {BO}, {BI}, {target_addr} => asm { bcx {BO}, {BI}, {target_addr}, 0, 0 }
}

    bc 4, 2, -5

Conclusion: a single space is not enough to separate instruction arguments?

from customasm.

chrisgbk avatar chrisgbk commented on May 28, 2024

I'm going to guess that 2 -5 is being simplified to -3, as it looks like a mathematical expression instead of separate arguments.

from customasm.

flaviojs avatar flaviojs commented on May 28, 2024

That makes sense, thanks.
Then the real problem is not having a helpful error message.

Anything that works with a "missing argument" example like:

    bc 4, 2

Ideally it would show the closest match and what part failed to match.

from customasm.

chrisgbk avatar chrisgbk commented on May 28, 2024

I checked and verified for sure, and my guess was correct, adding a syntax with one less argument gets a match, and that match was -3 when output.

This issue can additionally be worked around by specifying all negative numbers -x as 0-x or x*-1. Notably, (-x) by itself does not work, as that tries to call a function y(-x) which is uncallable.

from customasm.

hlorenzi avatar hlorenzi commented on May 28, 2024

chrisgbk is right in that 2 -5 just looks like a single expression to the parser. Every time there's an expression parameter, it greedily tries to consume an expression. Positive numbers like 2 5 should work, though, since that's not a valid expression and will be broken apart.

You're right that a single space isn't enough. The suggestion here is always to introduce some separator token between parameters, like a comma or anything else that would be invalid in an expression, so there's no ambiguity.

I'd also love to have the assembler detail what issues it encountered during instruction matching, so that you know exactly what went wrong! But I just couldn't yet think of how to implement that feature in the current architecture, and what message format would be the most helpful. If we're not careful, I imagine this explanation could become just as cryptic and confusing as the problem itself.

(And perhaps we should make expressions such as the uncallable 2 (-5) obviously wrong to the parser, so that it's able to break it apart into two parameters. But that might prove to be a bit of a headache, since we'd be trying to fix a semantics error in the syntax parser.)

from customasm.

flaviojs avatar flaviojs commented on May 28, 2024

Ok, document that a non-space separator is recommended between arguments.
A negative number example can be used to show what could go wrong.
The code does not contain docs and the wiki is not editable by random people so I cannot help there.

Normally I wouldn't mind trying to implement an appropriate error message, but I cannot use cargo fmt in this project.
I don't want to handle non-automatic formatting so I'm out.

from customasm.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.