Talk:Lexer hack

Page contents not supported in other languages.
From Wikipedia, the free encyclopedia

(A) (*B) Not Unambigous[edit]

The article states that this is an unambigous cast, but it's not. If A is a function it's a function call. Example:

int A(int _b) {
    return _b;
}

int main(void) {
    int  C = 134;
    int *B = &C;
    int D = (A) (*B);  // The function call

    printf("%d", D);
}

Untitled[edit]

This article provides no explanations for its technical terms nor are the terms linked to other articles to provide any explanation. Please expand and make accessible for the majority of readers. Velela 17:45, 21 May 2006 (UTC)[reply]

I've added a bit to help: [1]
  • a brief explanation of the lexing-parsing process to provide some context of where this occurs in compilation
  • an example to bring this down from the technical level of C language implementers to C language programmers
So it's still technical, but I hope that readers with a basic understanding of C should be able to get the idea. --Mrwojo (talk) 04:11, 27 November 2008 (UTC)[reply]

Clang[edit]

According to the reference given (Eli Bendersky's website), clang can get rid of 'the lexer hack' because it is using a recursive / backtracking parser (which allows it to try different interpretations, and tag lexical items with semantic info). Please explain how this supports the claim that clang is using a "non-reference lexical grammar".

Using the example given in this article, if using a LALR parser, it would be impossible to reinterpret "var*(var_or_type)*var" as "var*((type)*var)" instead of "(var*(var))*var" without throwing away the whole syntax tree. — Preceding unsigned comment added by 2A02:2F0E:D2A1:4B00:B165:DC79:CC95:1986 (talk) 23:17, 31 January 2017 (UTC)[reply]

I believe clang uses an equivalent of GLR parsing technique. Lightness1024 (talk) 09:42, 7 February 2020 (UTC)[reply]