MCPcopy Create free account
hub / github.com/Duet3D/RepRapFirmware / THROWS

Function THROWS

src/GCodes/GCodeBuffer/StringParser.cpp:355–445  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

353// Check whether the current command is a meta command, or we are skipping commands in a block
354// Return true if the current line no longer needs to be processed
355bool StringParser::CheckMetaCommand(const StringRef& reply) THROWS(GCodeException)
356{
357 // Ignore comment lines, if they are not indented they mess up the control flow. They may still need to be processed so return false.
358 if (gb.buffer[0] == ';')
359 {
360 return false;
361 }
362
363 if (overflowed)
364 {
365 throw GCodeException(&gb, ARRAY_SIZE(gb.buffer) + commandIndent - 1, "GCode command too long");
366 }
367
368 const bool doingFile = gb.IsDoingFile();
369 BlockType skippedBlockType = BlockType::plain;
370 if (doingFile)
371 {
372 // Deal with warning about mixed spaces and tabs
373 if (commandIndent == 0)
374 {
375 seenLeadingSpace = seenLeadingTab = false; // it's OK if the previous block used only space and the following one uses only tab, or v.v.
376 }
377 else
378 {
379 CheckForMixedSpacesAndTabs();
380 }
381
382 // Deal with skipping blocks
383 if (indentToSkipTo != NoIndentSkip)
384 {
385 if (indentToSkipTo < commandIndent)
386 {
387 Init();
388 return true; // continue skipping this block
389 }
390 else
391 {
392 // Finished skipping the nested block
393 if (indentToSkipTo == commandIndent)
394 {
395 skippedBlockType = gb.GetBlockState().GetType(); // save the type of the block we skipped in case the command is 'else' or 'elif'
396 gb.GetBlockState().SetPlainBlock(); // we've ended the loop or if-block
397 }
398 indentToSkipTo = NoIndentSkip; // no longer skipping
399 }
400 }
401
402 while (commandIndent < gb.GetBlockIndent())
403 {
404 gb.CurrentFileMachineState().EndBlock();
405 if (gb.GetBlockState().GetType() == BlockType::loop)
406 {
407 // Go back to the start of the loop and re-evaluate the while-part
408 gb.CurrentFileMachineState().lineNumber = gb.GetBlockState().GetLineNumber();
409#if SUPPORT_ASYNC_MOVES
410 gb.CurrentFileMachineState().fpos = gb.GetBlockState().GetFilePosition();
411#endif
412 gb.RestartFrom(gb.GetBlockState().GetFilePosition());

Callers

nothing calls this directly

Calls 15

SetPlainBlockMethod · 0.80
EndBlockMethod · 0.80
GetLineNumberMethod · 0.80
RestartFromMethod · 0.80
CreateBlockMethod · 0.80
SetIfTrueBlockMethod · 0.80
IncrementIterationsMethod · 0.80
SetLoopBlockMethod · 0.80
ExecutingMethod · 0.80

Tested by

no test coverage detected