Example #1
0
def parse_intern(buf):
  if glob.g_printtokens:
    print("Printing tokens...")
    lexer.input(buf)
    tok = lexer.token()
    while tok != None:
      print("  ", tok)
      tok = lexer.token()
    print("\n")

  try:
    result = parser.parse(buf)
  except JSCCError:
    sys.exit(-1)
    
  compact_strnodes(result, StrNode)
  compact_strnodes(result, HtmlNode)
  
  if glob.g_printnodes:
    print(result)
  
  buf2 = ""
  buf2 = gen_template(result)
  
  return buf2
Example #2
0
def cs_parse(buf):
  if glob.g_printtokens:
    print("Printing tokens...")
    lexer.input(buf)
    tok = lexer.token()
    while tok != None:
      print("  ", tok)
      tok = lexer.token()
    print("\n")

  try:
    result = parser.parse(buf)
  except JSCCError:
    sys.exit(-1)
    
  compact_strnodes(result, StrNode)
  compact_strnodes(result, HtmlNode)
  
  return result