Are multiline comments possible with nex? I've been playing with nex quite a bit and I'm very impressed. However, I'm having trouble figuring out how to handle multiline comments. Can this been done with the nesting feature? I've tried but could not figure it out. Below is one thing I tired but I regex is greedy the nesting grabs the rest of the document.
/[0-9]+/ { println("INTEGER:", txt()) }
/[0-9]+\.[0-9]*/ { println("FLOAT:", txt()) }
/if|then|begin|end|procedure|function/
{ println( "KEYWORD:", txt()) }
/[a-z][a-z0-9]*/ { println( "ID:", txt()) }
/\+|-|\*|\// { println("OP:", txt()) }
/[ \t]+/ { /* eat up whitespace */ }
/\/\*.*|\n*\*\// < { println("BEG_MULTI:", txt()) }
/.*|\n*\*\// { println("BEG_COMMENT:", txt()) }
/\n/ { println("NEWLINE") }
> { println("END_COMMENT", txt()) }
/\n/ { println("NEWLINE") }
/./ { println("UNRECOGNIZED CHAR:", txt()) }
//
package main
import (
"os"
)
func main() {
lex := NewLexer(os.Stdin)
txt := func() string { return lex.Text() }
NN_FUN(lex)
}
Are multiline comments possible with nex? I've been playing with nex quite a bit and I'm very impressed. However, I'm having trouble figuring out how to handle multiline comments. Can this been done with the nesting feature? I've tried but could not figure it out. Below is one thing I tired but I regex is greedy the nesting grabs the rest of the document.