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

feat(parse,interp,e2e): Add basic global native functions #35

Merged
merged 14 commits into from
Apr 4, 2018

Conversation

sjbarag
Copy link
Owner

@sjbarag sjbarag commented Apr 4, 2018

This gets the groundwork set up for the rapid implementation of global functions — including the ability to call them at runtime. There's a few caveats there for now though:

  1. Only LCase, UCase, (string lowercase and string uppercase) and RebootSystem (which does nothing in this implementation [1]) are implemented so far.
  2. I haven't figured out how I want to implement function argument type checking, e.g. causing an error to occur when LCase(185) is called.
  3. Adding new globally-scoped functions is probably a bit tougher than it needs to be right now. That's pretty minor though.

[1] I guess I could shell out to shutdown -r but that seems particularly mean and useless.

@sjbarag sjbarag added enhancement Any addition to this project's existing capabilities parser Affects this project's token parser interpreter Affects this project's tree-walking interpreter e2e Affects this project's end-to-end test cases (the BrightScript sample files executed during testing) labels Apr 4, 2018
@sjbarag
Copy link
Owner Author

sjbarag commented Apr 4, 2018

Oh right, I forgot to mention:

The same Callable system will work for user-defined functions as well! We still need to parse and interpret them, but the overall pattern will still apply 😄

It's part of the BrightScript standard library, so at least it's
something
This also provides a good function name in errors instead of just
"[Function]".  So that's neat.
This includes a move twoards greater compile-time safety in the
implementation of "native" functions.
These are only here right now to help work out the native function
implementation.
It's just UCase and LCase for now, but I want to get a pattern set up
for whenever we add more global functions.
This adds parser tests for function calls as well!  *Ho0r@Y*
Still only for global functions, but these tests should be easyish to
extend for user-defined functions
Right now it's only `LCase` and `UCase` but it's something!  At least
we've got a pattern set up.
@sjbarag sjbarag merged commit 0ca523a into master Apr 4, 2018
@sjbarag sjbarag deleted the add-functions branch April 4, 2018 03:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
e2e Affects this project's end-to-end test cases (the BrightScript sample files executed during testing) enhancement Any addition to this project's existing capabilities interpreter Affects this project's tree-walking interpreter parser Affects this project's token parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant