avancement planning

This commit is contained in:
2026-05-26 11:58:39 +02:00
parent 619a2b240a
commit 150b97cd2e
4892 changed files with 99214 additions and 429382 deletions
+37 -30
View File
@@ -20,6 +20,12 @@ function findLastWithPosition(tokens) {
}
}
function tokensToString(tokens, from, to) {
let result = ''
for (let i = from; i < to; i++) result += tokens[i][1]
return result
}
class Parser {
constructor(input) {
this.input = input
@@ -132,9 +138,10 @@ class Parser {
if (founded === 2) break
}
}
// If the token is a word, e.g. `!important`, `red` or any other valid property's value.
// Then we need to return the colon after that word token. [3] is the "end" colon of that word.
// And because we need it after that one we do +1 to get the next one.
// If the token is a word, e.g. `!important`, `red` or any other valid
// property's value. Then we need to return the colon after that word
// token. [3] is the "end" colon of that word. And because we need it
// after that one we do +1 to get the next one.
throw this.input.error(
'Missed semicolon',
token[0] === 'word' ? token[3] + 1 : token[2]
@@ -176,7 +183,7 @@ class Parser {
node.source.end.offset++
let text = token[1].slice(2, -2)
if (/^\s*$/.test(text)) {
if (!text.trim()) {
node.text = ''
node.raws.left = text
node.raws.right = ''
@@ -207,50 +214,50 @@ class Parser {
)
node.source.end.offset++
while (tokens[0][0] !== 'word') {
if (tokens.length === 1) this.unknownWord(tokens)
node.raws.before += tokens.shift()[1]
let start = 0
while (tokens[start][0] !== 'word') {
if (start === tokens.length - 1) this.unknownWord([tokens[start]])
start++
}
node.source.start = this.getPosition(tokens[0][2])
node.raws.before += tokensToString(tokens, 0, start)
node.source.start = this.getPosition(tokens[start][2])
node.prop = ''
while (tokens.length) {
let type = tokens[0][0]
let propStart = start
while (start < tokens.length) {
let type = tokens[start][0]
if (type === ':' || type === 'space' || type === 'comment') {
break
}
node.prop += tokens.shift()[1]
start++
}
node.prop = tokensToString(tokens, propStart, start)
node.raws.between = ''
let betweenStart = start
let token
while (tokens.length) {
token = tokens.shift()
if (token[0] === ':') {
node.raws.between += token[1]
break
} else {
if (token[0] === 'word' && /\w/.test(token[1])) {
this.unknownWord([token])
}
node.raws.between += token[1]
while (start < tokens.length) {
token = tokens[start]
start++
if (token[0] === ':') break
if (token[0] === 'word' && /\w/.test(token[1])) {
this.unknownWord([token])
}
}
node.raws.between = tokensToString(tokens, betweenStart, start)
if (node.prop[0] === '_' || node.prop[0] === '*') {
node.raws.before += node.prop[0]
node.prop = node.prop.slice(1)
}
let firstSpaces = []
let next
while (tokens.length) {
next = tokens[0][0]
let firstSpacesStart = start
while (start < tokens.length) {
let next = tokens[start][0]
if (next !== 'space' && next !== 'comment') break
firstSpaces.push(tokens.shift())
start++
}
let firstSpaces = tokens.slice(firstSpacesStart, start)
tokens = tokens.slice(start)
this.precheckMissedSemicolon(tokens)