mirror of
https://github.com/hanzoai/expr.git
synced 2026-09-24 16:58:58 +00:00
* convert source to a struct and fix minor issue displaying error * lexer: add byte and char pos * improve parser to use string instead of []rune * add lexer benchmarks * make lexer work as an iterator * make parser use the new iterator API in lexer * allow reusing the parser * cleanup code * add parser benchmarks
21 lines
384 B
Go
21 lines
384 B
Go
package parser
|
|
|
|
import "testing"
|
|
|
|
func BenchmarkParser(b *testing.B) {
|
|
const source = `
|
|
/*
|
|
Showing worst case scenario
|
|
*/
|
|
let value = trim("contains escapes \n\"\\ \U0001F600 and non ASCII ñ"); // inline comment
|
|
len(value) == 0x2A
|
|
// let's introduce an error too
|
|
whatever
|
|
`
|
|
b.ReportAllocs()
|
|
p := new(Parser)
|
|
for i := 0; i < b.N; i++ {
|
|
p.Parse(source, nil)
|
|
}
|
|
}
|