system/src/sc/parser/Language.java
public Object parse(String fileName, Reader reader, Parselet start, boolean enablePartialValues, boolean matchOnly, Object toPopulateInst, int bufSize) {
      try {
         if (!start.initialized) {
            // First make sure the language is initialized
            initialize();
            // If this parselet is not reachable from the children of the startParselet, it may not yet be started so start it here just in case
            if (!start.initialized)
               ParseUtil.initAndStartComponent(start);
         }
         Parser p = new Parser(this, reader, bufSize);
         p.enablePartialValues = enablePartialValues;
         p.matchOnly = matchOnly;
         p.populateInst = toPopulateInst;
         Object parseTree = p.parseStart(start);
         if (parseTree instanceof IParseNode) {
            if (!p.atEOF()) {
               if (enablePartialValues) {
                  parseTree = wrapPartialParseNode(parseTree, p);
                  IParseNode parseNode = (IParseNode) parseTree;
                  postProcessResult(parseTree, fileName);
                  if (debugReparse) {
                     System.out.println("*** EOF - parsed: " + parseNode.length() + " out of: " + p.length() + " characters");
                     globalParseCt += p.totalParseCt;
                  }
                  return p.parseError(start, parseTree, null, "Invalid text at end of file", 0, p.length());
               }
               else {
                  // TODO: maybe for this case, we should always enable partial values and reparse so we get better error messages?
                  // For now, we're letting subclasses determine the error in this case.  If the current parse is some recognizable string - e.g.
                  // a mismatching close tag, we can provide a nice specific error rather than a jumble of failed attempts to parse
                  parseTree = incompleteParse(p);
               }
            }
            else
               p.clearForSuccess();
         }
         else if (parseTree instanceof ParseError) {
            if (!p.atEOF()) {
               wrapPartialValues((ParseError) parseTree, p);
            }
         }

         if (debugReparse) {
            globalParseCt += p.totalParseCt;
         }

         postProcessResult(parseTree, fileName);
         return parseTree;
      }
      finally {
         try {
            reader.close();
         }
         catch (IOException exc) {
            System.err.println("*** Failed to close the reader for parsing: " + fileName + ": " + exc);
         }
      }
   }
/**
    * This is the variant you can safely override because all calls go through here.  The fileName argument may be null but helps the TemplateLanguage do its
    * processing of the file.  The matchOnly just returns a true/false if this is parseable without doing all of the work of parsing it.  You can provide an
    * instance in the rare case you want to use it as the default semantic node object for the parser to work on.  The bufSize is a tunable parameter to
    * choose the size of the buffer, useful if you are parsing a small string or something.
    */
This is the variant you can safely override because all calls go through here.  The fileName argument may be null but helps the TemplateLanguage do its
processing of the file.  The matchOnly just returns a true/false if this is parseable without doing all of the work of parsing it.  You can provide an
instance in the rare case you want to use it as the default semantic node object for the parser to work on.  The bufSize is a tunable parameter to
choose the size of the buffer, useful if you are parsing a small string or something.
This is the variant you can safely override because all calls go through here . The fileName argument may be null but helps the TemplateLanguage do its processing of the file . The matchOnly just returns a true / false if this is parseable without doing all of the work of parsing it . You can provide an instance in the rare case you want to use it as the default semantic node object for the parser to work on . The bufSize is a tunable parameter to choose the size of the buffer useful if you are parsing a small string or something .
public Object parse(String fileName, Reader reader, Parselet start, boolean enablePartialValues, boolean matchOnly, Object toPopulateInst, int bufSize) {
      try {
         if (!start.initialized) {
            initialize();
            if (!start.initialized)
               ParseUtil.initAndStartComponent(start);
         }
         Parser p = new Parser(this, reader, bufSize);
         p.enablePartialValues = enablePartialValues;
         p.matchOnly = matchOnly;
         p.populateInst = toPopulateInst;
         Object parseTree = p.parseStart(start);
         if (parseTree instanceof IParseNode) {
            if (!p.atEOF()) {
               if (enablePartialValues) {
                  parseTree = wrapPartialParseNode(parseTree, p);
                  IParseNode parseNode = (IParseNode) parseTree;
                  postProcessResult(parseTree, fileName);
                  if (debugReparse) {
                     System.out.println("*** EOF - parsed: " + parseNode.length() + " out of: " + p.length() + " characters");
                     globalParseCt += p.totalParseCt;
                  }
                  return p.parseError(start, parseTree, null, "Invalid text at end of file", 0, p.length());
               }
               else {
                  parseTree = incompleteParse(p);
               }
            }
            else
               p.clearForSuccess();
         }
         else if (parseTree instanceof ParseError) {
            if (!p.atEOF()) {
               wrapPartialValues((ParseError) parseTree, p);
            }
         }
         if (debugReparse) {
            globalParseCt += p.totalParseCt;
         }
         postProcessResult(parseTree, fileName);
         return parseTree;
      }
      finally {
         try {
            reader.close();
         }
         catch (IOException exc) {
            System.err.println("*** Failed to close the reader for parsing: " + fileName + ": " + exc);
         }
      }
   }
public Object parse ( String fileName , Reader reader , Parselet start , boolean enablePartialValues , boolean matchOnly , Object toPopulateInst , int bufSize ) { try { if ( ! start . initialized ) { initialize ( ) ; if ( ! start . initialized ) ParseUtil . initAndStartComponent ( start ) ; } Parser p = new Parser ( this , reader , bufSize ) ; p . enablePartialValues = enablePartialValues ; p . matchOnly = matchOnly ; p . populateInst = toPopulateInst ; Object parseTree = p . parseStart ( start ) ; if ( parseTree instanceof IParseNode ) { if ( ! p . atEOF ( ) ) { if ( enablePartialValues ) { parseTree = wrapPartialParseNode ( parseTree , p ) ; IParseNode parseNode = ( IParseNode ) parseTree ; postProcessResult ( parseTree , fileName ) ; if ( debugReparse ) { System . out . println ( "*** EOF - parsed: " + parseNode . length ( ) + " out of: " + p . length ( ) + " characters" ) ; globalParseCt += p . totalParseCt ; } return p . parseError ( start , parseTree , null , "Invalid text at end of file" , 0 , p . length ( ) ) ; } else { parseTree = incompleteParse ( p ) ; } } else p . clearForSuccess ( ) ; } else if ( parseTree instanceof ParseError ) { if ( ! p . atEOF ( ) ) { wrapPartialValues ( ( ParseError ) parseTree , p ) ; } } if ( debugReparse ) { globalParseCt += p . totalParseCt ; } postProcessResult ( parseTree , fileName ) ; return parseTree ; } finally { try { reader . close ( ) ; } catch ( IOException exc ) { System . err . println ( "*** Failed to close the reader for parsing: " + fileName + ": " + exc ) ; } } }
This is the variant you can safely override because all calls go through here.
This is the variant you can safely override because all calls go through here .
// First make sure the language is initialized // If this parselet is not reachable from the children of the startParselet, it may not yet be started so start it here just in case // TODO: maybe for this case, we should always enable partial values and reparse so we get better error messages? // For now, we're letting subclasses determine the error in this case.  If the current parse is some recognizable string - e.g. // a mismatching close tag, we can provide a nice specific error rather than a jumble of failed attempts to parse