Giter VIP home page Giter VIP logo

Comments (10)

hlorenzi avatar hlorenzi commented on May 31, 2024 1

I found out why asm blocks were erroring out, and now I can pass all the tests! (But I had to edit some of the more contrived tests.) It's on the rule_whitespace branch again.

As you said, rules written as op {a}, {b} will require the space after the comma. We can bet someone is relying on the old behavior, so this would be a breaking change... I wonder if that would be acceptable?

from customasm.

hlorenzi avatar hlorenzi commented on May 31, 2024 1

I was finally able to get all the tests to pass under the new whitespace rules, and it's now available on v0.12!
It's a breaking change and there might be unexpected issues, so let's see if it's worth it.

from customasm.

agrif avatar agrif commented on May 31, 2024

It looks like customasm is ignoring whitespace, for example:

#ruledef
{
	rl a => 0x0000
	rla => 0x01
}

rl a
rla

produces 01 01, not 00 00 01. I've been trying to implement the z80 instruction set in customasm, and have run into a few instances like above.

from customasm.

hlorenzi avatar hlorenzi commented on May 31, 2024

Yeah, it's ignoring whitespace. It was the easier route to take since the assembler uses a weird mix of lexical tokens and raw characters for instruction matching. I've gotta find a way to make whitespace count again without breaking backward-compatibility!

from customasm.

agrif avatar agrif commented on May 31, 2024

I've been poking at the source tonight, and I'm not sure this is fixable without breaking at least this test.

It seems reasonable to me that the rule should only match r0000 and friends, without the space, but I'm not sure why the behavior is there in the first place.

from customasm.

hlorenzi avatar hlorenzi commented on May 31, 2024

It was specifically for "glued" rules that the token/character duality arose in the parser. That test reflects a use-case where you may need to supply a complex expression to a glued argument -- the space is needed for the expression parser to work.

How did you go about solving the issue in general? I think we can add a small exception for that test, so all would be good!

from customasm.

agrif avatar agrif commented on May 31, 2024

I haven't implemented it yet, but I was planning on adding a whitespace variant to the rule parts. Looking at this more closely, I'm not sure that would work. I might try it anyway, and see what damage it causes.

from customasm.

hlorenzi avatar hlorenzi commented on May 31, 2024

I've played a bit with whitespaces rules, and it seems it'll be difficult to add it without breaking something in the way! It seems to break asm blocks, unfortunately, which might be a tough fix.

I've also tried simplifying this whole token/character duality thing to just using tokens directly, but that breaks a few other tests, and I'm not sure whether anyone is relying on that behavior. But this seems to be the most promising path, I think.

(This is all on the rule_whitespace branch!)

from customasm.

agrif avatar agrif commented on May 31, 2024

I've done some exploring as well, attaching an after_ignorable flag to all tokens and using this later to introduce a Space pattern to rules. Originally this flag was in the parser, but I also ran into an issue with asm blocks!

This passes all tests, but has the unusual side effect that rules written as op {a}, {b} now require the space after the comma -- basically, any space present in the rule must be present to match, but extra spaces are ignored. Unfortunately this means it doesn't solve my rl a / rla problem, and I don't know any way around that.

It's hard to track what spaces are important across parameter boundaries! The spaces between symbols are probably always important, but how can you tell if the space in the rule op {a} is between symbols?

from customasm.

agrif avatar agrif commented on May 31, 2024

I think so, but I'm obviously pretty biased here. It's unfortunate that these two tests broke, though. Back-compatibility would be a little bit easier to bear if a rule like op {a},{b} also accepted things like op a, b.

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.