exclude gocode from parser.y
This commit is contained in:
		
							parent
							
								
									f973ed31f5
								
							
						
					
					
						commit
						4318df3473
					
				
							
								
								
									
										26
									
								
								main.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										26
									
								
								main.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,26 @@ | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"os" | ||||
| ) | ||||
| 
 | ||||
| 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) | ||||
| } | ||||
							
								
								
									
										44
									
								
								node.go
									
									
									
									
									
										Normal file
									
								
							
							
						
						
									
										44
									
								
								node.go
									
									
									
									
									
										Normal file
									
								
							| @ -0,0 +1,44 @@ | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
| 	"bytes" | ||||
| 	"fmt" | ||||
| 	"io" | ||||
| ) | ||||
| 
 | ||||
| type node struct { | ||||
| 	name       string | ||||
| 	children   []node | ||||
| 	attributes map[string]string | ||||
| } | ||||
| 
 | ||||
| func (n node) String() string { | ||||
| 	buf := new(bytes.Buffer) | ||||
| 	n.print(buf, " ") | ||||
| 	return buf.String() | ||||
| } | ||||
| 
 | ||||
| func (n node) print(out io.Writer, indent string) { | ||||
| 	if len(n.attributes) > 0 { | ||||
| 		fmt.Fprintf(out, "\n%v%v %s", indent, n.name, n.attributes) | ||||
| 	} else { | ||||
| 		fmt.Fprintf(out, "\n%v%v", indent, n.name) | ||||
| 	} | ||||
| 	for _, nn := range n.children { | ||||
| 		nn.print(out, indent+"  ") | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| func Node(name string) node { | ||||
| 	return node{name: name, attributes: make(map[string]string)} | ||||
| } | ||||
| 
 | ||||
| func (n node) append(nn ...node) node { | ||||
| 	n.children = append(n.children, nn...) | ||||
| 	return n | ||||
| } | ||||
| 
 | ||||
| func (n node) attribute(key string, value string) node { | ||||
| 	n.attributes[key] = value | ||||
| 	return n | ||||
| } | ||||
							
								
								
									
										61
									
								
								parser.y
									
									
									
									
									
								
							
							
						
						
									
										61
									
								
								parser.y
									
									
									
									
									
								
							| @ -2,49 +2,9 @@ | ||||
| package main | ||||
| 
 | ||||
| import ( | ||||
|   "bytes" | ||||
|   "fmt" | ||||
|   "os" | ||||
|   "io" | ||||
| ) | ||||
| 
 | ||||
| type node struct { | ||||
|   name string | ||||
|   children []node | ||||
|   attributes map[string]string | ||||
| } | ||||
| 
 | ||||
| func (n node) String() string { | ||||
|   buf := new(bytes.Buffer) | ||||
|   n.print(buf, " ") | ||||
|   return buf.String() | ||||
| } | ||||
| 
 | ||||
| func (n node) print(out io.Writer, indent string) { | ||||
|   if (len(n.attributes) > 0) { | ||||
|     fmt.Fprintf(out, "\n%v%v %s", indent, n.name, n.attributes) | ||||
|   } else { | ||||
|     fmt.Fprintf(out, "\n%v%v", indent, n.name) | ||||
|   } | ||||
|   for _, nn := range n.children {  | ||||
|     nn.print(out, indent + "  ")  | ||||
|   } | ||||
| } | ||||
| 
 | ||||
| func Node(name string) node {  | ||||
|   return node{name: name, attributes: make(map[string]string)}  | ||||
| } | ||||
| 
 | ||||
| func (n node) append(nn...node) node { | ||||
|   n.children = append(n.children, nn...) | ||||
|   return n  | ||||
| } | ||||
| 
 | ||||
| func (n node) attribute(key string, value string) node { | ||||
|   n.attributes[key] = value | ||||
|   return n  | ||||
| } | ||||
| 
 | ||||
| %} | ||||
| 
 | ||||
| %union{ | ||||
| @ -1201,24 +1161,3 @@ isset_variable: | ||||
| ///////////////////////////////////////////////////////////////////////// | ||||
| 
 | ||||
| %% | ||||
| 
 | ||||
| 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) | ||||
| } | ||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user