colis-anr / morbig

A static parser for POSIX Shell
Other
190 stars 8 forks source link

Positions are still wrong #74

Open yurug opened 5 years ago

yurug commented 5 years ago

The column numbers of starting position are still wrong, as demonstrated by the following example:

true

which produces the following JSON for the word true:

"CmdName_Word",
                                      {
                                        "value": [
                                          "Word",
                                          "true",
                                          [ [ "WordName", "true" ] ]
                                        ],
                                        "position": {
                                          "start_p": {
                                            "pos_fname": "true.sh",
                                            "pos_lnum": 1,
                                            "pos_bol": 0,
                                            "pos_cnum": 4
                                          },
                                          "end_p": {
                                            "pos_fname": "true.sh",
                                            "pos_lnum": 2,
                                            "pos_bol": 5,
                                            "pos_cnum": 5
                                          }
                                        }
                                      }
Niols commented 4 years ago

This is, as of today, still the case. It has to do with the fact that Morbig, once it has delimited a token, only knows the position of the delimiter, and not the token itself. It would require a form of "position-aware" token buffer.