5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
|
# File 'lib/cooklang/parser.rb', line 5
def parse(input)
lexer = Lexer.new(input)
tokens = lexer.tokenize
metadata, content_tokens = Processors::MetadataProcessor.(tokens)
cleaned_tokens = Processors::TokenProcessor.(content_tokens)
notes, recipe_tokens = Processors::TokenProcessor.(cleaned_tokens)
parsed_steps = Processors::StepProcessor.parse_steps(recipe_tokens)
recipe = Builders::RecipeBuilder.build_recipe(parsed_steps, metadata)
Recipe.new(
ingredients: recipe.ingredients,
cookware: recipe.cookware,
timers: recipe.timers,
steps: recipe.steps,
metadata: recipe.metadata,
sections: recipe.sections,
notes: notes
)
end
|