php-parser/main.go
2017-12-01 16:04:53 +02:00

42 lines
508 B
Go

package main
import (
"bytes"
"os"
"unicode"
)
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)
}
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
}