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

add commonjs export keyword #131

Merged
merged 3 commits into from
Nov 14, 2018
Merged

add commonjs export keyword #131

merged 3 commits into from
Nov 14, 2018

Conversation

AnEmortalKid
Copy link
Member

Adds woof as a keyword for module.exports

@@ -11,7 +11,7 @@ Should dogescript be ported to other languages, the `js` portion may be changed

* dogescript uses single quotes for strings. Double quotes are not supported.
* dogescript uses 4 space characters for indentation. Tabs are not supported.
* dogescript seperates statements by newlines by default. In true-doge mode, they are separated by 3 spaces.
* dogescript separates statements by newlines by default. In true-doge mode, they are separated by 3 spaces.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change seems irrelevant?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I noticed it's misspelled, I can revert it

lib/parser.js Outdated
{

// woof foo is X
if ( keys[2] === 'is')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is the potential ambiguity between this and exporting an equality comparison a concern?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I battled with this internally. originally I was using the as keyword like we do for require: so blah as blah, but that sort of shifted everything around:

woof such f much b wow as bar

Can you export an === ? :

module.exports = === b;

I kept is since at least it feels consistent (though misleading) with very x is y. I guess it's not really needed for the woof statement. Would it feel too out of place to not have it?

woof bar such foo

vs

woof bar is such foo

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Or maybe I misunderstood :( care to elaborate? @vpzomtrrfrt

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think I was referring to the possibility of module.exports = foo === bar

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, I don't think so, since at that point keys[4] would be the === marker.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might have to make it a bit wonky:

woof as foo much a b
  shh 1
wow

Since wow is a terminating keyword it might be tricky to try to support

woof much a b
ahh 1
wow as foo

Particularly with the available tokens being provided on a line basis, we won’t have the export name until we process the wow

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We might have to make it a bit wonky:

woof as foo much a b
  shh 1
wow

Since wow is a terminating keyword it might be tricky to try to support

woof much a b
ahh 1
wow as foo

Particularly with the available tokens being provided on a line basis, we won’t have the export name until we process the wow

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, that's a good point

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What if we used so (feels odd but the woof keyword helps distinguish)

woof foo so much a b
  shh 1
wow
module.exports.foo = function(a,b,) { //1 }

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, other thanso I also thought of be

woof foo be much a b wow => module.exports.foo = function (a,b)

Can’t think of any other keywords atm :(

@AnEmortalKid AnEmortalKid mentioned this pull request Oct 8, 2018
@AnEmortalKid
Copy link
Member Author

@vpzomtrrfrt any outstanding issues with this?

@AnEmortalKid
Copy link
Member Author

I'll push some changes with woof x be y as the syntax, so we can do woof x be foo is bar.

@AnEmortalKid
Copy link
Member Author

Pushed changes with be. I made TODOs for the other expression supports. In a follow up PR i'm going to extract the main chunk of parse() into a parseKeys so all the handler functions i'm declaring outside can call that (to have more recursive power).

@AnEmortalKid
Copy link
Member Author

@vpzomtrrfrt any opposition with the new keyword?

@vpzomtrrfrt
Copy link
Member

be seems like the best compromise so far

test/spec.test.js Outdated Show resolved Hide resolved
@AnEmortalKid
Copy link
Member Author

@vpzomtrrfrt ready for final blessing :)

@AnEmortalKid AnEmortalKid merged commit e021707 into master Nov 14, 2018
@AnEmortalKid AnEmortalKid mentioned this pull request Nov 14, 2018
15 tasks
@AnEmortalKid AnEmortalKid deleted the module-exports branch November 15, 2018 03:49
@AnEmortalKid AnEmortalKid added this to the 2.4.0 milestone Aug 11, 2020
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

Successfully merging this pull request may close these issues.

2 participants