News for hackers. Stuff that matters.
Re:What if Git worked with programming languages? by ffwacom on Monday September 27, 2021 @04:34PM (#28675652)
> Not every programming language's grammar maps to an abstract syntax tree

Are there some examples of this?

Re:What if Git worked with programming languages? by simcop2387 on Monday September 27, 2021 @04:47PM (#28675803)
Perl, this is because you can't actually properly parse Perl without also running Perl code at the same time.
Re:What if Git worked with programming languages? by rowanG077 on Tuesday September 28, 2021 @07:01AM (#28681355)
That you can't properly parse Perl without also running Perl doesn't mean it doesn't have an AST. I don't know about Perl so it could very well be that it does not have an AST but your argument doesn't show it does not.
Re:What if Git worked with programming languages? by simcop2387 on Tuesday September 28, 2021 @07:51AM (#28681704)
Perl code changes how the parsing will be done, both by adding keywords, changing how many arguments the parser will look for, and even arbitrarily changing the language entirely with a source filter. It's largely that last bit that makes creating a consistent or coherent AST so impractical it may as well be impossible.
Re:What if Git worked with programming languages? by rurban on Tuesday September 28, 2021 @10:05PM (#28689520)
The AST contains code, but it's still an AST. Every AST contains code. Perl has a dynamic lexer, but still uses a static YACC grammar.
Re:What if Git worked with programming languages? by justinator on Monday September 27, 2021 @05:47PM (#28676445)
Re:What if Git worked with programming languages? by simcop2387 on Tuesday September 28, 2021 @07:49AM (#28681683)
PPI and PPR will parse most perl programs, but the moment you start doing stuff with prototypes or source filters they fail completely.
Re:What if Git worked with programming languages? by mumblemumble on Monday September 27, 2021 @04:52PM (#28675862)
Forth. You could certainly define a formal grammar for it and construct an AST, but it would be trivial and not very useful.