• Lucid Dreaming - Dream Views




    Results 1 to 12 of 12

    Hybrid View

    1. #1
      What's up <span class='glow_006400'>[SomeGuy]</span>'s Avatar
      Join Date
      Nov 2007
      LD Count
      About 1
      Gender
      Location
      Tmux on Debian
      Posts
      2,862
      Likes
      130
      DJ Entries
      4

      Javascript Stuck-tion, grr.

      Well, once again, I'm back here asking my cyber-homies for some help.
      Basically, I'm pretty much making a "word replacer". I'm writing a new browser script, and I'm creating a JS compiler. What the compiler will do is scan through a textarea and replace my script with JS. SO, after the user types in his program and clicks Compile (a button), it will document.write the program in JS. Kinda confusing?
      Here:
      Code:
      Step 1: I type in my program in a text area:
        EX:
        <$ a = 8
        <$ b = 4
        [?echo<< a + b;
        It makes 2 variables, and writes the sum of them.
      
      Step 2: I click compile
        JS scans through my textarea and replaces <$ with "var" and [?echo<<    with "document.write(".
      
      Step 3: It writes to the screen the program compiled into JS.
      Get it?

      Hey guys, I'm back. Feels good man
      ---------------------------------------------------
      WTF|Jesus lul
      spam removed

    2. #2
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      You'd have to make a grammar first, java has one, I don't remember what it's called. You have to make sure that your grammar is LL(1) though. Java also has a tree builder, that one I know, it's called JTB. You can use that to make your concrete parse tree.

    3. #3
      What's up <span class='glow_006400'>[SomeGuy]</span>'s Avatar
      Join Date
      Nov 2007
      LD Count
      About 1
      Gender
      Location
      Tmux on Debian
      Posts
      2,862
      Likes
      130
      DJ Entries
      4
      I'm not using java though...

      Javascript.

      Hey guys, I'm back. Feels good man
      ---------------------------------------------------
      WTF|Jesus lul
      spam removed

    4. #4
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      I thought you were trying to convert to Javascript You could do that with java. As far as I know there is no grammars for javascript.

    5. #5
      Member Identity X's Avatar
      Join Date
      Mar 2004
      Gender
      Posts
      1,529
      Likes
      7
      http://www.tizag.com/javascriptT/jav...ng-replace.php

      I used that magic thing called Google.

      Anyway, this program sounds a little useless, and by that I mean totally useless. Why not write in JavaScript in the first place? And what twisted excuse for syntax is [?echo <<? Besides, a series of replace statements != a compiler.

      ninja9578: I used JavaCC and JJTree last time I wrote a compiler in Java, never heard of JTB though.

      Quote Originally Posted by ninja9578 View Post
      I thought you were trying to convert to Javascript You could do that with java. As far as I know there is no grammars for javascript.
      Why would JavaScript/ECMAScript/JScript etc. (they are all slightly different things) not have grammars? That would be unfair on the browser writer, would it not? Almost every major language since Algol has had an (E)BNF grammar, with a few notable exceptions such as, I think, pre-ANSI C. As such the Java grammar which name you cannot recall is likely called the "Grammar of the Java Programming Language". They don't give these things fancy names, you know.

      AFAIK he's writing it in JavaScript and the output will be in JavaScript. For what it is (a long series of replace statements), JS is a reasonable choice, a good one even given it's mature regex support, given that it is a Web application.
      Last edited by Identity X; 08-26-2008 at 07:20 PM.

    6. #6
      Banned
      Join Date
      Apr 2007
      Location
      Out Chasing Rabbits
      Posts
      15,193
      Likes
      935
      JavaCC! Thanks, I couldn't remember the name of it. This is JTB

    7. #7
      Member Identity X's Avatar
      Join Date
      Mar 2004
      Gender
      Posts
      1,529
      Likes
      7
      Quote Originally Posted by ninja9578 View Post
      JavaCC! Thanks, I couldn't remember the name of it. This is JTB
      Ah. JavaCC is in no way a grammar. It's a compiler compiler. Hence 'CC'.

    Bookmarks

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •