KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > beaver > spec > Terminal


1 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2  * This file is part of Beaver Parser Generator. *
3  * Copyright (C) 2003,2004 Alexander Demenchuk <alder@softanvil.com>. *
4  * All rights reserved. *
5  * See the file "LICENSE" for the terms and conditions for copying, *
6  * distribution and modification of Beaver. *
7  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */

8
9 package beaver.spec;
10
11 /**
12  * Represents terminal symbols of the grammar.
13  */

14 public class Terminal extends GrammarSymbol
15 {
16     static public final class Associativity
17     {
18         static public final Associativity LEFT = new Associativity("LEFT");
19         static public final Associativity RIGHT = new Associativity("RIGHT");
20         static public final Associativity NONE = new Associativity("NONE");
21     
22         private final String JavaDoc name;
23     
24         private Associativity(String JavaDoc name)
25         {
26             this.name = name;
27         }
28     
29         public String JavaDoc toString()
30         {
31             return name;
32         }
33     }
34
35     /** Precedence if defined (0 otherwise) */
36     public int prec;
37
38     /** Associativity if predecence is defined */
39     public Associativity assoc;
40
41     Terminal(String JavaDoc name)
42     {
43         super(name);
44     }
45
46     Terminal(String JavaDoc name, int prec, Associativity type)
47     {
48         super(name);
49         setPrecedence(prec, type);
50     }
51     
52     public void setPrecedence(int value, Associativity type)
53     {
54         prec = value;
55         assoc = type;
56     }
57 }
58
Popular Tags