blob: dad7b5f215332c4c3a7387f614be3547ed4db106 [file] [log] [blame]
Todd Wang232d6492015-02-25 18:04:54 -08001#!/bin/bash
Jiri Simsad7616c92015-03-24 23:44:30 -07002# Copyright 2015 The Vanadium Authors. All rights reserved.
3# Use of this source code is governed by a BSD-style
4# license that can be found in the LICENSE file.
Todd Wang232d6492015-02-25 18:04:54 -08005
6# Generate the grammar.go source file, which contains the parser, by running
7# this shell script in the same directory, or by running go generate. This also
8# generates grammar.y.debug, which contains a list of all states produced for
9# the parser, and some stats.
10
11set -e
12
Jiri Simsad7616c92015-03-24 23:44:30 -070013go tool yacc -o grammar.y.tmp.go -v grammar.y.debug.tmp grammar.y
14gofmt -l -w grammar.y.tmp.go
Todd Wangb90b8de2015-03-31 20:04:13 -070015cat - grammar.y.tmp.go > grammar.y.go <<EOF
16// Copyright 2015 The Vanadium Authors. All rights reserved.
17// Use of this source code is governed by a BSD-style
18// license that can be found in the LICENSE file.
19
20EOF
Todd Wang232d6492015-02-25 18:04:54 -080021cat - grammar.y.debug.tmp > grammar.y.debug <<EOF
22***** PLEASE READ THIS! DO NOT DELETE THIS BLOCK! *****
23* The main reason this file has been generated and submitted is to try to ensure
24* we never submit changes that cause shift/reduce or reduce/reduce conflicts.
25* The Go yacc tool doesn't support the %expect directive, and will happily
26* generate a parser even if such conflicts exist; it's up to the developer
27* running the tool to notice that an error message is reported. The bottom of
28* this file contains stats, including the number of conflicts. If you're
29* reviewing a change make sure it says 0 conflicts.
30*
31* If you're updating the grammar, just cut-and-paste this message from the old
32* file to the new one, so that this comment block persists.
33***** PLEASE READ THIS! DO NOT DELETE THIS BLOCK! *****
34EOF
35
Jiri Simsad7616c92015-03-24 23:44:30 -070036rm grammar.y.debug.tmp grammar.y.tmp.go