/tutorial/backtracking/tiny_parse/perser.e
Specman e | 54 lines | 44 code | 8 blank | 2 comment | 0 complexity | 7b8f73b16f7288173ebcbad6b61dbc17 MD5 | raw file
1class PARSER 2inherit BACKTRACKING 3feature 4 5 get_context: PARSER_CONTEXT is 6 do 7 Result.make(stack.count,position) 8 end 9 10 restore_context(ctxt: PARSER_CONTEXT) is 11 do 12 stack.resize(ctxt.depth) 13 position := ctxt.position 14 end 15 16 push_mark_begin(what: PARSER_PARSEABLE) is 17 local 18 mark: PARSER_MARK 19 do 20 mark.make_begin(position,what) 21 stack.add_last(mark) 22 end 23 24 push_mark_end(what: PARSER_PARSEABLE) is 25 local 26 mark: PARSER_MARK 27 do 28 mark.make_end(position,what) 29 stack.add_last(mark) 30 end 31 32 push_and_mark_end(what: PARSER_PARSEABLE) is 33 local 34 sequence: PARSER_SEQUENCE_MARK_END 35 do 36 sequence := pool_of_mark_end.get_instance 37 sequence.set_parseable(what) 38 push_sequence(sequence) 39 end 40 41 goto(what: PARSER_PARSEABLE) is 42 do 43 -- TODO bouffer les blancs 44 -- memoriser what 45 end 46 47 goto_inside(what: PARSER_PARSEABLE) is 48 do 49 goto(what) 50 push_mark_begin(what) 51 push_and_mark_end(what) 52 end 53end 54