package rebelsky.compiler.pascal; import java.util.Vector; import rebelsky.compiler.parser.Nonterminal; /** * A collection of constants that define the nonterminals in Pascal. * (Not yet complete.) * * @author Samuel A. Rebelsky * @version 0.6 of November 2002 */ public class PascalNonterminals { // +-----------+----------------------------------------------------------- // | Constants | // +-----------+ /** * An addition operator, such as plus or minus. */ public static final Nonterminal ADDING_OPERATOR = new Nonterminal("adding_operator"); /** * An assignment statement. */ public static final Nonterminal ASSIGNMENT = new Nonterminal("assignment"); /** * A list of assignment statements. Not used in the standard * Pascal grammar, but useful for some variant grammars that * I like to create. * * ::= TSEMI { TSEMI } */ public static final Nonterminal ASSIGNMENT_LIST = new Nonterminal("assignment_list"); /** * A block of code. In Pascal, lots of declarations followed by * a group of statements enclosed in begin and end. */ public static final Nonterminal BLOCK = new Nonterminal("block"); /** * A Boolean expression. Not part of standard Pascal, but useful * in a number of variants. */ public static final Nonterminal BOOLEAN_EXPRESSION = new Nonterminal("boolean_expression"); /** * A compound statment (a list of statements enclosed in a begin/end pair). */ public static final Nonterminal COMPOUND_STATEMENT = new Nonterminal("compound_statement"); /* * A conditional statement (e.g., an if statement). */ public static final Nonterminal CONDITIONAL = new Nonterminal("conditional"); /** * A constant. */ public static final Nonterminal CONSTANT = new Nonterminal("constant"); /** * A single constant definition. */ public static final Nonterminal CONSTANT_DEFINITION = new Nonterminal("constant_definition"); /** * Zero or more constant definitions. */ public static final Nonterminal CONSTANT_DEFINITIONS = new Nonterminal("constant_definitions"); /** * The famous expression. */ public static final Nonterminal EXPRESSION = new Nonterminal("expression"); /** * Part of an expression. Factors contain no unparenthesized * addition and multiplication symbols. */ public static final Nonterminal FACTOR = new Nonterminal("factor"); /** * An identifier that names a file. Used in the program heading. */ public static final Nonterminal FILE_IDENTIFIER = new Nonterminal("file_identifier"); /** * A call to a function. */ public static final Nonterminal FUNCTION_CALL = new Nonterminal("function_call"); /** * The declaration of one function. Typically gives parameters (with * types, return value, local variables, and body. */ public static final Nonterminal FUNCTION_DECLARATION = new Nonterminal("function_declaration"); /** * A list of function declarations. Not standard Pascal, but useful * in some variant languages. */ public static final Nonterminal FUNCTION_DECLARATIONS = new Nonterminal("function_declarations"); /** * A non-empty list of identifiers. */ public static final Nonterminal IDENTIFIER_LIST = new Nonterminal("identifier_list"); /** * A label, typically used as the destination of a (blech) goto * statement. */ public static final Nonterminal LABEL = new Nonterminal("label"); /** * The declaration of zero or more labels that are to be used * within a block. */ public static final Nonterminal LABEL_DECLARATION = new Nonterminal("label_declaration"); /** * An operator with the precedence of multiplication, such as * multiplication, division, or modulus. */ public static final Nonterminal MULTIPLYING_OPERATOR = new Nonterminal("multiplying_operator"); /** * A call to a procedure. Not to be confused with a function call * or with a procedure declaration. */ public static final Nonterminal PROCEDURE_CALL = new Nonterminal("procedure_call"); /** * A complete program. Typically the start symbol of the grammar. */ public static final Nonterminal PROGRAM = new Nonterminal("program"); /** * The heading of a program. Gives name, input, and output. */ public static final Nonterminal PROGRAM_HEADING = new Nonterminal("program_heading"); /** * Relational operators, used for comparing values. */ public static final Nonterminal RELATIONAL_OPERATOR = new Nonterminal("relational_opeator"); /** * A statement. */ public static final Nonterminal STATEMENT = new Nonterminal("statement"); /** * Part of an expression. Terms are expression with no unparenthesized * additive operations. */ public static final Nonterminal TERM = new Nonterminal("term"); /** * The name of a type. */ public static final Nonterminal TYPE_IDENTIFIER = new Nonterminal("type_identifier"); /** * A non-negative number. */ public static final Nonterminal UNSIGNED_NUMBER = new Nonterminal("unsigned_number"); /** * A variable (something that can be assigned to). */ public static final Nonterminal VARIABLE = new Nonterminal("variable"); /** * Declare the type of one or more variables. */ public static final Nonterminal VARIABLE_DECLARATION = new Nonterminal("variable_declaration"); /** * Zero or more variable declarations. */ public static final Nonterminal VARIABLE_DECLARATIONS = new Nonterminal("variable_declarations"); /** * A while loop. */ public static final Nonterminal WHILE_LOOP = new Nonterminal("while_loop"); } // class PascalNonterminals