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