demo_substring_problem.py
Go to the documentation of this file.
00001 #!/usr/bin/env python
00002 #
00003 # License: BSD
00004 #   https://raw.github.com/robotics-in-concert/rocon_tools/license/LICENSE
00005 #
00006 # Substrings in the original module caused problems:
00007 #
00008 # Matching against "foo" | "foo2" below would originally throw these errors:
00009 #
00010 # Parsing rule: "pattern" for string:"foo2"
00011 # .Parsing terminal:"FOO" for string:"foo2"
00012 # <Parsed terminal :"FOO" - value="foo"
00013 # Parsed rule :"pattern" - value="foo"
00014 # foo2
00015 #
00016 # This was originally caused by incorrectly getting the length of the term
00017 # to match inbetween operators.
00018 #
00019 # 
00020 ##############################################################################
00021 # Imports
00022 ##############################################################################
00023 
00024 # enable some python3 compatibility options:
00025 # (unicode_literals not compatible with python2 uuid module)
00026 from __future__ import absolute_import, print_function
00027 
00028 import rocon_ebnf.rule_parser as rule_parser
00029 
00030 ##############################################################################
00031 # Main
00032 ##############################################################################
00033 
00034 if __name__ == '__main__':
00035     print("==================================================")
00036     foo_rules = [
00037              'option verbose',
00038              'pattern           ::= "foo" | "foo2"',
00039               ]
00040     input_string = "foo2"
00041     result = rule_parser.match(foo_rules, input_string)
00042     print("Result %s" % result)
00043     print("==================================================")
00044     foo_rules = [
00045              'option verbose',
00046              'pattern           ::= r"foo" | r"foo2"',
00047               ]
00048     input_string = "foo2"
00049     result = rule_parser.match(foo_rules, input_string)
00050     print("Result %s" % result)
00051     print("==================================================")


rocon_ebnf
Author(s): LParis
autogenerated on Fri May 2 2014 10:35:48