Skip to content

Finish parser#2

Open
tigershen23 wants to merge 2 commits intomasterfrom
finish_parser
Open

Finish parser#2
tigershen23 wants to merge 2 commits intomasterfrom
finish_parser

Conversation

@tigershen23
Copy link
Contributor

@tigershen23 tigershen23 commented Jan 19, 2017

Wanted to add on to Richie's work without pushing to his fork and Myles suggested just working off of this repo instead of forking anyways, so I figured I would make a hub PR for the rest of our lex/parse work.

Supercedes #1

Here's a version of our language spec augmented with some examples, hopefully it can be used to track how much functionality we are able to parse and what remains to be done.

Feel free to push to this branch directly (or branch off of it) and check off items you add. We can also merge stuff into master as we feel comfortable with it, up to y'all really.

  • First class func () => {}
  • signed integers literals 1234 -24
  • string literals "hello world" "hello \" yo\"world"
  • condition logic if (condition) { } else if (condition) { } else { }
  • array literal [1, 2, "hey guys", 4]
  • map literal #{key1: val1, 2: #{subkey: subval}# }#
  • declartion let let foo = "bar"
  • while loop while(true) {}
  • operators + - / *
  • comments //

(cherry picked from commit 54683d8)
(cherry picked from commit 8954439)
(cherry picked from commit aa062ab)
(cherry picked from commit bf7eec5)
}),
exp: (exp, left, right) => ({
type: "EXP",
value: exp,
Copy link
Contributor Author

@tigershen23 tigershen23 Jan 19, 2017

Choose a reason for hiding this comment

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

@richardartoul Can the value ever be something besides an operator with the way you wrote https://github.com/Bradfield/languages-2017-01/pull/2/files#diff-fe30eed34176a05cc930283036bce555R39? If we don't have a valid value that isn't an operator, what do you think about calling this key op to avoid ambiguity?

: LET id ASSIGN exp -> af.declareAssign($2, $4)
;

function_call
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

| DIVIDE -> af.operator("DIVIDE")
;


Copy link
Contributor Author

Choose a reason for hiding this comment

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

nit: xtra whitespace

| id -> af.exp($1, null, null)
| function_call -> af.exp($1, null, null)
| exp operator exp -> af.exp($2, $1, $3)
| OPAREN exp CPAREN -> $2
Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@richardartoul
Copy link

Thanks for doing this, excited to work on this tomorrow! Also sorry about the crappy test runner. When I got home I noticed that we had introduced regressions even in our 3 hour session (making the function declarations accept arguments broke the functionality for functions with no arguments) so I threw something together really fast.

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