Giter VIP home page Giter VIP logo

Comments (3)

EnderShadow avatar EnderShadow commented on June 8, 2024

Some additional information based on my testing. If I inline subrule b from above, it properly compiles

from customasm.

EnderShadow avatar EnderShadow commented on June 8, 2024

An even smaller POC if it matters.

#subruledef b
{
    % => 0x0`0
}

#ruledef
{
    {x: u8} {y: b} => x @ y
}

0 %

from customasm.

hlorenzi avatar hlorenzi commented on June 8, 2024

Hmm, this might be unsolvable in the current architecture. The reason s0 %r0 fails is that the a subrule s{x: u4} starts parsing an expression after the s token, and the remaining 0 %r0 looks like a valid expression syntactically (using the modulo operator % on the literal 0 an the variable r0). To avoid any parser complexity, expression parsing is greedy. The solution, as you mention, is to introduce a separator token that looks invalid in an expression, such as a comma.

There is an exception, however, in the case of specifying everything in a single rule as s{x: u4} %r{y: u4}, where the parser will look ahead, and expression parsing can stop early. This means that extracting parameters into their own named subrules isn't exactly orthogonal in behavior, and the most powerful option is usually to specify everything monolithically. This can be annoying and might be worth improving in the future.

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.