[HN Gopher] Ungrammar
       ___________________________________________________________________
        
       Ungrammar
        
       Author : todsacerdoti
       Score  : 134 points
       Date   : 2020-10-24 09:55 UTC (13 hours ago)
        
 (HTM) web link (rust-analyzer.github.io)
 (TXT) w3m dump (rust-analyzer.github.io)
        
       | PaulHoule wrote:
       | ... that is, is a semantic as opposed to syntactic model?
        
       | neolog wrote:
       | Can someone ELI5? Is it just a parser for Rust concrete syntax
       | tree?
        
         | UncleEntity wrote:
         | It's a generator for the parse tree nodes which the parser uses
         | to construct a concrete syntax tree.
        
         | octoberfranklin wrote:
         | AFAICT it's not even a parser:                  In rust-
         | analyzer, it is paired with a hand-written parser.
         | 
         | I think it's just a convention for how to represent concrete
         | syntax tress as Rust abstract datatypes.
        
       | auggierose wrote:
       | Very interesting. I am actually working for a few days now on
       | something very related: Generate syntax tree data structures (in
       | Swift) from a grammar (which is the actual grammar used for
       | parsing). What I found very useful is to distinguish between
       | hidden, auxiliary and visible symbols. Hidden symbols don't
       | appear in the tree, visible symbols appear as normal, and for
       | auxiliary symbols only their children appear in the syntax tree.
       | Seems to work very nicely so far. This way, left oder right
       | recursion for example doesn't matter if your recursion symbol is
       | auxiliary, because it will just be flattened into a list anyway.
       | Therefore I can use regular expressions in a grammar by
       | desugaring them via auxiliary symbols in the usual way via
       | context-free rules, and have a sensible syntax tree generated for
       | that.
        
         | barrkel wrote:
         | Left or right recursion makes a semantic difference for non-
         | associative operators like subtraction.
        
           | auggierose wrote:
           | In those cases I'd suggest you don't make the corresponding
           | symbol auxiliary.
        
       | andrewmcwatters wrote:
       | Is it possible to take some extended BNF and standard nonterminal
       | names (stat, funcname, etc.) then output some Hello, World!
       | example from it?
       | 
       | It would be really cool to just generate the look and feel of a
       | programming language just using extended BNF.
        
       | samatman wrote:
       | Cool project, really weird and offputting branding.
       | 
       | I'd call this a "concrete grammar", calling something that's a
       | grammar an "ungrammar" is cutesy. It feels lazy, like they
       | stopped at the first idea they had.
        
         | vmception wrote:
         | I didn't get that impression
        
       ___________________________________________________________________
       (page generated 2020-10-24 23:01 UTC)