Giter Site home page Giter Site logo

Comments (4)

roblourens avatar roblourens commented on September 1, 2024 1

Honestly I'm not sure what else we had in mind. Would have to look back at old notes.

Have you considered also making escape characters like \n its own token appearing as a children node in a string?

Probably would not parse it at that granularity unless there was a good reason for it.

from tolerant-php-parser.

PythooonUser avatar PythooonUser commented on September 1, 2024

Hey,

here in #11 and in #168 you talk about that strings and template strings are still not implemented perfectly. Can you iterate on what exactly is still missing or not working?

I had a look at the parse output of e.g.

<?php "Hello $world";

Which gives

{
    "SourceFileNode": {
        "statementList": [
            [...]
            {
                "ExpressionStatement": {
                    "expression": {
                        "StringLiteral": {
                            "startQuote": {
                                "kind": "DoubleQuoteToken",
                                "fullStart": 6,
                                "start": 6,
                                "length": 1
                            },
                            "children": [
                                {
                                    "kind": "EncapsedAndWhitespace",
                                    "fullStart": 7,
                                    "start": 7,
                                    "length": 6
                                },
                                {
                                    "Variable": {
                                        "dollar": null,
                                        "name": {
                                            "kind": "VariableName",
                                            "fullStart": 13,
                                            "start": 13,
                                            "length": 6
                                        }
                                    }
                                }
                            ],
                            "endQuote": {
                                "kind": "DoubleQuoteToken",
                                "fullStart": 19,
                                "start": 19,
                                "length": 1
                            }
                        }
                    },
                    "semicolon": {
                        "kind": "SemicolonToken",
                        "fullStart": 20,
                        "start": 20,
                        "length": 1
                    }
                }
            }
        ]
        [...]
    }
}

And it returns an instance of StringLiteral which is essentially a non-delimited list of whitespace/characters and expression nodes. That sounds good to me and seems to be flexible enough.

Have you considered also making escape characters like \n its own token appearing as a children node in a string? Could that be helpful? I know that this distinction is made in language grammars (syntax highlighting) at least.

Cheers

from tolerant-php-parser.

PythooonUser avatar PythooonUser commented on September 1, 2024

Yes, I see. The current implementation seems to be in a good state :)

from tolerant-php-parser.

roblourens avatar roblourens commented on September 1, 2024

Thanks for taking a look though. I will close this unless there is a reason to reopen it.

from tolerant-php-parser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.