I have defined a StreamLanguage and I would like it to match a multi-line block comment in the following format: /* my comment another line */
The token stream is single line, so I would like to match the first part of the comment and hold a value somewhere indicating that the comment has started and check for a match. Is there a straight-forward way to do this?
My current code matches only single line:
import { StreamLanguage } from '@codemirror/language'
const lang = StreamLanguage.define({
token(stream, state) {
if (stream.eatSpace()) return null
if (stream.match(/\/\*.*?(\*\/|$)/)) return 'blockComment'
stream.next()
return 'literal'
},
})
Thank you for the resource!
But the issue is that the stream only contains one line, but not the whole text, so I am wondering, if there a way to pass some metadata while parsing next line.