42 lines
		
	
	
		
			508 B
		
	
	
	
		
			Go
		
	
	
	
	
	
			
		
		
	
	
			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
 | |
| }
 |