yast2-core
|
YCP language parser. More...
#include <Parser.h>
Public Member Functions | |
void | init () |
Parser () | |
Parser (FILE *file, const char *filename=0) | |
Parser (const char *buf) | |
Parser (int fd, const char *filename=0) | |
~Parser () | |
YCodePtr | parse (SymbolTable *gTable=0, SymbolTable *lTable=0) |
Scanner * | scanner () |
void | setScanner (Scanner *) |
bool | atEOF () |
void | setInput (FILE *file, const char *filename=0) |
void | setInput (const char *buf) |
void | setInput (int fd, const char *filename=0) |
void | setBuffered () |
void | setDepends () |
bool | depends () const |
Public Attributes | |
YCodePtr | m_result |
int | m_lineno |
int | m_loop_count |
int | m_parser_errors |
blockstack_t * | m_block_stack |
switchstack_t * | m_switch_stack |
scannerstack_t * | m_scanner_stack |
YBlockPtr | m_current_block |
int | m_blockstack_depth |
Private Attributes | |
Scanner * | m_scanner |
bool | m_buffered |
bool | m_depends |
bool | m_at_eof |
YCP language parser.
A YCP parser read a characters stream and outputs a sequence of YCP values. Three properties of the YCP grammar are important:
Property 1 allows you to call the parser without the specification, which type of value you expect. This allows a YCP protocol block to be of any YCP value.
Property 2 allows the parser class to be free of variables that must be kept between to parses.
Property 3 is especially important, because it allows the parser to determine the end of a value without having to look ahead more that one character.
Parser::Parser | ( | ) |
Parser::Parser | ( | FILE * | file, |
const char * | filename = 0 |
||
) |
Creates a new YCP parser
filename | If you have the name of the file you parse available, pass it here in order to get nice error location messages in case of a parse error. |
References init(), m_at_eof, m_lineno, and setInput().
Parser::Parser | ( | const char * | buf | ) |
Creates a new YCP parser
References init(), m_at_eof, m_lineno, and setInput().
Parser::Parser | ( | int | fd, |
const char * | filename = 0 |
||
) |
Creates a new YCP parser
filename | If you have the name of the file you parse available, pass it here in order to get nice error location messages in case of a parse error. |
References init(), m_at_eof, m_lineno, and setInput().
Parser::~Parser | ( | ) |
Cleans up.
References m_scanner.
bool Parser::atEOF | ( | ) |
report EOF state. If parse() returns 0 the caller should check atEOF() in order to distinguish between a syntax error and end-of-file.
References m_at_eof.
Referenced by Y2StdioComponent::doActualWork(), main(), and parsefile().
bool Parser::depends | ( | ) | const |
Only dependencies ?
void Parser::init | ( | ) |
Initialize the internal state of the parser.
References StaticDeclaration::active_predefined(), SymbolTable::endUsage(), m_block_stack, m_blockstack_depth, m_current_block, m_loop_count, m_parser_errors, m_result, m_scanner_stack, m_switch_stack, SymbolTable::startUsage(), and Y2Namespace::table().
YCodePtr Parser::parse | ( | SymbolTable * | gTable = 0 , |
SymbolTable * | lTable = 0 |
||
) |
Reads in as many bytes from the input stream as are neccessary to parse a YCP file.
If gTable and lTable are set, they're used instead of local ones. This is used for include files using the symbol tables of the including block. see: Scanner::initTables()
References init(), Scanner::initTables(), m_at_eof, m_lineno, m_parser_errors, m_result, m_scanner, y2debug, y2internal, yydebug, and yyparse().
Referenced by Y2CCWFM::createInLevel(), main(), parse_client_and_options(), parse_server_and_options(), parsefile(), processfile(), SCRAgent::readconf(), Y2StdioComponent::receive(), Y2ProgramComponent::receiveFromExternal(), Y2SerialComponent::receiveFromSerial(), run_agent_instance(), and Debugger::setVariable().
Scanner * Parser::scanner | ( | ) |
Accesses the scanner
References m_scanner.
Referenced by attach_parameter(), i_check_binary_op(), i_check_unary_op(), parsefile(), start_block(), yyerror_assign_const(), yyerror_cant_cast(), yyerror_no_module(), yyerror_type_mismatch(), yyerror_with_code(), yyerror_with_file(), yyerror_with_lineinfo(), yyerror_with_name(), yyerror_with_tableentry(), yylex(), yywarning_with_lineinfo(), and yywarning_with_tableentry().
void Parser::setBuffered | ( | ) |
Makes the scanner use buffering, i.e. read more than one character at once.
References m_at_eof, m_buffered, m_scanner, and Scanner::setBuffered().
Referenced by Y2CCWFM::createInLevel(), main(), parsefile(), processfile(), and run_agent_instance().
void Parser::setInput | ( | FILE * | file, |
const char * | filename = 0 |
||
) |
use file for further parsing.
filename | If you have the name of the file you parse available, pass it here in order to get nice error location messages in case of a parse error. |
References m_at_eof, m_buffered, m_scanner, and Scanner::setBuffered().
Referenced by Y2SerialComponent::initializeConnection(), Y2ProgramComponent::launchExternalProgram(), main(), parsefile(), Parser(), processfile(), and run_agent_instance().
void Parser::setInput | ( | const char * | buf | ) |
use buf for further parsing
References m_at_eof, m_buffered, m_scanner, and Scanner::setBuffered().
void Parser::setInput | ( | int | fd, |
const char * | filename = 0 |
||
) |
Parse a value from a file descriptor
filename | If you have the name of the file you parse available, pass it here in order to get nice error location messages in case of a parse error. |
References m_at_eof, m_buffered, m_scanner, and Scanner::setBuffered().
void Parser::setScanner | ( | Scanner * | s | ) |
|
private |
If true, the scanner reached EOF.
Referenced by atEOF(), parse(), Parser(), setBuffered(), and setInput().
blockstack_t* Parser::m_block_stack |
Stack of parsed blocks
Referenced by init(), start_block(), and yylex().
int Parser::m_blockstack_depth |
integer number for the depth of the current block
Referenced by _blockstack_pop(), init(), and start_block().
|
private |
Is true, if the input can be buffered, i.e. more than one character may be read at once in order to gain performance.
Referenced by setBuffered(), and setInput().
YBlockPtr Parser::m_current_block |
pointer to the currently parsed block
Referenced by init(), start_block(), and yylex().
|
private |
Is true, if just imported modules and included files are to be checked (make depends)
Referenced by setDepends().
int Parser::m_lineno |
Copied from struct parserret
Referenced by parse(), Parser(), yyerror_assign_const(), yyerror_type_mismatch(), yyerror_with_code(), yyerror_with_file(), yyerror_with_lineinfo(), yyerror_with_name(), yyerror_with_tableentry(), yylex(), yywarning_with_lineinfo(), and yywarning_with_tableentry().
int Parser::m_loop_count |
Loop nesting level. Detects break outside a loop. Was a static variable in parser.yy
Referenced by init().
int Parser::m_parser_errors |
Errors during one parse. Was a static variable in parser.yy
Referenced by init(), parse(), yyerror_assign_const(), yyerror_cant_cast(), yyerror_no_module(), yyerror_type_mismatch(), yyerror_with_code(), yyerror_with_file(), yyerror_with_lineinfo(), yyerror_with_name(), and yyerror_with_tableentry().
YCodePtr Parser::m_result |
|
private |
This is where the parser gets its input from.
Referenced by parse(), scanner(), setBuffered(), setInput(), setScanner(), and ~Parser().
scannerstack_t* Parser::m_scanner_stack |
Scanners used for include parsing
Referenced by init(), start_block(), and yylex().
switchstack_t* Parser::m_switch_stack |
Stack of parsed switches
Referenced by init().