Skip to content

Auto script#34

Open
TaeSeanDo wants to merge 5 commits intomasterfrom
auto-script
Open

Auto script#34
TaeSeanDo wants to merge 5 commits intomasterfrom
auto-script

Conversation

@TaeSeanDo
Copy link
Contributor

No description provided.

@TaeSeanDo
Copy link
Contributor Author

I just have 1 question: For MissionScript, why does parenSplit split at '\(' and not '('?
Other than that, the code looks good.

@docprofsky
Copy link
Member

This is because String.split() uses a regular expression to determine where to split the string. A \ is used to escape special characters, such as (. When defining a string, a \ is used to insert special characters (\n for newline). To place a \ in a string, \\ has to be typed.

http://stackoverflow.com/questions/3481828/how-to-split-a-string-in-java/3481842#3481842

@RiverApril
Copy link

Oh maybe we should have it split on a semicolon instead of a new line so you could write multiple on a single line.

@docprofsky
Copy link
Member

How about a semicolon or a newline? I do not think we have much of a need for multiple statements on one line and I do not want to require semicolons for this.

@RiverApril
Copy link

Okay sounds good, feel free to make the change, or let me know if I should.

@docprofsky
Copy link
Member

I think it is fine without semicolons.

@docprofsky
Copy link
Member

Having a comment on a blank line breaks the parser.

@docprofsky
Copy link
Member

I think the best way to fix the comment without a preceding function function on that line is to use the presence of a ( to determine if there is a function on the part of the line before the comment (if present).

@RiverApril
Copy link

Where does it break? I think you could fix it by checking if the line starts with // before line 12. I'm guessing it's trying to parse the comment?

@docprofsky
Copy link
Member

No, it breaks because there is no open parenthesis on that line.

This is because the SmartDashboard does not
support typing newlines in a text field
@docprofsky
Copy link
Member

I have fixed the blank line issue.

@RiverApril
Copy link

Oh okay sorry, yes you're right.

Copy link
Member

Choose a reason for hiding this comment

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

Instead of checking what is returned, we should check the function signature. This can be done with getReturnType().

Copy link
Member

Choose a reason for hiding this comment

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

Having done more research, I think the best way is to use instanceof Command. By using instanceof Command, a subclass of Command will also be accepted. Also, null instanceof T is always false [1], so we can remove the null check.

[1]: http://stackoverflow.com/a/7313605

Copy link
Member

Choose a reason for hiding this comment

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

We should throw an exception here.
A ParseException or rethrowing the NumberFormatException is probably appropriate.

Copy link
Member

Choose a reason for hiding this comment

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

Here is also a good place to throw an excerption.
Probably a ParseException.

Copy link
Member

Choose a reason for hiding this comment

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

Here is also a good place to throw an excerption.
Probably a ParseException, or maybe an IllegalArgumentException.

@docprofsky docprofsky requested a review from RiverApril April 1, 2017 19:25
@docprofsky
Copy link
Member

@nedearb Can you review this, specifically the exceptions.

@RiverApril
Copy link

Looks fine, but have you tested it?

@docprofsky docprofsky removed the request for review from RiverApril April 1, 2017 20:00
Copy link

@RiverApril RiverApril left a comment

Choose a reason for hiding this comment

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

Looks good

@docprofsky
Copy link
Member

A better way of integrating the MissionScript parser with our missions is to make a ScriptMission that extends Mission. The ScriptMission would take a filename which it parse to generate its mission. The ScriptMission could reload the mission every time it is run or have a separate way of triggering it to reload its mission.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

Comments