Coder Social home page Coder Social logo

Comments (6)

dionisiydk avatar dionisiydk commented on September 26, 2024

Why not reusing RBParser for all this parsing? It could be like:

methodNode := RBParser new 
    initializeParserWith: source;
    parseMessagePattern.
methodNode source: source.
^methodNode selectorAndArgumentNames

from tonel.

dionisiydk avatar dionisiydk commented on September 26, 2024

The main method can be rewritten as:

TonelWriter>>splitMethodSource: aMethodDefinition into: aBlock
	
	| source methodNode declaration body |
	source := aMethodDefinition source.
	methodNode := RBParser new 
    initializeParserWith: source;
    parseMessagePattern.
	methodNode source: source.
	declaration := methodNode selectorAndArgumentNames.

	body := source allButFirst: methodNode bodyStart - 1.
	aBlock
		value: (declaration trimLeft withLineEndings: self newLine)
		value: (body withLineEndings: self newLine)

It requires fix in #selectorAndArgumentNames because it does not take into account comments before selector. And it requires #bodyStart:

RBMethodNode>>bodyStart
	^ self arguments
		ifEmpty: [self keywordsPositions first + self selector size]
		ifNotEmpty: [self arguments last stop + 1]

from tonel.

estebanlm avatar estebanlm commented on September 26, 2024

That was like that in the first version.
But... so far that's not possible because Tonel is designed to be ported to different dialects and some of them do not have RBParser available (we could put that into a dialect dependent package, but well...).

from tonel.

dionisiydk avatar dionisiydk commented on September 26, 2024

from tonel.

estebanlm avatar estebanlm commented on September 26, 2024

at least Gemstone and Squeak have MC.
(and I was targeting Gemstone compatibility)

from tonel.

dalehenrich avatar dalehenrich commented on September 26, 2024

We've got RBParser as well and I have just about finished creating an RBParser-based Tonel reader for Rowan ... I can share the RBParser implementation (NewTonelParser. RBTonelParser, and RBTonelScanner) if there's interest...

from tonel.

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.