Shop OBEX P1 Docs P2 Docs Learn Events
Spin compiler - Page 5 — Parallax Forums

Spin compiler

1235

Comments

  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-26 06:08
    I can see that I am going to have to create an X-Code project file for it now to keep up with the windows versionsmile.gif

    I'll see if there is anything I can bust.
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-26 07:45
    Okay, I busted it again smile.gif

    I'm going to try and make a slightly more comprehensive test file but for now this is showing an error in the assignment.

    Would it be possible to get the parser to output the comments to make it easier to see where in the source we are?

    I get this error when I try and upload a spin file. Anyone know a way around it other than renaming the file?
    Server Error in '/' Application.
    
    Runtime Error
    
    Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed remotely (for security reasons). It could, however, be viewed by browsers running on the local server machine. 
    
    Details: To enable the details of this specific error message to be viewable on remote machines, please create a <customErrors> tag within a "web.config" configuration file located in the root directory of the current web application. This <customErrors> tag should then have its "mode" attribute set to "Off".
    
    
    <!-- Web.Config Configuration File -->
    
    <configuration>
        <system.web>
            <customErrors mode="Off"/>
        </system.web>
    </configuration>
    
    Notes: The current error page you are seeing can be replaced by a custom error page by modifying the "defaultRedirect" attribute of the application's <customErrors> configuration tag to point to a custom error page URL.
    
    
    <!-- Web.Config Configuration File -->
    
    <configuration>
        <system.web>
            <customErrors mode="RemoteOnly" defaultRedirect="mycustompage.htm"/>
        </system.web>
    </configuration>
    
    
  • dfletchdfletch Posts: 165
    edited 2008-03-26 16:44
    My bleary morning eyes was reading this as the error you were getting in the parser itself. I'm thinking "what kind of crazy stuff is the Mac doing?! I never put any XML in there!". I completely didn't expect to see a forum bug report here. Nobody expects the Spanish Inquisition! tongue.gif

    Thank goodness Jasper_M was in the IRC channel to set me straight smile.gif

    I'll look at this one later today.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-26 21:48
    Sorry about that. I should have made it clearersmile.gif
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-03-27 01:28
    Okay, here is a test file. I will keep adding things to it as I get time. I will only put in things that compile with the current compiler. At some stage I will try to make another file with
    all the syntax errors I can think of.

    Once you get the parser working with multiple files I'll split it up into separate objects so it is easier to find stuff.


    I think that the parser has an error when parsing the method name rows. The '|' that signifies the start of local variables is coming out as an OR statement.
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-04-26 02:39
    Almost a month since this was last updated. Any progress to report?
  • dfletchdfletch Posts: 165
    edited 2008-04-26 02:47
    I've gotten myself buried in too much stuff, really and I just moved to a new apartment. Sorry, it's going to be slow for a while. I'm thinking it will be back on my radar sometime in May.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-05-29 15:38
    Ping!!!!

    Is there anything that we can do to help get this ball rolling? Maybe define some subroutines that need to be written that some of us can tackle?
  • rokickirokicki Posts: 1,000
    edited 2008-05-29 17:08
    Absolutely! Dfletch is the man here, but if you have some spare cycles to help, try downloading and
    building the project from sourceforge and see what works and what doesn't. Then chat with dfletch
    (and me if you want) about what remains and how it should be done.

    There are a lot of separable pieces, all of which are pretty approachable. I believe right now dfletch
    is making the parser multipass so it can pick up declarations properly before needing the uses. We
    also need someone to add a treewalker to generate the actual binary code; that will take some study
    of what people have done and perhaps some reverse engineering.

    But always, the first step is to download and build. I posted some instructions earlier.
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-05-29 17:31
    I pulled down a copy of spinparser-0.0.0rCVS a while bace and it makes fine on my MacBook Pro. But where are the instructions you posted? Do I need to setup CVS? -Chuck-
  • rokickirokicki Posts: 1,000
    edited 2008-05-29 17:58
    Here are the instructions:

    cvs -dserver:anonymous@spinc.cvs.sourceforge.net:/cvsroot/spinc login
    cvs -z3 -dserver:anonymous@spinc.cvs.sourceforge.net:/cvsroot/spinc co -P spinparser
    
    



    This does an anonymous checkout. This *should* work on either Unix or on Windows with cygwin
    (and one would hope on the Mac too).

    If you want to contribute back to the codebase, you'll need to register on sourceforge (it's quick
    and easy) and then let me or dfletch know you want checkin privileges.
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-05-29 19:22
    The first commnad gives me:

    cvs login: CVSROOT password specification is only valid for
    cvs login: pserver connection method.
    cvs [noparse][[/noparse]login aborted]: Bad CVSROOT: `server:anonymous@spinc.cvs.sourceforge.net:/cvsroot/spinc'.
    
    
  • rokickirokicki Posts: 1,000
    edited 2008-05-29 21:41
    Try this:

    cvs -d[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]server:anonymous@spinc.cvs.sourceforge.net:/cvsroot/spinc login
    cvs -z3 -d[img]http://forums.parallax.com/images/smilies/tongue.gif[/img]server:anonymous@spinc.cvs.sourceforge.net:/cvsroot/spinc co -P spinparser
    
    



    Looks like something ate the tongue.gif maybe thinking they were smilies.

    Ugg, did it again. How do I get it to work without the smilies? This is code!

    In any case, the -d argument should look like

    - d : p s e r v e r ...

    but without the spaces of course. If someone knows how to make this forum work
    correctly, maybe they can tell me how to include code without getting it munged.
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-05-29 22:50
    That helped. It whirred and clicked for awhile, then ended with:


    g++ -dynamiclib -single_module  -o .libs/libSpinParser.0.0.0.dylib  .libs/libSpinParser_la-spinparse.o .libs/libSpinParser_la-spinlex.o .libs/InvalidNode.o .libs/Node.o .libs/Nonterminal.o .libs/SpinParser.o .libs/StringPointer.o .libs/Terminal.o .libs/Tree.o   -install_name  /usr/local/lib/libSpinParser.0.dylib -Wl,-compatibility_version -Wl,1 -Wl,-current_version -Wl,1.0
    Undefined symbols:
      "spinlex(YYSTYPE*, void*)", referenced from:
          spinparse(void*)in libSpinParser_la-spinparse.o
    ld: symbol(s) not found
    collect2: ld returned 1 exit status
    make: *** [noparse][[/noparse]libSpinParser.la] Error 1
    make: *** [noparse][[/noparse]all-recursive] Error 1
    make: *** [noparse][[/noparse]all] Error 2
    
    
  • stevenmess2004stevenmess2004 Posts: 1,102
    edited 2008-05-30 10:52
    The instructions are back a couple of pages. Try a few posts from the bottom of this page for instructions on how to build. http://forums.parallax.com/showthread.php?p=711419

    I had it working on mac os 10.5 without any dramas. Unfortunately I don't know enough about compilers (or have the time to learn) to do anything useful except break it. I started putting a test suite together awhile ago but never finished it.

    @rokicki, try phil's code page here www.phipi.com/format. It should make those problems disappear. It just changes things that will muck up the forum into ascii or something.
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-05-30 14:25
    Thanks. I have an old version running, but the version in CVS (that I checked out yesterday) is the one getting the build error. The older one builds fine.
  • dfletchdfletch Posts: 165
    edited 2008-05-31 04:31
    Hi. Actually I started working on this again last week.

    Got tripped up on something (I forget exactly what ATM) last weekend and took a small break.

    Will be working more on it this weekend, hopefully a big new rev coming shortly.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • dfletchdfletch Posts: 165
    edited 2008-05-31 20:44
    OK I know exactly where I went wrong last week.

    So I'm implementing multiple passes. So when a function name or var or dat variable etc. is defined lower down in the file,
    the parser can still recognize it for what it is.

    To do this, we'll have a "name pass" where it only picks up the name and type of certain items. Then on a subsequent
    "code pass", those names are recognized and parser rules can expect a type of element explicitly.

    This keeps the parser nice and clean - we don't have to detect for example that someone put a CON variable in a postfix
    expression because the parser would simply not allow it - there's no rule that says it can happen.

    Now, that's all good in theory except I totally botched it in my first attempt. What I tried to do was make the lexer limit what
    tokens are sent into the parser depending on which pass we're doing. I don't know what I was thinking but it's completely
    backwards. The lexer should pass all tokens on every pass, and the parser should switch what action it takes depending
    on the current pass.

    So I'm chucking away a bunch of bad code and starting this rev pretty much from scratch. Well sorta - two changes I can
    keep. One is the ability to use a FILE pointer instead of stdin. The parser and lexer are both re-entrant now as well
    (meaning it's possible to recurse into it for OBJ support) and I can keep those changes too.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • dfletchdfletch Posts: 165
    edited 2008-06-02 08:12
    OK! Multi pass parsing is starting to work. On the first pass, I'm getting CNAMEs from the lexer.
    On the second pass, these come out as the appropriate token type like CONSTNAME etc. Only
    prob now is the grammar doesn't actually have rules to handle all these new types!

    I'm doing an interm commit now and will have a better working version tomorrow or so.

    On another front, Jasper_M volunteered in IRC to write code to emit Spin bytecodes. So when
    we're ready to concentrate on output, hopefully we'll just need to call Jasper's lovely functions smile.gif

    Chuck - I will need some help shortly implementing one other bit, perhaps you could help there.
    Constant expressions need to get evaluated. Each expression will be a tree node with an eval()
    function. Those eval()s will all need to be implemented, and this is where I can use a ton of help.
    I'm not sure how hard it will be to make this consistent on all platforms. Do we just assume that
    size of long is 32 bits for example? Is the AdditionExpression::eval() as simple as a+b? See, I'm
    already a bit lost smile.gif

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • dfletchdfletch Posts: 165
    edited 2008-06-02 08:18
    Darn! The reentrant option of flex seems to break on MacOSX.

    Sorry Mac guys I'll try to figure out a solution. What's weird though is the lexer and parser should not need
    to be regenerated unless someone did `make maintainer-clean.`. Weird.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • dfletchdfletch Posts: 165
    edited 2008-06-02 17:24
    Ok I figured out a fix for Mac users this morning.

    You just can't use the flex that comes with OSX, sorry. Fortunately it's really easy to upgrade.

    Download latest version: prdownloads.sourceforge.net/flex/flex-2.5.35.tar.gz?download

    In a terminal:

    $ tar xvzf flex-2.5.35.tar.gz
    $ cd flex-2.5.35
    $ ./configure --prefix=/usr
    $ make
    $ sudo make install
    
    



    After this, the reentrant option is recognized and build works normally.

    I'll put this info in the README eventually as well..

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler

    Post Edited (dfletch) : 6/2/2008 5:31:07 PM GMT
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-06-02 17:45
    My default flex is at 2.5.33. I do not see a build error, but I get a syntax error when I try to run spinc against the test program.

    --(chuck@cyclops-2)-(~/work/cvs/spinparser)--
    --(0)> spinc test/simpletest.spin
    --------- NAME PASS ------------
    --------- CODE PASS ------------
    ERROR: syntax error
    
    



    How do I turn on debug?


    I tried downloading 2.5.35. Configure works. Make fails:

    --(2)> make
    make  all-recursive
    Making all in .
    if gcc -DHAVE_CONFIG_H -I. -I. -I.  -DLOCALEDIR=\"/usr/share/locale\" -I./intl   -g -O2 -MT ccl.o -MD -MP -MF ".deps/ccl.Tpo" -c -o ccl.o ccl.c; \
        then mv -f ".deps/ccl.Tpo" ".deps/ccl.Po"; else rm -f ".deps/ccl.Tpo"; exit 1; fi
    In file included from /usr/include/netinet/in.h:85,
                     from flexdef.h:79,
                     from ccl.c:34:
    /usr/include/sys/socket.h:97: error: two or more data types in declaration specifiers
    make: *** [noparse][[/noparse]ccl.o] Error 1
    make: *** [noparse][[/noparse]all-recursive] Error 1
    make: *** [noparse][[/noparse]all] Error 2
    
    
  • Mike GreenMike Green Posts: 23,101
    edited 2008-06-02 17:50
    Chuck,
    Flex 2.5.35 configures and makes without errors for me. I have MacOS 10.5.3. On the other hand, I'm having problems with cvs.
  • dfletchdfletch Posts: 165
    edited 2008-06-02 17:52
    Chuck, do this:

    $ export CXXFLAGS="-Wall -DDEBUG_LEXER -DDEBUG_PARSER
    $ make distclean
    $ ./configure
    $ make
    
    



    It's quiet unless you define DEBUG_LEXER and DEBUG_PARSER.

    Yes syntax error is expected. That's the prob on pass 2 that I described a couple posts ago. Update tonight.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-06-02 17:53
    I am on MacOSX 10.5.3 also. What CVS error are you getting?
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-06-02 18:03
    Maybe I do not need the new flex. 10.5.33 may be good enough?

    I defined the flags and rebuilt as you instructed. Now I get lots of messages, ending in the CODE pass:

    --------- CODE PASS ------------
    token (no token): (comment)
    token T_LINE_END: (newline)
    type Constant: /* nothing (optional) */
    type Constants: Constant
    type CommaOrNewline: T_LINE_END
    token (no token): (comment)
    token T_LINE_END: (newline)
    type Constant: /* nothing (optional) */
    type Constants: Constants CommaOrNewline Constant
    type CommaOrNewline: T_LINE_END
    token (no token): (comment)
    token T_LINE_END: (newline)
    type Constant: /* nothing (optional) */
    type Constants: Constants CommaOrNewline Constant
    type CommaOrNewline: T_LINE_END
    token (no token): (comment)
    token T_LINE_END: (newline)
    type Constant: /* nothing (optional) */
    type Constants: Constants CommaOrNewline Constant
    type CommaOrNewline: T_LINE_END
    token T_LINE_END: (newline)
    type Constant: /* nothing (optional) */
    type Constants: Constants CommaOrNewline Constant
    type CommaOrNewline: T_LINE_END
    token (no token): (comment)
    token T_LINE_END: (newline)
    type Constant: /* nothing (optional) */
    type Constants: Constants CommaOrNewline Constant
    type CommaOrNewline: T_LINE_END
    token CONSTNAME: A
    type Constant: /* nothing (optional) */
    type Constants: Constants CommaOrNewline Constant
    type Spin: Constants
    ERROR: syntax error
    --(chuck@cyclops-2)-(~/work/cvs/spinparser)--
    --(0)> 
    
    



    So I guess I am current now.
  • dfletchdfletch Posts: 165
    edited 2008-06-02 18:06
    Yep, that is exactly the expected output currently.

    Each "token" is a lexical token coming from spinlex.lpp. Each "type" is a rule that matched in the grammar in spinparse.ypp.

    You can see these in the debug rules inside those files.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-06-02 19:12
    Although I am an old programmer, I have never worked on a compiler, so FLEX and LEX and YACC, and BISON, and friends are new to me. I am an old IBM Mainframe Assembler programmer, though I have worked some in C++, and many other languages.

    I still have a day job, but I can help at night if you give me the name of the subroutines you need, the input format, and the output desired. And if you can point me to some concise Doc to read, it might help. [noparse]:)[/noparse] -Chuck-
  • dfletchdfletch Posts: 165
    edited 2008-06-02 19:23
    Chuck: I'm hoping to have a set of node objects (like the AdditionExpression I mentioned earlier) that the parser
    will create in the next couple of days. Like I said before, the eval() will need to be implemented on these. It won't
    need any specific knowledge of how the parser itself works.

    I haven't figured out the API exactly yet, but it will possibly look something like this:

    pointer<Expression> AdditionExpression::eval(void) {
      pointer<Expression> retval = new Expression;
      pointer<Expression> a = getChild(0).eval();
      pointer<Expression> b = getChild(1).eval();
      retval->setIntValue(a->getIntValue() + b->getIntValue());
      return retval;
    }
    
    



    When I'm ready for help in a day or two, I'll fill out a couple of the easy ones to help get you started.
    This code is totally just an example of what it will be like.

    Cheers,

    --fletch

    ▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔▔
    Join us in the Un-Official Propeller IRC channel: irc.freenode.net #propeller
    Newbies, oldies, programmers, math professors, and everyone in-between welcome!
    Propeller IRC howto
    spinc - open source Spin compiler
  • Chuck RiceChuck Rice Posts: 210
    edited 2008-07-08 13:36
    Ping. Fletch, any progress?
Sign In or Register to comment.