kotlinx / ast

Generic AST parsing library for kotlin multiplatform
Apache License 2.0
316 stars 22 forks source link

Why column is called row? #77

Open matkoniecz opened 2 years ago

matkoniecz commented 2 years ago

Why column is called row? It appears in what astInfoOrNull returns.

Is it some slang/peculiarity in among parser writers? Or some typo? Or maybe I am mistaken about how English works?

I expected lines and columns, not lines and rows. And would expect row to be synonym of line, not of column.


BTW, https://github.com/kotlinx/ast/issues/21 seems implemented and looks like it can be closed


wider explanation if above is unclear

With

private fun Ast.root(): Ast? {
    var returned: Ast? = null
    this.summary(false).onSuccess { returned = it.firstOrNull() }
    return returned
}

one may extract line and column with following code

private fun Ast.humanReadableDescription(): String {
    val current = this.root() ?: return "NULL"
    return "${current.astInfoOrNull!!.start.line}  ${current.astInfoOrNull!!.start.row}"
}

(I know that I can also use description - but that is not allowing me to format things like I want, in this case it is intended as the first step toward clear matching with parsed text)

I have just one question - why column is called row?