ML-YACC notes

Source: Internet
Author: User

1. Basic Format

{User Declarations}

%
{Ml-YACC Declarations}
%
{Rules}

 

Similar to ml-Lex, {user Declarations}, user declarations are used to define custom values used in rules. We recommend that you shorten the code as much as possible.

 

The {ml-YACC Declarations} section is used for mandatory and optional declarations. For example, you must declare the Terminator, non-Terminator, and value types associated with them. You must define the name of the syntax analyzer and the type of the position value, which Terminator and non-terminator can be followed by the START symbol. Optional declarations include the priority of the Terminator, prohibiting the default protocol, and specifying whether the generated program contains lengthy descriptions in the. DESC file.

 

The {rules} part includes context-independent grammar and corresponding semantic behavior.

 

2. Necessary ml-YACC statement

% Name: syntax analyzer name

% Term: Terminator % nonterm: Non-Terminator

These two statements are similar to the datatype statement in ml. Do not use the ml keyword as the symbolic name.

% Term name1 [of ML-type]

| Name2 [of ML-type]

 

% Pos: indicates the type of the position value.

% POS<Ml-type>

 

3. optional declaration

% Arg: Declares the parameters passed in when the syntax analyzer is called.

% EOP: the end point after the start symbol. It must be declared in the term.

% Noshift: indicates a non-convertible symbol, that is, it cannot appear on the right of the rule.


%header (functor {parser name}LrValsFun(structure Token : TOKEN ...) )

% Left, % right, % nonassoc: Priority

% Start: Declaration start character

% Verbose: name of the description file

 

 

References: http://www.smlnj.org/doc/ML-Yacc/mlyacc002.html

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.