php-parser/main.go

42 lines
508 B
Go
Raw Normal View History

2017-12-01 13:29:23 +00:00
package main
import (
"bytes"
"os"
2017-12-01 14:04:53 +00:00
"unicode"
2017-12-01 13:29:23 +00:00
)
const src = `
<?php
namespace Test;
/**
* Class foo
*/
class foo
{
}
`
func main() {
yyDebug = 0
yyErrorVerbose = true
l := newLexer(bytes.NewBufferString(src), os.Stdout, "file.name")
yyParse(l)
}
2017-12-01 14:04:53 +00:00
func rune2Class(r rune) int {
if r >= 0 && r < 0x80 { // Keep ASCII as it is.
return int(r)
}
if unicode.IsLetter(r) {
return classUnicodeLeter
}
if unicode.IsDigit(r) {
return classUnicodeDigit
}
// return classOther
return -1
}