Coverage Report

##### Coverage Report - org.webmacro.parser.WMParser

Classes in this File | Line Coverage | Branch Coverage | Complexity
WMParser |
72% | 13/18
N/A | N/A
| 3.0;3

1 |  |
     /*
2 |  |
      * Copyright (C) 1998-2000 Semiotek Inc.  All Rights Reserved.
3 |  |
      *
4 |  |
      * Redistribution and use in source and binary forms, with or without
5 |  |
      * modification, are permitted under the terms of either of the following
6 |  |
      * Open Source licenses:
7 |  |
      *
8 |  |
      * The GNU General Public License, version 2, or any later version, as
9 |  |
      * published by the Free Software Foundation
10 |  |
      * (http://www.fsf.org/copyleft/gpl.html);
11 |  |
      *
12 |  |
      *  or
13 |  |
      *
14 |  |
      * The Semiotek Public License (http://webmacro.org/LICENSE.)
15 |  |
      *
16 |  |
      * This software is provided "as is", with NO WARRANTY, not even the
17 |  |
      * implied warranties of fitness to purpose, or merchantability. You
18 |  |
      * assume all risks and liabilities associated with its use.
19 |  |
      *
20 |  |
      * See www.webmacro.org for more information on the WebMacro project.
21 |  |
      */
22 |  |
23 |  |
     package org.webmacro.parser;
24 |  |
25 |  |
     import java.io.IOException;
26 |  |
     import java.io.Reader;
27 |  |
28 |  |
     import org.slf4j.Logger;
29 |  |
     import org.slf4j.LoggerFactory;
30 |  |
     import org.webmacro.Broker;
31 |  |
     import org.webmacro.engine.BlockBuilder;
32 |  |
     import org.webmacro.engine.Parser;
33 |  |
34 |  |
     /**
35 |  |
      * @author Brian Goetz
36 |  |
      */
37 |  |
     public class WMParser implements Parser
38 |  |
     {
39 |  |
40 | 2 |
         static Logger _log =  LoggerFactory.getLogger(WMParser.class);
41 |  |
         private final Broker _broker;
42 |  |
43 |  |
         public WMParser (Broker b)
44 | 6 |
         {
45 | 6 |
             _broker = b;
46 | 6 |
             _log.info("parser created");
47 | 6 |
         }
48 |  |
49 |  |
         // Parser Interface
50 |  |
51 |  |
         /**
52 |  |
          * Return a short name that identifies this parser. This name could,
53 |  |
          * for example, be used as the extension for files which contain
54 |  |
          * syntax parsable by this parser.
55 |  |
          */
56 |  |
         public final String getParserName ()
57 |  |
         {
58 | 0 |
             return "wm";
59 |  |
         }
60 |  |
61 |  |
         /**
62 |  |
          * Parse a block that appears on the supplied input Reader. The
63 |  |
          * name supplied is used in error messages to identify the source
64 |  |
          * being parsed.
65 |  |
          */
66 |  |
         public BlockBuilder parseBlock (String name, Reader in)
67 |  |
                 throws org.webmacro.engine.ParseException, IOException
68 |  |
         {
69 |  |
             BlockBuilder bb;
70 | 228 |
             WMParser_impl parser = null;
71 |  |
             try
72 |  |
             {
73 | 228 |
                 parser = new WMParser_impl(_broker, name, in);
74 |  |
75 |  |
                 try
76 |  |
                 {
77 | 228 |
                     bb = parser.WMDocument();
78 |  |
                 }
79 | 0 |
                 catch (TokenMgrError e)
80 |  |
                 {
81 | 0 |
                     throw new ParseException("Lexical error: " + e.toString());
82 | 224 |
                 }
83 |  |
             }
84 | 4 |
             catch (ParseException e)
85 |  |
             {
86 | 4 |
                 throw new org.webmacro.engine.ParseException("Parser Exception", e);
87 |  |
             }
88 | 0 |
             catch (ParserRuntimeException e)
89 |  |
             {
90 | 0 |
                 throw new org.webmacro.engine.ParseException("Parse Exception", e);
91 | 224 |
             }
92 |  |
93 | 224 |
             return bb;
94 |  |
         }
95 |  |
96 |  |
     }
97 |  |
98 |  |