Commit 7dc25960 authored by Rob Pike's avatar Rob Pike

cmd/yacc: remove Makefile and build expr using go generate

It now serves as an example for go generate as well as for yacc.

NOTE: Depends on go generate, which is not yet checked in.
This is a proof of concept of the approach.
That is https://golang.org/cl/125580044.

LGTM=rsc
R=rsc
CC=golang-codereviews
https://golang.org/cl/125620044
parent 41fc05d0
# Copyright 2009 The Go Authors. All rights reserved.
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
TARG=expr$(shell go env GOEXE)
$(TARG): yacc.go expr.y
go run yacc.go -p expr expr.y
go build -o $(TARG) y.go
clean:
rm -f y.go y.output $(TARG)
This directory contains a simple program demonstrating how to use
the Go version of yacc.
To build it:
$ go generate
$ go build
or
$ go generate
$ go run expr.go
The file main.go contains the "go generate" command to run yacc to
create expr.go from expr.y. It also has the package doc comment,
as godoc will not scan the .y file.
The actual implementation is in expr.y.
The program is not installed in the binary distributions of Go.
......@@ -11,11 +11,6 @@
%{
// This tag will be copied to the generated file to prevent that file
// confusing a future build.
// +build ignore
package main
import (
......
// Copyright 2014 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
// This file holds the go generate command to run yacc on the grammar in expr.y.
// To build expr:
// % go generate
// % go build
//go:generate -command yacc go tool yacc
//go:generate yacc -o expr.go -p "expr" expr.y
// Expr is a simple expression evaluator that serves as a working example of
// how to use Go's yacc implemenation.
package main
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment