#-----------------------------------------------------------------------------* # # @file gtl_debugger_parser.galgas # # @section desc File description # # Debugger parser for GTL. # # @section copyright Copyright # # GTL template language, part of Trampoline RTOS # # Trampoline is copyright (c) CNRS, University of Nantes, # Ecole Centrale de Nantes # Trampoline is protected by the French intellectual property law. # # This software is distributed under the GNU Public Licence V2. # Check the LICENSE file in the root directory of Trampoline # # $Date$ # $Rev$ # $Author$ # $URL$ # #-----------------------------------------------------------------------------* syntax gtl_debugger_parser (gtl_debugger_scanner) { #-----------------------------------------------------------------------------* rule !@gtlExpression expression rule !@gtlVarPath path #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { select $cont$ or $continue$ end instruction = @gtlContinueInstruction.new { !.here !"" } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $help$ instruction = @gtlHelpInstruction.new { !.here !"" } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $step$ instruction = @gtlStepInstruction.new { !.here !"" } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $load$ let @lstring fileName select $identifier$ ?fileName or $string$ ?fileName end instruction = @gtlLoadInstruction.new { !.here !"" !fileName } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $hist$ instruction = @gtlHistoryInstruction.new { !.here !"" } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $break$ select $not$ select $signed_literal_integer_bigint$ ?let @lbigint index instruction = @gtlBreakpointDeleteInstruction.new { !.here !"" !index } or $all$ instruction = @gtlBreakpointDeleteAllInstruction.new { !.here !"" } end or select $identifier$ ?let @lstring fileName $.$ $identifier$ ?let @lstring fileExtension $:$ $signed_literal_integer_bigint$ ?let @lbigint lineNum instruction = @gtlBreakpointInstruction.new { !.here !"" ![fileName string] + "." + fileExtension ![lineNum bigint] } or $signed_literal_integer_bigint$ ?let @lbigint lineNum instruction = @gtlBreakpointInstruction.new { !.here !"" !"" ![lineNum bigint] } end or $string$ ?let @lstring fileNameAndLineNum let @stringlist components = [[fileNameAndLineNum string] componentsSeparatedByString !":"] if [components length] == 2 then let @string fileName = [components mValueAtIndex !0] let @string lineNum = [components mValueAtIndex !1] instruction = @gtlBreakpointInstruction.new { !.here !"" !fileName ![lineNum decimalUnsignedNumber] } else error .here : "Illegal breakpoint location" : instruction end or instruction = @gtlBreakpointListInstruction.new { !.here !"" } end } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $watch$ select $not$ select $signed_literal_integer_bigint$ ?let @lbigint index instruction = @gtlWatchpointDeleteInstruction.new { !.here !"" !index } or $all$ instruction = @gtlWatchpointDeleteAllInstruction.new { !.here !"" } end or $($ ?let @gtlExpression watchExpression instruction = @gtlWatchpointInstruction.new { !.here !"" !watchExpression } $)$ or instruction = @gtlWatchpointListInstruction.new { !.here !"" } end } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $do$ select ?let @gtlInstruction instructionToStepDo instruction = @gtlDoInstInstruction.new { !.here !"" !instructionToStepDo } or $not$ select $signed_literal_integer_bigint$ ?let @lbigint num instruction = @gtlDoNotInstruction.new { !.here !"" !num } or $all$ instruction = @gtlDoNotAllInstruction.new { !.here !"" } end or instruction = @gtlDoInstruction.new { !.here !"" } end } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { instruction = @gtlStepInstruction.new { !.here !"" } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $let$ ?let @gtlVarPath variable select $:=$ ?let @gtlExpression expression instruction = @gtlLetInstruction.new { !.here !"" !variable !expression } or $+=$ ?let @gtlExpression expression instruction = @gtlLetAddInstruction.new { !.here !"" !variable !expression } or $-=$ ?let @gtlExpression expression instruction = @gtlLetSubstractInstruction.new { !.here !"" !variable !expression } or $*=$ ?let @gtlExpression expression instruction = @gtlLetMultiplyInstruction.new { !.here !"" !variable !expression } or $/=$ ?let @gtlExpression expression instruction = @gtlLetDivideInstruction.new { !.here !"" !variable !expression } or $mod=$ ?let @gtlExpression expression instruction = @gtlLetModuloInstruction.new { !.here !"" !variable !expression } or $<<=$ ?let @gtlExpression expression instruction = @gtlLetShiftLeftInstruction.new { !.here !"" !variable !expression } or $>>=$ ?let @gtlExpression expression instruction = @gtlLetShiftRightInstruction.new { !.here !"" !variable !expression } or $&=$ ?let @gtlExpression expression instruction = @gtlLetAndInstruction.new { !.here !"" !variable !expression } or $|=$ ?let @gtlExpression expression instruction = @gtlLetOrInstruction.new { !.here !"" !variable !expression } or $^=$ ?let @gtlExpression expression instruction = @gtlLetXorInstruction.new { !.here !"" !variable !expression } or instruction = @gtlLetUnconstructedInstruction.new { !.here !"" !variable } end } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $unlet$ ?let @gtlVarPath variable instruction = @gtlUnletInstruction.new { !.here !"" !variable } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { ?instruction } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $variables$ instruction = @gtlVariablesInstruction.new { !.here !"" !true } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $display$ ?let @gtlVarPath variable instruction = @gtlDisplayStatementInstruction.new { !.here !"" !variable } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $print$ ?let @gtlExpression expression instruction = @gtlPrintStatementInstruction.new { !.here !"" !true !expression } } #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { $list$ @uint window = 5 select $signed_literal_integer_bigint$ ?let @lbigint num window = [[num bigint] uint] if window > 10 then window = 10 end or end instruction = @gtlListInstruction.new { !.here !"" !window } } #-----------------------------------------------------------------------------* # if ... elsif ... else ... end if instruction in a module #-----------------------------------------------------------------------------* rule !@gtlInstruction instruction { @gtlThenElsifStatementList thenElsifList = .emptyList @gtlInstructionList elseList = .emptyList $if$ let @location where = .here repeat ?let @gtlExpression condition $then$ ?let @gtlInstructionList instructionList thenElsifList += !condition !instructionList while $elsif$ end #--- else select $else$ ?elseList or end #--- $end$ $if$ instruction = @gtlIfStatementInstruction.new { !where !signature(!where) !thenElsifList !elseList } } #-----------------------------------------------------------------------------* # Instruction list in a setter, getter or function or any control instruction #-----------------------------------------------------------------------------* rule !@gtlInstructionList instructionList { instructionList = .emptyList repeat while ?let @gtlInstruction instruction instructionList += !instruction end } }