Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Heck yeah! Free insight

Heck yeah! Free insight

Scheduled Pinned Locked Moved The Lounge
comai-codingtutorial
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • honey the codewitchH Offline
    honey the codewitchH Offline
    honey the codewitch
    wrote on last edited by
    #1

    I have a parser generator called Parsley[^] which I have not updated in a while. One of the neat things it can do is link several grammars** into several different parsers, and then link the different parsers it generates together so they can use each other to perform sub-parses. There are a number of advantages to this, including the fact that you can disambiguate grammar constructs by factoring them out over multiple grammars - since the parsers each have their own parse table, you won't have duplicate entries which causing ambiguity. But I just realized I could parallelize the code generation for it too wherein each different grammar crunching task runs its own CPU bound operation to create the parse tables. And it's easy. ** a grammar is a document that tells the parser how to parse something. Usually it's written in a variant of BNF or EBNF. I came up with all of this during a conversation about schizoaffective disorder. My mind is really funny sometimes. I think it helped that I've been doing so much async stuff lately.

    Real programmers use butterflies

    M 1 Reply Last reply
    0
    • honey the codewitchH honey the codewitch

      I have a parser generator called Parsley[^] which I have not updated in a while. One of the neat things it can do is link several grammars** into several different parsers, and then link the different parsers it generates together so they can use each other to perform sub-parses. There are a number of advantages to this, including the fact that you can disambiguate grammar constructs by factoring them out over multiple grammars - since the parsers each have their own parse table, you won't have duplicate entries which causing ambiguity. But I just realized I could parallelize the code generation for it too wherein each different grammar crunching task runs its own CPU bound operation to create the parse tables. And it's easy. ** a grammar is a document that tells the parser how to parse something. Usually it's written in a variant of BNF or EBNF. I came up with all of this during a conversation about schizoaffective disorder. My mind is really funny sometimes. I think it helped that I've been doing so much async stuff lately.

      Real programmers use butterflies

      M Offline
      M Offline
      Member 12982558
      wrote on last edited by
      #2

      Interesting Can you elaborate a little on how to decide when to activate one (or more) of the (sub?) parsers? Of course you can activate a number of parsers simaultaneuously on a given input (sub)string Long, long time ago in one of the compilers we used a mix of bottom up and top down (recursive descent) parsers, is that (more or less) similar to what you are describing?

      honey the codewitchH 1 Reply Last reply
      0
      • M Member 12982558

        Interesting Can you elaborate a little on how to decide when to activate one (or more) of the (sub?) parsers? Of course you can activate a number of parsers simaultaneuously on a given input (sub)string Long, long time ago in one of the compilers we used a mix of bottom up and top down (recursive descent) parsers, is that (more or less) similar to what you are describing?

        honey the codewitchH Offline
        honey the codewitchH Offline
        honey the codewitch
        wrote on last edited by
        #3

        Member 12982558 wrote:

        Can you elaborate a little on how to decide when to activate one (or more) of the (sub?) parsers?

        The share a symbol table, so when you reference a symbol from a foreign grammar it invokes the subparser like here's an excerpt of a grammar i wrote:

        / SlangStatement.xbnf
        // This is the XBNF spec for Slang Statements (gplex version - unicode enabled)
        // Slang is a CodeDOM compliant subset of C#
        @import "SlangExpression.xbnf";
        // Statements

        // we use this with our skipped lists to get comments on to relevant nodes
        Comments; // { lineComment | blockComment }
        Directives; // { directive }

        VariableDeclarationStatement= varType Identifier "=" Expression ";" | Type Identifier [ "=" Expression ] ";";

        Here I bolded the import line which will cause this parser to reference the SlangExpression parser generated by SlangExpression.xbnf (a grammar like this one) I also bolded all the foreign symbols. These invoke a subparse when encountered

        Member 12982558 wrote:

        Of course you can activate a number of parsers simaultaneuously on a given input (sub)string

        I think maybe I wasn't clear about where the parallelization opportunity is. It's in the generation of the parser source code from the grammars. That's what I can make parallel. It means faster dev cycles for the parser because it doesn't take as long to generate. ETA: but i could parallelize the backtracking. Not sure if I would gain or lose perf doing that though

        Member 12982558 wrote:

        Long, long time ago in one of the compilers we used a mix of bottom up and top down (recursive descent) parsers, is that (more or less) similar to what you are describing?

        It sounds like it. Here's I'm assuming your parsers call other parsers like the top-down delegates to the bottom-up for some things. If so, this is like that except it's all top down, not several different algorithms.

        Real programmers use butterflies

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups