Verilog Parser
Verilog Parser API

Describes the top level, programmer facing parser API. More...

Functions

int verilog_parse_buffer (char *to_parse, int length)
 Perform a parsing operation on the supplied in-memory string. More...
 
int verilog_parse_file (FILE *to_parse)
 Perform a parsing operation on the supplied file. More...
 
int verilog_parse_string (char *to_parse, int length)
 Perform a parsing operation on the supplied in-memory string. More...
 
void verilog_parser_init ()
 Sets up the parsing environment ready for input. More...
 

Detailed Description

Describes the top level, programmer facing parser API.

Function Documentation

int verilog_parse_buffer ( char *  to_parse,
int  length 
)

Perform a parsing operation on the supplied in-memory string.

Parses the supplied string, reading at most "length" bytes, adding any parsed constructs to the existing yy_verilog_source_tree object, and using the existing yy_preproc preprocessor context.

Parameters
[in]to_parse- The string to be parsed.
[in]length- How many characters of to_parse to process.
Precondition
yy_init has been called atleast once, and to_parse is an accessible array of characters.
Postcondition
Any valid verilog constructs have been added to the yy_verilog_source_tree global object.
Returns
An integer describing the result of the parse operation. If the return value is a zero, the file was parsed successfully. If it takes any other value, the file parsed was syntactically invalid.
Warning
This function does not create a copy of the to_parse data, and will destroy the contents of the buffer. If you would rather the function operate on a copy of the data instead, please use the verilog_parse_string function.
Note
In the event of an invalid file being parsed, then the yy_verilog_source_tree object will only contain upto, but not including, the most recently valid parsed object. For example, when the following source is parsed:
module valid_module();
    initial begin
        $display("This module is valid");
    end
endmodule

module invalid_module();
    initial begin
        $display("This module is syntactically invalid");
endmodule

then the first "valid_module" object will be added to the source tree, but the second will not.

int verilog_parse_file ( FILE *  to_parse)

Perform a parsing operation on the supplied file.

Parses the supplied file object, adding any parsed constructs to the existing yy_verilog_source_tree object, and using the existing yy_preproc preprocessor context.

Parameters
[in]to_parse- The open file object to be parsed.
Precondition
yy_init has been called atleast once, and to_parse is an open and valid file to be read.
Postcondition
Any valid verilog constructs have been added to the yy_verilog_source_tree global object.
Returns
An integer describing the result of the parse operation. If the return value is a zero, the file was parsed successfully. If it takes any other value, the file parsed was syntactically invalid.
Note
In the event of an invalid file being parsed, then the yy_verilog_source_tree object will only contain upto, but not including, the most recently valid parsed object. For example, when the following source is parsed:
module valid_module();
    initial begin
        $display("This module is valid");
    end
endmodule

module invalid_module();
    initial begin
        $display("This module is syntactically invalid");
endmodule

then the first "valid_module" object will be added to the source tree, but the second will not.

Perform a parsing operation on the supplied file.

int verilog_parse_string ( char *  to_parse,
int  length 
)

Perform a parsing operation on the supplied in-memory string.

Parses the supplied string, reading at most "length" bytes, adding any parsed constructs to the existing yy_verilog_source_tree object, and using the existing yy_preproc preprocessor context.

Parameters
[in]to_parse- The string to be parsed.
[in]length- How many characters of to_parse to process.
Precondition
yy_init has been called atleast once, and to_parse is an accessible array of characters.
Postcondition
Any valid verilog constructs have been added to the yy_verilog_source_tree global object.
Returns
An integer describing the result of the parse operation. If the return value is a zero, the file was parsed successfully. If it takes any other value, the file parsed was syntactically invalid.
Warning
This function will create a copy of to_parse, and so is not destructive to the originally passed variable. If you would rather not create a copy, then use the verilog_parse_buffer function.
Note
In the event of an invalid file being parsed, then the yy_verilog_source_tree object will only contain upto, but not including, the most recently valid parsed object. For example, when the following source is parsed:
module valid_module();
    initial begin
        $display("This module is valid");
    end
endmodule

module invalid_module();
    initial begin
        $display("This module is syntactically invalid");
endmodule

then the first "valid_module" object will be added to the source tree, but the second will not.

void verilog_parser_init ( )

Sets up the parsing environment ready for input.

Makes sure that there is a vaild preprocessor context and source tree object ready to store any parsed constructs.

Precondition
The yy_preproc and yy_verilog_source_tree objects are in an unknown state
Postcondition
The yy_preproc and yy_verilog_source_tree objects are not NULL, and are certain to be either new or existing contexts ready for parsing.
Note
Calling this function, parsing a file, and then calling this function again, does not destroy the original preprocessor context or source tree.