Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Smalltalk grammar parsing of literal arrays differs from legacy parser #64

Open
stlutz opened this issue Apr 3, 2021 · 0 comments
Open

Comments

@stlutz
Copy link

stlutz commented Apr 3, 2021

The Smalltalk grammar defines the following rule for literal arrays:

LiteralArrayLiteral =
"#(" literalArrayLiteralElement* ")"

This fails to parse e.g. Morph class >> #vectorAdditions
vectorAdditions
	"Answer slot/command definitions for the vector experiment"

	^ # (
(slot x   'The x coordinate' Number readWrite Player  getX   Player setX:)
(slot y   'The y coordinate' Number readWrite Player  getY  Player setY:)
(slot heading  'Which direction the object is facing.  0 is straight up' Number readWrite Player getHeading  Player setHeading:)
(slot distance 'The length of the vector connecting the origin to the object''s position' Number readWrite Player getDistance Player setDistance:)
(slot theta 'The angle between the positive x-axis and the vector connecting the origin to the object''s position' Number readWrite Player getTheta Player setTheta: )
(slot headingTheta 'The angle that my heading vector makes with the positive x-axis' Number readWrite Player getHeadingTheta Player setHeadingTheta:)

(command + 'Adds two players together, treating each as a vector from the origin.' Player)
(command - 'Subtracts one player from another, treating each as a vector from the origin.' Player)
(command * 'Multiply a player by a Number, treating the Player as a vector from the origin.' Number)
(command / 'Divide a player by a Number, treating the Player as a vector from the origin.' Number)

(command incr: 'Each Player is a vector from the origin.  Increase one by the amount of the other.' Player)
(command decr: 'Each Player is a vector from the origin.  Decrease one by the amount of the other.' Player)
(command multBy: 'A Player is a vector from the origin.  Multiply its length by the factor.' Number)
(command dividedBy: 'A Player is a vector from the origin.  Divide its length by the factor.' Number)
	)

The rule should probably be:

LiteralArrayLiteral =
	"#" "(" literalArrayLiteralElement*  ")"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant