grammar PIR::Grammar; # # pasm_ops.g - contains grammar for all PASM instructions [1]. # # [1] all except for: # dot gnu # experimental # obscure # python # ops. # # The math ops may be implemented as a library instead in the future? # # # For most instructions, the arguments are handled by the rule # , which takes 0 or more (comma-separated) arguments. # it is *a lot* of work to fix this, so for now just want to test # general working of the PIR parser. # # PASM instructions (pure PASM) go here # rule pasm_instr { | | | | | | | | | | | } rule bitwise_op { band \, [ \, ]? | bands \, [ \, ]? | bnot [ \, ]? | n_bnot \, | bnots [ \, ]? | n_bnots \, | bor \, [ \, ]? | bors \, [ \, ]? | shl \, [ \, ]? | shr \, [ \, ]? | lsr \, [ \, ]? | rot \, \, \, | bxor \, [ \, ]? | bxors \, [ \, ]? } rule comparison_op { eq | eq_str | eq_num | eq_addr | ne | ne_str | ne_num | ne_addr | lt | lt_str | lt_num | lt_addr | le | le_str | le_num | le_addr | gt | gt_str | gt_num | gt_addr | ge | ge_str | ge_num | ge_addr | if_null \, | unless_null \, | cmp | cmp_str | cmp_num | issame | isntsame | istrue [ | ] \, | isfalse [ | ] \, | isnull [ | ] \, | isge | isgt | isle | islt | iseq | isne | and [ | ] \, \, | not [ \, ]? | n_not \, | or [ | ] \, \, | xor [ | ] \, \, } rule debug_op { debug_init | debug_load | debug_break | debug_print | backtrace | getline | getfile } rule loading_op { clone | exchange | set \, | assign # | setref # | deref # | setp_ind # | setn_ind # | sets_ind # | seti_ind # | null # | cleari # | clearn # | clearp # | clears # } rule stack_op { saveall # | restoreall # | entrytype # | depth # | lookback # | save # | savec # | restore # | rotate_up # } rule system_op { spawnw # | err # | time # | gmtime # | localtime # | decodetime # | decodelocaltime # | sysinfo # | sleep # | sizeof # } rule var_op { store_lex # | find_lex # | get_namespace # | get_hll_namespace # | get_root_namespace # | get_global # | get_hll_global # | get_root_global # | set_global # | set_hll_global # | set_root_global # } # TODO: # # define "argument" rules, so that not each instruction has to # define it's specific number and types of args. # for instance: args_v_i_s for matching a argument, # argument and a argument #