/** * Parses a learning classifier expression out of an encoded string using the automatically * generated scanner and parser. * * @param s The string out of which the learning classifier expression will be parsed. * @return The parsed learning classifier expression. **/ private static LearningClassifierExpression parseLCE(String s) { Reader reader = null; try { reader = new BufferedReader(new InputStreamReader(new GZIPInputStream( new HexStringInputStream(s)))); } catch (Exception e) { System.err.println("LBJava ERROR: Can't instantiate string parser for LCE:"); e.printStackTrace(); System.exit(1); } AST ast = null; try { ast = (AST) new parser(new Yylex(reader)).parse().value; } catch (Exception e) { System.err.println("LBJava ERROR: Can't parse LCE from string:"); e.printStackTrace(); System.exit(1); } SemanticAnalysis.runAndRestore(ast); ClassifierAssignment ca = (ClassifierAssignment) ast.declarations.iterator().next(); return (LearningClassifierExpression) ca.expression; }
/** Parse the grammar specification from standard input. This produces * sets of terminal, non-terminals, and productions which can be accessed * via static variables of the respective classes, as well as the setting * of various variables (mostly in the emit class) for small user supplied * items such as the code to scan with. */ protected static void parse_grammar_spec() throws java.lang.Exception { parser parser_obj; /* create a parser and parse with it */ parser_obj = new parser(); try { if (opt_do_debug) parser_obj.debug_parse(); else parser_obj.parse(); } catch (Exception e) { /* something threw an exception. catch it and emit a message so we have a line number to work with, then re-throw it */ lexer.emit_error("Internal error: Unexpected exception"); throw e; } }
/** Parse the grammar specification from standard input. This produces * sets of terminal, non-terminals, and productions which can be accessed * via static variables of the respective classes, as well as the setting * of various variables (mostly in the emit class) for small user supplied * items such as the code to scan with. */ protected static void parse_grammar_spec() throws java.lang.Exception { parser parser_obj; /* create a parser and parse with it */ parser_obj = new parser(); try { if (opt_do_debug) parser_obj.debug_parse(); else parser_obj.parse(); } catch (Exception e) { /* something threw an exception. catch it and emit a message so we have a line number to work with, then re-throw it */ lexer.emit_error("Internal error: Unexpected exception"); throw e; } }
/** Parse the grammar specification from standard input. This produces * sets of terminal, non-terminals, and productions which can be accessed * via static variables of the respective classes, as well as the setting * of various variables (mostly in the emit class) for small user supplied * items such as the code to scan with. */ protected static void parse_grammar_spec() throws java.lang.Exception { parser parser_obj; /* create a parser and parse with it */ parser_obj = new parser(); try { if (opt_do_debug) parser_obj.debug_parse(); else parser_obj.parse(); } catch (Exception e) { /* something threw an exception. catch it and emit a message so we have a line number to work with, then re-throw it */ lexer.emit_error("Internal error: Unexpected exception"); throw e; } }
/** Parse the grammar specification from standard input. This produces * sets of terminal, non-terminals, and productions which can be accessed * via static variables of the respective classes, as well as the setting * of various variables (mostly in the emit class) for small user supplied * items such as the code to scan with. */ protected static void parse_grammar_spec() throws java.lang.Exception { parser parser_obj; /* create a parser and parse with it */ parser_obj = new parser(); try { if (opt_do_debug) parser_obj.debug_parse(); else parser_obj.parse(); } catch (Exception e) { /* something threw an exception. catch it and emit a message so we have a line number to work with, then re-throw it */ lexer.emit_error("Internal error: Unexpected exception"); throw e; } }
/** Parse the grammar specification from standard input. This produces * sets of terminal, non-terminals, and productions which can be accessed * via static variables of the respective classes, as well as the setting * of various variables (mostly in the emit class) for small user supplied * items such as the code to scan with. */ protected static void parse_grammar_spec() throws java.lang.Exception { parser parser_obj; /* create a parser and parse with it */ ComplexSymbolFactory csf = new ComplexSymbolFactory(); parser_obj = new parser(new Lexer(csf),csf); parser_obj.setDebugSymbols(opt_do_debugsymbols); try { if (opt_do_debug) parser_obj.debug_parse(); else parser_obj.parse(); } catch (Exception e) { /* something threw an exception. catch it and emit a message so we have a line number to work with, then re-throw it */ ErrorManager.getManager().emit_error("Internal error: Unexpected exception"); throw e; } }
/** Parse the grammar specification from standard input. This produces * sets of terminal, non-terminals, and productions which can be accessed * via static variables of the respective classes, as well as the setting * of various variables (mostly in the emit class) for small user supplied * items such as the code to scan with. */ protected static void parse_grammar_spec() throws java.lang.Exception { parser parser_obj; /* create a parser and parse with it */ ComplexSymbolFactory csf = new ComplexSymbolFactory(); parser_obj = new parser(new Lexer(csf),csf); try { if (opt_do_debug) parser_obj.debug_parse(); else parser_obj.parse(); } catch (Exception e) { /* something threw an exception. catch it and emit a message so we have a line number to work with, then re-throw it */ ErrorManager.getManager().emit_error("Internal error: Unexpected exception"); throw e; } }