Although this manual covers all aspects of the CUP system, it is relatively brief, and assumes you have at least a little bit of knowledge of LR parsing. A working knowledge of YACC is also very helpful in understanding how CUP specifications work. A number of compiler construction textbooks (such as [2,3]) cover this material, and discuss the YACC system (which is quite similar to this one) as a specific example. In addition, Andrew Appel's Modern Compiler Implementation in Java textbook [4] uses and describes CUP in the context of compiler construction.
Using CUP involves creating a simple specification based on the grammar for which a parser is needed, along with construction of a scanner capable of breaking characters up into meaningful tokens (such as keywords, numbers, and special symbols).
As a simple example, consider a system for evaluating simple arithmetic expressions over integers. This system would read expressions from standard input (each terminated with a semicolon), evaluate them, and print the result on standard output. A grammar for the input to such a system might look like:
expr_list ::= expr_list expr_part | expr_part expr_part ::= expr ';' expr ::= expr '+' expr | expr '-' expr | expr '*' expr | expr '/' expr | expr '%' expr | '(' expr ')' | '-' expr | numberTo specify a parser based on this grammar, our first step is to identify and name the set of terminal symbols that will appear on input, and the set of non-terminal symbols. In this case, the non-terminals are:
expr_list, expr_part and expr .For terminal names we might choose:
SEMI, PLUS, MINUS, TIMES, DIVIDE, MOD, NUMBER, LPAREN, and RPARENThe experienced user will note a problem with the above grammar. It is ambiguous. An ambiguous grammar is a grammar which, given a certain input, can reduce the parts of the input in two different ways such as to give two different answers. Take the above grammar, for example. given the following input:
// CUP specification for a simple expression evaluator (no actions) import java_cup.runtime.*; /* Preliminaries to set up and use the scanner. */ init with {: scanner.init(); :}; scan with {: return scanner.next_token(); :}; /* Terminals (tokens returned by the scanner). */ terminal SEMI, PLUS, MINUS, TIMES, DIVIDE, MOD; terminal UMINUS, LPAREN, RPAREN; terminal Integer NUMBER; /* Non terminals */ non terminal expr_list, expr_part; non terminal Integer expr, term, factor; /* Precedences */ precedence left PLUS, MINUS; precedence left TIMES, DIVIDE, MOD; precedence left UMINUS; /* The grammar */ expr_list ::= expr_list expr_part | expr_part; expr_part ::= expr SEMI; expr ::= expr PLUS expr | expr MINUS expr | expr TIMES expr | expr DIVIDE expr | expr MOD expr | MINUS expr %prec UMINUS | LPAREN expr RPAREN | NUMBER ;
To produce a parser from this specification we use the CUP generator. If this specification were stored in a file parser.cup, then (on a Unix system at least) we might invoke CUP using a command like:
java java_cup.Main < parser.cupor (starting with CUP 0.10k):
java java_cup.Main parser.cupThe system will produce two Java source files containing parts of the generated parser: sym.java and parser.java (these names can be changed with command-line options; see below). As you might expect, these two files contain declarations for the classes sym and parser. The sym class contains a series of constant declarations, one for each terminal symbol. This is typically used by the scanner to refer to symbols (e.g. with code such as "return new Symbol(sym.SEMI);" ). The parser class implements the parser itself.
The specification above, while constructing a full parser, does not perform any semantic actions &emdash; it will only indicate success or failure of a parse. To calculate and print values of each expression, we must embed Java code within the parser to carry out actions at various points. In CUP, actions are contained in code strings which are surrounded by delimiters of the form {: and :} (we can see examples of this in the init with and scan with clauses above). In general, the system records all characters within the delimiters, but does not try to check that it contains valid Java code.
A more complete CUP specification for our example system (with actions
embedded at various points in the grammar) is shown below:
// CUP specification for a simple expression evaluator (w/ actions) import java_cup.runtime.*; /* Preliminaries to set up and use the scanner. */ init with {: scanner.init(); :}; scan with {: return scanner.next_token(); :}; /* Terminals (tokens returned by the scanner). */ terminal SEMI, PLUS, MINUS, TIMES, DIVIDE, MOD; terminal UMINUS, LPAREN, RPAREN; terminal Integer NUMBER; /* Non-terminals */ non terminal expr_list, expr_part; non terminal Integer expr; /* Precedences */ precedence left PLUS, MINUS; precedence left TIMES, DIVIDE, MOD; precedence left UMINUS; /* The grammar */ expr_list ::= expr_list expr_part | expr_part; expr_part ::= expr:e {: System.out.println("= " + e); :} SEMI ; expr ::= expr:e1 PLUS expr:e2 {: RESULT = new Integer(e1.intValue() + e2.intValue()); :} | expr:e1 MINUS expr:e2 {: RESULT = new Integer(e1.intValue() - e2.intValue()); :} | expr:e1 TIMES expr:e2 {: RESULT = new Integer(e1.intValue() * e2.intValue()); :} | expr:e1 DIVIDE expr:e2 {: RESULT = new Integer(e1.intValue() / e2.intValue()); :} | expr:e1 MOD expr:e2 {: RESULT = new Integer(e1.intValue() % e2.intValue()); :} | NUMBER:n {: RESULT = n; :} | MINUS expr:e {: RESULT = new Integer(0 - e.intValue()); :} %prec UMINUS | LPAREN expr:e RPAREN {: RESULT = e; :} ;
expr:e1 PLUS expr:e2 {: RESULT = new Integer(e1.intValue() + e2.intValue()); :}the first non-terminal expr has been labeled with e1, and the second with e2. The left hand side value of each production is always implicitly labeled as RESULT.
Each symbol appearing in a production is represented at runtime by an object of type Symbol on the parse stack. The labels refer to the instance variable value in those objects. In the expression expr:e1 PLUS expr:e2, e1 and e2 refer to objects of type Integer. These objects are in the value fields of the objects of type Symbol representing those non-terminals on the parse stack. RESULT is of type Integer as well, since the resulting non-terminal expr was declared as of type Integer. This object becomes the value instance variable of a new Symbol object.
For each label, two more variables accessible to the user are declared. A left and right value labels are passed to the code string, so that the user can find out where the left and right side of each terminal or non-terminal is in the input stream. The name of these variables is the label name, plus left or right. for example, given the right hand side of a production expr:e1 PLUS expr:e2 the user could not only access variables e1 and e2, but also e1left, e1right, e2left and e2right. these variables are of type int.
The final step in creating a working parser is to create a scanner (also
known as a lexical analyzer or simply a lexer). This routine is
responsible for reading individual characters, removing things things like
white space and comments, recognizing which terminal symbols from the
grammar each group of characters represents, then returning Symbol objects
representing these symbols to the parser.
The terminals will be retrieved with a call to the
scanner function. In the example, the parser will call
scanner.next_token(). The scanner should return objects of
type java_cup.runtime.Symbol. This type is very different than
older versions of CUP's java_cup.runtime.symbol. These Symbol
objects contains the instance variable value of type Object,
which should be
set by the lexer. This variable refers to the value of that symbol, and
the type of object in value should be of the same type as declared in
the terminal and non terminal declarations. In the
above example, if the lexer wished to pass a NUMBER token, it should
create a Symbol with the value instance variable
filled with an object of type Integer.
The code contained in the init with clause of the specification
will be executed before any tokens are requested. Each token will be
requested using whatever code is found in the scan with clause.
Beyond this, the exact form the scanner takes is up to you; however
note that each call to the scanner function should return a new
instance of
In the next section a more detailed and formal
explanation of all parts of a CUP specification will be given.
Section 3 describes options for running the
CUP system. Section 4 discusses the details
of how to customize a CUP parser, while section 5
discusses the scanner interface added in CUP 0.10j. Section
6 considers error recovery. Finally, Section 7
provides a conclusion.
Symbol
objects corresponding to terminals and non-terminals with no value
have a null value field.
java_cup.runtime.Symbol
(or a subclass).
These symbol objects are annotated with parser information and pushed
onto a stack; reusing objects will result in the parser annotations
being scrambled. As of CUP 0.10j, Symbol
reuse should be
detected if it occurs; the parser will throw an Error
telling you to fix your scanner.
2. Specification Syntax
Now that we have seen a small example, we present a complete description of all
parts of a CUP specification. A specification has four sections with
a total of eight specific parts (however, most of these are optional).
A specification consists of:
package name;where name name is a Java package identifier, possibly in several parts separated by ".". In general, CUP employs Java lexical conventions. So for example, both styles of Java comments are supported, and identifiers are constructed beginning with a letter, dollar sign ($), or underscore (_), which can then be followed by zero or more letters, numbers, dollar signs, and underscores.
After an optional package declaration, there can be zero or more import declarations. As in a Java program these have the form:
import package_name.class_name;or
import package_name.*;The package declaration indicates what package the sym and parser classes that are generated by the system will be in. Any import declarations that appear in the specification will also appear in the source file for the parser class allowing various names from that package to be used directly in user supplied action code.
action code {: ... :};where {: ... :} is a code string whose contents will be placed directly within the action class class declaration.
After the action code declaration is an optional parser code declaration. This declaration allows methods and variable to be placed directly within the generated parser class. Although this is less common, it can be helpful when customizing the parser &emdash; it is possible for example, to include scanning methods inside the parser and/or override the default error reporting routines. This declaration is very similar to the action code declaration and takes the form:
parser code {: ... :};Again, code from the code string is placed directly into the generated parser class definition.
Next in the specification is the optional init declaration which has the form:
init with {: ... :};This declaration provides code that will be executed by the parser before it asks for the first token. Typically, this is used to initialize the scanner as well as various tables and other data structures that might be needed by semantic actions. In this case, the code given in the code string forms the body of a void method inside the parser class.
The final (optional) user code section of the specification indicates how the parser should ask for the next token from the scanner. This has the form:
scan with {: ... :};As with the init clause, the contents of the code string forms the body of a method in the generated parser. However, in this case the method returns an object of type java_cup.runtime.Symbol. Consequently the code found in the scan with clause should return such a value. See section 5 for information on the default behavior if the
scan with
section is omitted.As of CUP 0.10j the action code, parser code, init code, and scan with sections may appear in any order. They must, however, precede the symbol lists.
terminal classname name1, name2, ...; non terminal classname name1, name2, ...; terminal name1, name2, ...;and
non terminal name1, name2, ...;where classname can be a multiple part name separated with "."s. The classname specified represents the type of the value of that terminal or non-terminal. When accessing these values through labels, the users uses the type declared. the classname can be of any type. If no classname is given, then the terminal or non-terminal holds no value. a label referring to such a symbol with have a null value. As of CUP 0.10j, you may specify non-terminals the declaration "
nonterminal
" (note, no
space) as well as the original "non terminal
" spelling.Names of terminals and non-terminals cannot be CUP reserved words; these include "code", "action", "parser", "terminal", "non", "nonterminal", "init", "scan", "with", "start", "precedence", "left", "right", "nonassoc", "import", and "package".
precedence left terminal[, terminal...]; precedence right terminal[, terminal...]; precedence nonassoc terminal[, terminal...];The comma separated list indicates that those terminals should have the associativity specified at that precedence level and the precedence of that declaration. The order of precedence, from highest to lowest, is bottom to top. Hence, this declares that multiplication and division have higher precedence than addition and subtraction:
precedence left ADD, SUBTRACT; precedence left TIMES, DIVIDE;Precedence resolves shift reduce problems. For example, given the input to the above example parser 3 + 4 * 8, the parser doesn't know whether to reduce 3 + 4 or shift the '*' onto the stack. However, since '*' has a higher precedence than '+', it will be shifted and the multiplication will be performed before the addition.
CUP assigns each one of its terminals a precedence according to these declarations. Any terminals not in this declaration have lowest precedence. CUP also assigns each of its productions a precedence. That precedence is equal to the precedence of the last terminal in that production. If the production has no terminals, then it has lowest precedence. For example, expr ::= expr TIMES expr would have the same precedence as TIMES. When there is a shift/reduce conflict, the parser determines whether the terminal to be shifted has a higher precedence, or if the production to reduce by does. If the terminal has higher precedence, it it shifted, if the production has higher precedence, a reduce is performed. If they have equal precedence, associativity of the terminal determine what happens.
An associativity is assigned to each terminal used in the precedence/associativity declarations. The three associativities are left, right and nonassoc Associativities are also used to resolve shift/reduce conflicts, but only in the case of equal precedences. If the associativity of the terminal that can be shifted is left, then a reduce is performed. This means, if the input is a string of additions, like 3 + 4 + 5 + 6 + 7, the parser will always reduce them from left to right, in this case, starting with 3 + 4. If the associativity of the terminal is right, it is shifted onto the stack. hence, the reductions will take place from right to left. So, if PLUS were declared with associativity of right, the 6 + 7 would be reduced first in the above string. If a terminal is declared as nonassoc, then two consecutive occurrences of equal precedence non-associative terminals generates an error. This is useful for comparison operations. For example, if the input string is 6 == 7 == 8 == 9, the parser should generate an error. If '==' is declared as nonassoc then an error will be generated.
All terminals not used in the precedence/associativity declarations are treated as lowest precedence. If a shift/reduce error results, involving two such terminals, it cannot be resolved, as the above conflicts are, so it will be reported.
start with non-terminal;This indicates which non-terminal is the start or goal non-terminal for parsing. If a start non-terminal is not explicitly declared, then the non-terminal on the left hand side of the first production will be used. At the end of a successful parse, CUP returns an object of type java_cup.runtime.Symbol. This Symbol's value instance variable contains the final reduction result.
The grammar itself follows the optional start declaration. Each production in the grammar has a left hand side non-terminal followed by the symbol "::=", which is then followed by a series of zero or more actions, terminal, or non-terminal symbols, followed by an optional contextual precedence assignment, and terminated with a semicolon (;).
Each symbol on the right hand side can optionally be labeled with a name.
Label names appear after the symbol name separated by a colon (:). Label
names must be unique within the production, and can be used within action
code to refer to the value of the symbol. Along with the label, two
more variables are created, which are the label plus left and
the label plus right. These are int values that
contain the right and left locations of what the terminal or
non-terminal covers in the input file. These values must be properly
initialized in the terminals by the lexer. The left and right values
then propagate to non-terminals to which productions reduce.
If there are several productions for the same non-terminal they may be
declared together. In this case the productions start with the non-terminal
and "::=". This is followed by multiple right hand sides each
separated by a bar (|). The full set of productions is then terminated by a
semicolon.
Actions appear in the right hand side as code strings (e.g., Java code inside
{: ... :} delimiters). These are executed by the parser
at the point when the portion of the production to the left of the
action has been recognized. (Note that the scanner will have returned the
token one past the point of the action since the parser needs this extra
lookahead token for recognition.)
Contextual precedence assignments follow all the symbols and actions of
the right hand side of the production whose precedence it is assigning.
Contextual precedence assignment allows a production to be assigned a
precedence not based on the last terminal in it. A good example is
shown in the above sample parser specification:
In addition to the specification file, CUP's behavior can also be changed
by passing various options to it. Legal options are documented in
precedence left PLUS, MINUS;
precedence left TIMES, DIVIDE, MOD;
precedence left UMINUS;
expr ::= MINUS expr:e
{: RESULT = new Integer(0 - e.intValue()); :}
%prec UMINUS
Here, there production is declared as having the precedence of UMINUS.
Hence, the parser can give the MINUS sign two different precedences,
depending on whether it is a unary minus or a subtraction operation.
3. Running CUP
As mentioned above, CUP is written in Java. To invoke it, one needs
to use the Java interpreter to invoke the static method
java_cup.Main(), passing an array of strings containing options.
Assuming a Unix machine, the simplest way to do this is typically to invoke it
directly from the command line with a command such as:
java java_cup.Main options < inputfile
Once running, CUP expects to find a specification file on standard input
and produces two Java source files as output. Starting with CUP 0.10k,
the final command-line argument may be a filename, in which case the
specification will be read from that file instead of from standard input.
Main.java
and include:
interface
rather than as a class
.
This option is typically used to work-around the java bytecode
limitations on table initialization code sizes. However, CUP
0.10h introduced a string-encoding for the parser tables which
is not subject to the standard method-size limitations.
Consequently, use of this option should no longer be required
for large grammars.
java_cup.runtime.Scanner
. By default, the
generated parser refers to this interface, which means you cannot
use these parsers with CUP runtimes older than 0.10j. If your
parser does not use the new scanner integration features, then you
may specify the -noscanner
option to suppress the
java_cup.runtime.Scanner
references and allow
compatibility with old runtimes. Not many people should have reason
to do this.
-version
flag will cause it
to print out the working version of CUP and halt. This allows
automated CUP version checking for Makefiles, install scripts and
other applications which may require it.
4. Customizing the Parser
Each generated parser consists of three generated classes. The
sym class (which can be renamed using the -symbols
option) simply contains a series of int constants,
one for each terminal. Non-terminals are also included if the -nonterms
option is given. The source file for the parser class (which can
be renamed using the -parser option) actually contains two
class definitions, the public parser class that implements the
actual parser, and another non-public class (called CUP$action) which
encapsulates all user actions contained in the grammar, as well as code from
the action code declaration. In addition to user supplied code, this
class contains one method: CUP$do_action which consists of a large
switch statement for selecting and executing various fragments of user
supplied action code. In general, all names beginning with the prefix of
CUP$ are reserved for internal uses by CUP generated code.
The parser class contains the actual generated parser. It is a subclass of java_cup.runtime.lr_parser which implements a general table driven framework for an LR parser. The generated parser class provides a series of tables for use by the general framework. Three tables are provided:
Beyond the parse tables, generated (or inherited) code provides a series of methods that can be used to customize the generated parser. Some of these methods are supplied by code found in part of the specification and can be customized directly in that fashion. The others are provided by the lr_parser base class and can be overridden with new versions (via the parser code declaration) to customize the system. Methods available for customization include:
getScanner().next_token()
.
In addition to the normal parser, the runtime system also provides a debugging version of the parser. This operates in exactly the same way as the normal parser, but prints debugging messages (by calling public void debug_message(String mess) whose default implementation prints a message to System.err).
Based on these routines, invocation of a CUP parser is typically done with code such as:
/* create a parsing object */ parser parser_obj = new parser(); /* open input files, etc. here */ Symbol parse_tree = null; try { if (do_debug_parse) parse_tree = parser_obj.debug_parse(); else parse_tree = parser_obj.parse(); } catch (Exception e) { /* do cleanup here - - possibly rethrow e */ } finally { /* do close out here */ }
To use the new code, your scanner should implement the
java_cup.runtime.Scanner
interface, defined as:
package java_cup.runtime; public interface Scanner { public Symbol next_token() throws java.lang.Exception; }
In addition to the methods described in section
4, the java_cup.runtime.lr_parser
class has two new
accessor methods, setScanner()
and getScanner()
.
The default implementation of scan()
is:
public Symbol scan() throws java.lang.Exception { Symbol sym = getScanner().next_token(); return (sym!=null) ? sym : new Symbol(EOF_sym()); }
The generated parser also contains a constructor which takes a
Scanner
and calls setScanner()
with it. In
most cases, then, the init with
and scan
with
directives may be omitted. You can simply create the
parser with a reference to the desired scanner:
/* create a parsing object */ parser parser_obj = new parser(new my_scanner());or set the scanner after the parser is created:
/* create a parsing object */ parser parser_obj = new parser(); /* set the default scanner */ parser_obj.setScanner(new my_scanner());
Note that because the parser uses look-ahead, resetting the scanner in
the middle of a parse is not recommended. If you attempt to use the
default implementation of scan()
without first calling
setScanner()
, a NullPointerException
will be
thrown.
As an example of scanner integration, the following three lines in the lexer-generator input are all that is required to use a JLex or JFlex scanner with CUP:
%implements java_cup.runtime.Scanner %function next_token %type java_cup.runtime.SymbolThe JLex directive
%cup
abbreviates the above three directive in JLex versions 1.2.5 and above.
Invoking the parser with the JLex scanner is then simply:
parser parser_obj = new parser( new Yylex( some_InputStream_or_Reader));
Note CUP handles the JLex/JFlex convention of returning null on EOF
without a problem, so an %eofval
directive is not
required in the JLex specification (this feature was added in CUP 0.10k).
The simple_calc example in the CUP distribution illustrates the use of
the scanner integration features with a hand-coded scanner.
The CUP website has a minimal CUP/JLex integration example for study.
6. Error Recovery
A final important aspect of building parsers with CUP is
support for syntactic error recovery. CUP uses the same
error recovery mechanisms as YACC. In particular, it supports
a special error symbol (denoted simply as error).
This symbol plays the role of a special non-terminal which, instead of
being defined by productions, instead matches an erroneous input
sequence.
The error symbol only comes into play if a syntax error is detected. If a syntax error is detected then the parser tries to replace some portion of the input token stream with error and then continue parsing. For example, we might have productions such as:
stmt ::= expr SEMI | while_stmt SEMI | if_stmt SEMI | ... | error SEMI ;This indicates that if none of the normal productions for stmt can be matched by the input, then a syntax error should be declared, and recovery should be made by skipping erroneous tokens (equivalent to matching and replacing them with error) up to a point at which the parse can be continued with a semicolon (and additional context that legally follows a statement). An error is considered to be recovered from if and only if a sufficient number of tokens past the error symbol can be successfully parsed. (The number of tokens required is determined by the error_sync_size() method of the parser and defaults to 3).
Specifically, the parser first looks for the closest state to the top
of the parse stack that has an outgoing transition under
error. This generally corresponds to working from
productions that represent more detailed constructs (such as a specific
kind of statement) up to productions that represent more general or
enclosing constructs (such as the general production for all
statements or a production representing a whole section of declarations)
until we get to a place where an error recovery production
has been provided for. Once the parser is placed into a configuration
that has an immediate error recovery (by popping the stack to the first
such state), the parser begins skipping tokens to find a point at
which the parse can be continued. After discarding each token, the
parser attempts to parse ahead in the input (without executing any
embedded semantic actions). If the parser can successfully parse past
the required number of tokens, then the input is backed up to the point
of recovery and the parse is resumed normally (executing all actions).
If the parse cannot be continued far enough, then another token is
discarded and the parser again tries to parse ahead. If the end of
input is reached without making a successful recovery (or there was no
suitable error recovery state found on the parse stack to begin with)
then error recovery fails.
7. Conclusion
This manual has briefly described the CUP LALR parser generation system.
CUP is designed to fill the same role as the well known YACC parser
generator system, but is written in and operates entirely with Java code
rather than C or C++. Additional details on the operation of the system can
be found in the parser generator and runtime source code. See the CUP
home page below for access to the API documentation for the system and its
runtime.
This document covers version 0.10j of the system. Check the CUP home page: http://www.cs.princeton.edu/~appel/modern/java/CUP/ for the latest release information, instructions for downloading the system, and additional news about CUP. Bug reports and other comments for the developers should be sent to the CUP maintainer, C. Scott Ananian, at<EMAIL_ADDRESS>CUP was originally written by Scott Hudson, in August of 1995.
It was extended to support precedence by Frank Flannery, in July of 1996.
On-going improvements have been done by C. Scott Ananian, the CUP maintainer, from December of 1997 to the present.
java_cup_spec ::= package_spec import_list code_parts symbol_list precedence_list start_spec production_list package_spec ::= PACKAGE multipart_id SEMI | empty import_list ::= import_list import_spec | empty import_spec ::= IMPORT import_id SEMI code_part ::= action_code_part | parser_code_part | init_code | scan_code code_parts ::= code_parts code_part | empty action_code_part ::= ACTION CODE CODE_STRING opt_semi parser_code_part ::= PARSER CODE CODE_STRING opt_semi init_code ::= INIT WITH CODE_STRING opt_semi scan_code ::= SCAN WITH CODE_STRING opt_semi symbol_list ::= symbol_list symbol | symbol symbol ::= TERMINAL type_id declares_term | NON TERMINAL type_id declares_non_term | NONTERMINAL type_id declares_non_term | TERMINAL declares_term | NON TERMINAL declares_non_term | NONTERMIANL declared_non_term term_name_list ::= term_name_list COMMA new_term_id | new_term_id non_term_name_list ::= non_term_name_list COMMA new_non_term_id | new_non_term_id declares_term ::= term_name_list SEMI declares_non_term ::= non_term_name_list SEMI precedence_list ::= precedence_l | empty precedence_l ::= precedence_l preced + preced; preced ::= PRECEDENCE LEFT terminal_list SEMI | PRECEDENCE RIGHT terminal_list SEMI | PRECEDENCE NONASSOC terminal_list SEMI terminal_list ::= terminal_list COMMA terminal_id | terminal_id start_spec ::= START WITH nt_id SEMI | empty production_list ::= production_list production | production production ::= nt_id COLON_COLON_EQUALS rhs_list SEMI rhs_list ::= rhs_list BAR rhs | rhs rhs ::= prod_part_list PERCENT_PREC term_id | prod_part_list prod_part_list ::= prod_part_list prod_part | empty prod_part ::= symbol_id opt_label | CODE_STRING opt_label ::= COLON label_id | empty multipart_id ::= multipart_id DOT ID | ID import_id ::= multipart_id DOT STAR | multipart_id type_id ::= multipart_id terminal_id ::= term_id term_id ::= symbol_id new_term_id ::= ID new_non_term_id ::= ID nt_id ::= ID symbol_id ::= ID label_id ::= ID opt_semi ::= SEMI | empty
// Simple Example Scanner Class import java_cup.runtime.*; import sym; public class scanner { /* single lookahead character */ protected static int next_char; /* advance input by one character */ protected static void advance() throws java.io.IOException { next_char = System.in.read(); } /* initialize the scanner */ public static void init() throws java.io.IOException { advance(); } /* recognize and return the next complete token */ public static Symbol next_token() throws java.io.IOException { for (;;) switch (next_char) { case '0': case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': /* parse a decimal integer */ int i_val = 0; do { i_val = i_val * 10 + (next_char - '0'); advance(); } while (next_char >= '0' && next_char <= '9'); return new Symbol(sym.NUMBER, new Integer(i_val)); case ';': advance(); return new Symbol(sym.SEMI); case '+': advance(); return new Symbol(sym.PLUS); case '-': advance(); return new Symbol(sym.MINUS); case '*': advance(); return new Symbol(sym.TIMES); case '/': advance(); return new Symbol(sym.DIVIDE); case '%': advance(); return new Symbol(sym.MOD); case '(': advance(); return new Symbol(sym.LPAREN); case ')': advance(); return new Symbol(sym.RPAREN); case -1: return new Symbol(sym.EOF); default: /* in this simple scanner we just ignore everything else */ advance(); break; } } };
For more information, refer to the manual on scanners.
terminal classname terminal [, terminal ...];still works. The classname, however indicates the type of the value of the terminal or non-terminal, and does not indicate the type of object placed on the parse stack. A declaration, such as:
terminal terminal [, terminal ...];indicates the terminals in the list hold no value.
For more information, refer to the manual on declarations.
For more information, refer to the manual on labels.
For more information, refer to the manual on RESULT.
For more information, refer to the manual on positions.
precedence {left| right | nonassoc} terminal[, terminal ...]; ...The terminals are assigned a precedence, where terminals on the same line have equal precedences, and the precedence declarations farther down the list of precedence declarations have higher precedence. left, right and nonassoc specify the associativity of these terminals. left associativity corresponds to a reduce on conflict, right to a shift on conflict, and nonassoc to an error on conflict. Hence, ambiguous grammars may now be used.
For more information, refer to the manual on precedence.
lhs ::= {right hand side list of terminals, non-terminals and actions} %prec {terminal};this production would then have a precedence equal to the terminal specified after the %prec. Hence, shift/reduce conflicts can be contextually resolved. Note that the %prec terminal part comes after all actions strings. It does not come before the last action string.
For more information, refer to the manual on contextual precedence. These changes implemented by:
This is because the parsing tables (and parsing engine) are in one object (belonging to class parser or whatever name is specified by the -parser directive), and the semantic actions are in another object (of class CUP$actions).
However, there is a way to do it, though it's a bit inelegant. The action object has a private final field named parser that points to the parsing object. Thus, methods and instance variables of the parser can be accessed within semantic actions as:
parser.report_error(message,info); x = parser.mydata;
Perhaps this will not be necessary in a future release, and that such methods and variables as report_error and mydata will be available directly from the semantic actions; we will achieve this by combining the "parser" object and the "actions" object together.
For a list of any other currently known bugs in CUP, see
http://www.cs.princeton.edu/~appel/modern/java/CUP/bugs.html.
Appendix E: Change log
java_cup.runtime.Scanner
interface.


View Messages
Sign Out
Write something to everyone:
Send Message
Subscribe to Push Notifications
You need to sign in to use this application.
Welcome!


This template shows how to enable full text search on Firestore documents by using one of the followning hosted search services:
See file functions/index.js for the code.
The dependencies are listed in functions/package.json.
As an example we’ll be using a secure note structure:
/notes
/note-123456
text: "This is my first note...",
owner: "FIREBASE_USER_ID"
/note-123457
text: "This is my second note entry...",
owner: "FIREBASE_USER_ID"
tags: ["some_category"]
Whenever a new note is created or modified a Function sends the content to be indexed.
For setup and overview, please see the Full Text Search Solution in the Firestore documentation.


Before Change
receiver_args = "--server -1"
process_args = [(_RunIperf3, (receiving_vm, receiver_args), {}),
(_RunIperf3, (sending_vm, sender_args), {})]
background_tasks.RunParallelProcesses(process_args, 200, 1)
cat_command = "cd {iperf3_exec_dir}; cat {out_file}".format(
After Change
receiver_args = "--server -1"
server_process = multiprocessing.Process(
name="server",
target=_RunIperf3,
args=(receiving_vm, receiver_args))
server_process.start()
receiving_vm.WaitForProcessRunning("iperf3", 3)


#import <opencv2/videoio/cap_ios.h>
Instance Methods | |
| (start) | - CV_UNUSED |
| (unlockBalance) | - CV_UNUSED |
| (lockBalance) | - CV_UNUSED |
| (unlockExposure) | - CV_UNUSED |
| (lockExposure) | - CV_UNUSED |
| (unlockFocus) | - CV_UNUSED |
| (stop) | - CV_UNUSED |
| (updateOrientation) | - CV_UNUSED |
| (createVideoPreviewLayer) | - CV_UNUSED |
| (createCaptureOutput) | - CV_UNUSED |
| (lockFocus) | - CV_UNUSED |
| (switchCameras) | - CV_UNUSED |
| (id) | - initWithParentView: |
Protected Attributes | |
| BOOL | cameraAvailable |
| UIDeviceOrientation | currentDeviceOrientation |
Properties | |
| AVCaptureSession * | captureSession |
| BOOL | captureSessionLoaded |
| AVCaptureVideoPreviewLayer * | captureVideoPreviewLayer |
| AVCaptureDevicePosition | defaultAVCaptureDevicePosition |
| NSString *const | defaultAVCaptureSessionPreset |
| AVCaptureVideoOrientation | defaultAVCaptureVideoOrientation |
| int | defaultFPS |
| int | imageHeight |
| int | imageWidth |
| UIView * | parentView |
| BOOL | running |
| BOOL | useAVCaptureVideoPreviewLayer |
| AVCaptureConnection * | videoCaptureConnection |
Method Documentation
◆ CV_UNUSED() [1/12]
| - (start) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [2/12]
| - (unlockBalance) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [3/12]
| - (lockBalance) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [4/12]
| - (unlockExposure) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [5/12]
| - (lockExposure) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [6/12]
| - (unlockFocus) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [7/12]
| - (stop) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [8/12]
| - (updateOrientation) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [9/12]
| - (createVideoPreviewLayer) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [10/12]
| - (createCaptureOutput) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [11/12]
| - (lockFocus) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ CV_UNUSED() [12/12]
| - (switchCameras) CV_UNUSED |
Implemented in CvPhotoCamera, CvVideoCamera, and CvVideoCamera.
◆ initWithParentView:()
| - (id) initWithParentView: | (UIView *) | parent |
Member Data Documentation
◆ cameraAvailable
|
protected |
◆ currentDeviceOrientation
|
protected |
Property Documentation
◆ captureSession
|
readwritenonatomicstrong |
◆ captureSessionLoaded
|
readnonatomicassign |
◆ captureVideoPreviewLayer
|
readnonatomicassign |
◆ defaultAVCaptureDevicePosition
|
readwritenonatomicassign |
◆ defaultAVCaptureSessionPreset
|
readwritenonatomicstrong |
◆ defaultAVCaptureVideoOrientation
|
readwritenonatomicassign |
◆ defaultFPS
|
readwritenonatomicassign |
◆ imageHeight
|
readwritenonatomicassign |
◆ imageWidth
|
readwritenonatomicassign |
◆ parentView
|
readwritenonatomicstrong |
◆ running
|
readnonatomicassign |
◆ useAVCaptureVideoPreviewLayer
|
readwritenonatomicassign |
◆ videoCaptureConnection
|
readwritenonatomicstrong |
The documentation for this class was generated from the following file:
- opencv2/videoio/cap_ios.h


Poignant memorial to Scot killed in Manchester Arena bombing gets go-ahead
Plans for a memorial garden and bronze sculpture in memory of Eilidh MacLeod have been given approval.
by Julie Dunnett, https://www.dailyrecord.co.uk/authors/julie-gilbert/A memorial for a Scots teenager killed in the Manchester Arena bombing has been given the go-ahead on her home island.
Eilidh MacLeod from Barra was just 14 when she died in the terror attack at Ariana Grande's concer t on May 22, 2017.
Following the atrocity, her family set up the Eilidh MacLeod Memorial Trust - known as Eilidh's Trust - in her memory.
Earlier this year, the trust announced plans for a memorial garden and bronze sculpture on her home island.
The statue depicts a young woman holding a set of pipes and holding hands with a boy.
Eilidh played the pipes and the school girl's family wanted it to reflect her passion for music.
The sculpture will overlook the island of Vatersay where Eilidh spent her early years growing up.
A post on the Eilidh's Trust Facebook page announced that the Comhairle nan Eilean Siar Council had approved the memorial plan.
The post reads: "Some lovely news to share with you.
"Our application for the permanent memorial and garden of remembrance has been approved by Comhairle nan Eilean Siar.
"We are delighted that the council has given Eilidh’s Trust its backing for this.
"This is an early - but important- step in the development of a memorial, and a quiet space for everyone to reflect on their daily lives and on loved ones who are no longer with us."


We first give a somewhat simplified sketch of how the debugger treats the breakpoints. This description will be refined in the sequel.
The debugger allows us to prescribe some activities to be performed at certain points of execution, namely at the ports of procedure boxes. In principle, the debugger is entered at each port of each procedure invocation. It then considers the current breakpoints one by one, most recent first. The first breakpoint for which the evaluation of the test part succeeds is then activated, and the execution continues according to its action part. The activated breakpoint “hides” the remaining (older) ones, i.e. those are not tried here. If none of the current breakpoints is activated, the debugger behaves according to the actual debugging mode (trace, debug or zip).
Both the test and the action part can be simple or composite. Evaluating
a simple test amounts to checking whether it holds in the current state
of execution, e.g. pred(foo/2)
holds if the debugger is at a
port of predicate foo/2
.
Composite conditions can be built from simple ones by forming lists, or
using the `,', `;', `->', and `\+' operators,
with the usual meaning of conjunction, disjunction,
if-then-else and negation. A list of conditions is equivalent to a
conjunction of the same conditions. For example, the condition
[pred(foo/2), \+port(fail)]
will hold for all ports of
foo/2
, except for the Fail port.


APSMediaPlayerClosableOverlayController Class Reference
| Inherits from | APSMediaPlayerOverlayController : UIViewController |
|---|---|
| Declared in | APSMediaPlayerClosableOverlayController.h APSMediaPlayerClosableOverlayController.m |
Overview
The APSMediaPlayerClosableOverlayController
class is meant to be a superclass for overlay controllers that need to display a configurable close button to remove the overlay from screen.
The class adds a set of standard keys to any overlay controller’s own defined keys, to handle close button configuration. Methods are also exposed to allow a subclass to add and remove the close button from its view stack.
– addCloseButtonWithParameters:
This method adds the close button to the current view stack.
- (UIView *_Nullable)addCloseButtonWithParameters:(NSDictionary<NSString*,id> *_Nonnull)parameters
Parameters
parameters |
A dictionary containing configuration information. |
|---|
Discussion
This method adds the close button to the current view stack.
The close button is configurable using the provided dictionary structure. Available configuration keys and values are:
kAPSCloseImage
: if set to aUIImage
, that image will be used instead of the standard progress-wheel close button.kAPSCloseSize
: aNSNumber
reprezenting the lenght of a side of the close button square, in points. Defaults to 16.kAPSCloseBackgroundColor
: the background color of the close button view. Set this to aUIColor
or aNSString
containing the hex color reprezentation. Defaults to[UIColor clearColor]
.kAPSCloseXColor
: the color of the X symbol in the center of the player. Set this to aNSString
containing the hex color reprezentation. Defaults to[UIColor darkGrayColor]
.kAPSCloseProgressColor
: the color of the circular bar that indicates the currently elapsed time until the close button can be tapped. Set this to aNSString
containing the hex color reprezentation. Defaults to[UIColor darkGrayColor]
.kAPSCloseProgressTrackColor
: the color of the circular bar that indicates the total time until the close button can be tapped. Set this to aNSString
containing the hex color reprezentation. Defaults to[UIColor lightGrayColor]
.kAPSCloseOffsetX
: the horizontal offset of the close button, relative to the right margin of the overlay’s view. Set this to aNSNumber
. Defaults to 0.kAPSCloseOffsetY
: the vertical offset of the close button, relative to the top margin of the overlay’s view. Set this to aNSNumber
. Defaults to 0.kAPSCloseInitialAlpha
: aNSNumber
indicating the opacity of the close button before it is activated for receiving taps. Defaults to 0.5.kAPSCloseFinalAlpha
: aNSNumber
indicating the opacity of the close button after it has been activated for receiving taps. Defaults to 0.7.kAPSCloseHidden
: set this key to @YES to skip displaying the close button for this overlay. Defaults to @NO.kAPSCloseOffset
: aNSNumber
that indicates the offset, in seconds, after which the close button should become activated for receiving taps. Defaults to 3.kAPSCloseTrackingURLs
: aNSArray
ofNSURL
s that will be tracked by the player when the close button is tapped and the overlay is removed (see[APSMediaPlayer track:forEvent:type:]
).
Declared In
APSMediaPlayerClosableOverlayController.h
– removeCloseButton
This method removes the close button from the current view stack.
- (void)removeCloseButton
Discussion
This method removes the close button from the current view stack.
Declared In
APSMediaPlayerClosableOverlayController.h


Innovative Information Security Solutions & Services.
Egirna Technologies Limited is an information security solutions and services provider based in Egypt with global reach. The company focus is providing innovative and budget conscious information security solutions and services. Our team members expertise ranging from young enthusiasts to +20 years of experience in the field.
{{ content }}
{% include footer.html %}


Unified Platform for Logistics Support
India’s evolving economic landscape requires all sellers to continuously create more robust, efficient and technically advanced support for their business ranging from marketing to logistics. Maximizing the potential of your business requires re-defining business strategy and adapting to continuously evolving customer demands every day.
Logistics PartnerLogistics is the backbone of supply-chain management. Our suite of mini-truck offerings for intra-city logistics coupled with web-based tracking and periodical alerts have been designed to provide seamless consumer experience. We specialize in intra-city logistics and enjoy advantages to high economy of scale, enabling us to provide transparent and economical price. Book a mini-truck without going through the hassle of calling multiple vendors and haggling for prices.
Logistics Management: Efficient Management, Web Tracking, SMS Alerts.
Order Management: Ease and Convenience, Mini-Truck within 60 minutes, Dedicated Support Staff.
Economies of Scale: Widespread Network, Economical Pricing, Safety and Reliability, Advertisement.
Tracking Integrated Platform
We provide a unified tracking solution for fleet management, helping owners maximize their capacity utilization. Our reporting and business intelligence tools provide real-time and periodic business performance metrics. Increase deployment efficiency by dispatching the closest vehicle to any job site; reduce phone calls to the drivers in the field and better customer satisfaction by enhanced response time and periodical alerts.
Fleet Management: Geo-Fencing, Optimization Analytics, Historical Track Replays, SMS alerts
Capacity Utilization: Dispatching and Routing Efficiency, Warranted usage
Copyright © 2014 - All Rights Reserved - Domain Name
Template by OS Templates


Why I Blog
I blog because I’m lazy. There’s more too it though: In any given day I may explain something to someone, the first time I do this I make a bit of a mental note. The second time I do this, especially within a short time frame I make a physical note of this in the form of the title of a blog post. Once I’m already to a second time of doing this its almost inevitable I’ll continue repeating myself – and its valuable to others.
Becoming replaceable
My goal in doing this is actually to become heavily replaceable. Keeping information locked away means I’m the only one capable of doing it. Making myself highly replaceable means I can continue to work on new and interesting things.
Lots can be shared
I don’t recall exactly where I read it, I believe it may have been James Governor, but any email that doesn’t contain proprietary info or trade secrets should be blogged. I fully expect the sentiment around this is something to the effect that anything that contains good ideas/learning/processes can also be helpful to others.
Distilling information
For every time I explain something I often linger about one piece too long, hit something that doesn’t need to be discussed, or miss something entirely. Putting an idea or guide together in written form you re-read it, which is hard to do when simply verbally explaining. If you’ve video taped yourself before for public speaking practice you know this is an awkward but valuable experience. Its much easier to practice as an exercise in writing.
Economies of scale
While in some ways I am absolutely lazy when I blog I get economies of scale I couldn’t otherwise have. On a given day on a high day I may have 15 one on one conversations. Every post has the opportunity to become a one on one conversation.
One on one conversation is my preferred method instead of in a large group. In a related area I’ve been having an ongoing conversation wth Ryan Daigle on whether blog posts should have comments. I opt for having you reach out to me directly via email, he believes comments should be available. Putting this in words crystalizes that to me its just relative to how you prefer to interact.
Summary
As with any other post, this is one conversation I’ve now had a few times over. Hopefully this gives some basis to why I feel others should contribute content as well. Whether you want make your self dispensible, refine your thoughts, or reach new economies of scale I believe its a worthwhile exercise for many. If you have other reasons you feel its valuable as always please reach out.


Data Binding
Enter data:
First Choice
Second Choice
Third Choice
select
range
One:
Two:
Three:
radio


Ability Skin: This skin unlocks a unique Hero portrait for your in-game Avatar and also an additional ability while equipped.
While Sarya is using her Ultimate, Enemies will gain 80% less Energy due to Damage taken
Ability only available while Night Raider Skin is equipped


Your task in this exercise is to show the behavior for the array-based stack's push operation. In the array displayed below, the "top" position is arr_size.
Push insert_value onto the stack.
Click on a value of the stack to highlight it, then click on the "Insert" button to insert insert_value to the highlighted position.
To change the value of "top", click on a cell in the array to highlight it, then click "Set Top".
If the index of "top" is greater than or equal to array size, then the stack is full and nothing can be added. In this case, just click "check answer".
Otherwise, the first step would be to insert a value into the "top" position of the stack.
Finally, increase the "top" index by 1.


This app implements actions that manage a Cisco Umbrella domain list. Cisco Umbrella allows third-party implementations like Phantom Enterprise to create and manage a list of domains (i.e. add, delete) via what it calls 'custom integrations'. The Phantom Cisco Umbrella App requires such an integration to be pre-configured on Cisco Umbrella. The steps to do this are outlined below:
- Login to your Cisco dashboard and go to Policies > Policy Components > Integrations and click the "Add" button.
- Set the name of the custom integration to be "Phantom Orchestration Feed"
- Expand your new custom integration, check "Enable", copy the integration URL and then click Save.
- The integration URL will be of the form: https://s-platform.api.opendns.com/1.0/events?customerKey=bac2bfa7-d134-4b85-a5ed-b1ffec027a91 One of the parameters to this URL is the customer key (GUID format). This value will be required while configuring the Cisco Umbrella asset on Phantom. The Cisco Umbrella App on Phantom will use this customer key while adding, listing, and deleting domains.
- Go to Policies > Policy Components > Security Settings, click on add, and check the relevant security settings. Scroll down and under Integrations select 'Phantom Orchestration Feed'.
At the end of the above steps Cisco Umbrella has been configured to:
- Create a 'custom integration' domain list with a customerKey for Phantom to use.
- Use the domains belonging to the 'Phantom Orchestration Feed' to block DNS requests.
The next step is to configure a 'Cisco Umbrella' app's asset on Phantom and specify the 'Cisco Customer key' and click 'Test Connectivity' to validate the configuration.
More information about 'custom integrations' can be found here.


Jedds Tree Care is a complete yard service including branch trimming, pruning, stump removal and emergency tree removal. We offer same day emergency service 24/7. Jedds operates out of East Lansing, MI, but also serves the surrounding counties for your urban and rural needs. We provide tree and yard care for both commercial and residential clients. Customer satisfaction is our primary goal.
Our business is fully insured. Safety is our number one priority. We have professional arborists on staff to deal with your special needs and we can handle any job, large or small.
We take pride in all of our work and we value your business.
Jedd Tree Care201 Edward Ave.
Lansing, MI 48930
email<EMAIL_ADDRESS>phone:<PHONE_NUMBER>


Madhur Kakkar SVG Icons
Check out the MK 2021 Gadgets Collection &
It Is 100% Free
Download button below
Battery
Batteries are a collection of one or more cells whose chemical reactions create a flow of electrons in a circuit
Camera
A camera is an optical instrument that captures a visual image.
Cell Phone
a Cell phone is a portable telephone that can make and receive calls over a radio frequency
Headphone
Headphones are a pair of small loudspeaker drivers worn on or around the head over a user's ears.
Ipad
IPad is a tablet designed, developed and marketed by Apple Inc
Mouse
A computer mouse is a hand-held pointing device that detects two-dimensional motion relative to a surface.
Video Camera
A camera that exposes photographic film to light in order to take a picture.
Secuirity
computer security, also called cybersecurity, the protection of computer systems
TV
Telegram television (also known as a TV) is a machine with a screen.
USB
USB is used to attach keyboards, mice, printers, external storage and mobile devices to the computer.
Hard Disk
a piece of hard plastic that is fixed inside a computer and is used for storing data and programs permanently
keyboard
keyboard is an input device that allows a person to enter letters, numbers, and other symbols into a computer