Comments (7)
; workaround 2 -just use a function
#fn value(x) => x
bc 4 2 value(-5)
from customasm.
; 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.
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.
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.
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.
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.
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)
- le() causes negative numbers to become positive HOT 3
- feature request: api for own rust programs HOT 1
- Include order not respected HOT 7
- #fill raises 'expected expression' error HOT 7
- Allow outputting banks to different output files
- Support for 32bit and 64bit floats HOT 1
- "no match found for instruction" when mnemonic is less than 4 characters long (and has a subruledef directly next to it) HOT 4
- pattern matching error: whitespace and constants after mnemomics cause pattern matching rules to be broken HOT 2
- Improve error message HOT 1
- Feature request: allow use of \x in multi byte character string functions HOT 2
- Allow Constants as Slice Sizes HOT 1
- Apparently unable to handle parameter without preceeding whitespace HOT 5
- Feature request: functions with variable numbers of arguments
- bank start/end/firstfree symbols
- Feature Request: Packed Instructions HOT 2
- Feature request: fill bank with custom value instead of zeros HOT 3
- Failure to match when a number is followed by a % HOT 3
- Allow aliases for token substitution HOT 8
- Is it possible to parse statements like .data or .asciz? HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from customasm.