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

TinyPG runnable as command line #9

Merged
merged 9 commits into from
Mar 21, 2013
Merged

Conversation

Jissai
Copy link
Contributor

@Jissai Jissai commented Mar 8, 2013

*add command line support on Main()
*Refactor and isolate business code (Parse/build/eval) from View (MainForm)
*add unit test

Jissai added 5 commits March 8, 2013 11:08
* refactor and isolate business code (aka parse/buil/eval) from
presentation (MainForm)
* add commandline support on Main() with branch to either GUI or Silent
run
strip the StringBuilder from method parameters, it now stand as a
Program Property
*bug correction
*add unit test
*code refactoring
/// Summary description for ProgramTester
/// </summary>
[TestClass]
public class ProgramTester
Copy link
Member

Choose a reason for hiding this comment

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

What is this class for?

The <summary> is basically empty.

Is it just a unit test for your Program class changes? Or is it more than that?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hi Tom,

Didn't have access to the internet for the week end. I will try to answer
to all your questions.

1/ in MainForm.cs there is a lot of deleted code. I placed the code
in Programs.cs to reduce code duplication : Parse/build/eval of grammar is
done only in Program now and Mainform.cs beiing the view, it should not
contains any business methods.

2/ Sorry for the spaces, I done a code auto-formatting at one time and even
if i tried to go back with the same number of spaces, git report them :(

3/ //var args = Environment.GetCommandLineArgs();
Sure you can remove it, I wasn't sure to reproduce the same behavior of
this command before i changed Main() 's signature, so I commented it for
reference "just in case". I just forget to remove it.

4/ I thought it was for the best... well apparently not. will do as you say
next time :)

5/ Yes ProgramTester is there to help test Program.cs. I should have filled
the

I think I addressed all your mails. Thank you for the reviews and feedbacks.
If any questions, fell free to ask.

Jissai

2013/3/8 Tom Spilman [email protected]

In TinyPG.UnitTests/ProgramTester.cs:

@@ -0,0 +1,79 @@
+using System;
+using System.Text;
+using System.Collections.Generic;
+using System.Linq;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+using TinyPG.Compiler;
+
+namespace TinyPG.UnitTests
+{

  • ///

  • /// Summary description for ProgramTester

  • ///

  • [TestClass]

  • public class ProgramTester

  • What is this class for?

    The

    is basically empty.

    Is it just a unit test for your Program class changes? Or is it more than
    that?


    Reply to this email directly or view it on GitHubhttps://github.com//pull/9/files#r3301515
    .

    Copy link
    Contributor Author

    Choose a reason for hiding this comment

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

    done in next commit

    @tomspilman
    Copy link
    Member

    This is fantastic! This mostly covers my needs for issue #3.

    Just going to review your code some first then we can get this merged.

    @tomspilman
    Copy link
    Member

    I didn't forget about you here... it just has been a busy week. I will get this merged in the next 24 hours.

    @tomspilman
    Copy link
    Member

    Looks like we may have a bug with these changes.

    If I open one of my existing TPG files with the TinyPG editor and hit Generate the ParseTree.cs, Parser.cs, and Scanner.cs files are no longer generated.

    Can you give that a test on your end?

    @Jissai
    Copy link
    Contributor Author

    Jissai commented Mar 20, 2013

    I use the editor and cmd line every day with different tpg file without
    problems.
    I had a similar bug (and a fix) when the grammar contains errors. Is this
    your case ?

    Scanner, Parser, ParserTree were not Generated if the grammar file
    contains build errors
    @tomspilman
    Copy link
    Member

    I had a similar bug (and a fix) when the grammar
    contains errors. Is this your case ?

    Well.... yes and no.

    The grammar has no errors and a correct parse tree is generated:

    Parse successful!
    

    There are however errors when the parser code is compiled....

    Building code...
    The type or namespace name 'ShaderInfo' could not be found (are you missing a using directive or an assembly reference?) on line 220
    The type or namespace name 'TechniqueInfo' could not be found (are you missing a using directive or an assembly reference?) on line 230
    The type or namespace name 'ShaderInfo' could not be found (are you missing a using directive or an assembly reference?) on line 241
    The type or namespace name 'PassInfo' could not be found (are you missing a using directive or an assembly reference?) on line 253
    The type or namespace name 'PassInfo' could not be found (are you missing a using directive or an assembly reference?) on line 261
    The type or namespace name 'TechniqueInfo' could not be found (are you missing a using directive or an assembly reference?) on line 270
    The type or namespace name 'PassInfo' could not be found (are you missing a using directive or an assembly reference?) on line 279
    The type or namespace name 'PassInfo' could not be found (are you missing a using directive or an assembly reference?) on line 287
    The type or namespace name 'SamplerStateInfo' could not be found (are you missing a using directive or an assembly reference?) on line 298
    The type or namespace name 'SamplerStateInfo' could not be found (are you missing a using directive or an assembly reference?) on line 314
    The type or namespace name 'ShaderInfo' could not be found (are you missing a using directive or an assembly reference?) on line 320
    Compilation contains errors, could not compile.
    

    These are all expected as my parser references classes and method that exist outside of the TPG file.

    I guess the key thing is that this all worked fine before... it does not now.... something changed and alter the behavior.

    @tomspilman
    Copy link
    Member

    So testing with your latest change seemed to fix that.

    Next issue I ran into if I do this:

    TinyPG.exe MGFX.tpg
    

    The command line crashes.

    If I do this....

    TinyPG.exe .\MGFX.tpg
    

    It does not.

    Seems like it assumes the path contains a directory and doesn't account for the case where it doesn't.

    @Jissai Jissai closed this Mar 20, 2013
    @Jissai Jissai reopened this Mar 20, 2013
    Jissai added 2 commits March 20, 2013 14:15
    When given e relative filename, TinyPG crashes  when launched from
    command line in cmd window.
    SetCurrentDirectory should not be called with null or string.Empty
    directory
    use GetFullPath on the argument to convert relative path to absolute
    pat. It prevents a lot of troubles afterward.
    @tomspilman
    Copy link
    Member

    Ok... that seems to have fixed it.

    As you have noted the console output isn't working from the command line.

    I'm fine merging this now if you are and get further fixes later.

    @Jissai
    Copy link
    Contributor Author

    Jissai commented Mar 21, 2013

    Sure we can merge it.
    Thank you for your feedbacks and debugguing by the way.
    Concerning the console output, the workaround i described in issue #18 works fine in my environement for now.

    tomspilman added a commit that referenced this pull request Mar 21, 2013
    TinyPG runnable as command line
    @tomspilman tomspilman merged commit c8af838 into SickheadGames:master Mar 21, 2013
    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