Showing results for 
Search instead for 
Did you mean: 

Python Parser



I have Heidenhain TNC but - for ISO code, program.I 

I understand, that I cannot use library parser and try to use Python Parser. I see few times video-lessons from Knoweledge Base (thanks for this materials) but:

For example, I need simulate G71 for my ISO programm

If I use Heidenhain TNC controller for Global Configurations Machine Configuratior - I cannot to add any G-commands. 

If I use like FANUC - I have a message "Dll Parser for Python is old version...."

Ok, I set FANUC, add G71, and return back to Heidenhaine. I can see G71 but red color. 

If I try to add


def p_lineContent_22(self,p):
'''lineContent : 'G71''''
dictArgsNC = {}


I see a message "old DLL Python parser"...... 


How I can add G71 for heid ISO?! 






Re: Python Parser

Solution Partner Phenom Solution Partner Phenom
Solution Partner Phenom

I try to "learn" my parser to understand ";" as comment


I add to LEX token 'COMMENT'


and two cases


def t_COMMENT_1(t):
    t.type = 'COMMENT'
    return t

def t_COMMENT_2(t):
    r'\*[ \t]*-(.)*'
    t.type = 'COMMENT'
    return t


for Yacc


    def p_optionalComment_1(self, p):
        '''optionalComment : '''

    def p_optionalComment_2(self, p):
        '''optionalComment : COMMENT'''



And I have error in log-file

A Python error occurred during parsing of line ';(PART: test_1250.prt)'.

'NoneType' object has no attribute 'write'


Re: Python Parser

Siemens Phenom Siemens Phenom
Siemens Phenom

let me clarify some points. Maybe that helps better to understand the different problems.
1. The message "old dll Python parser..." relies on the dll parser setting in Machine Configurator (General -- Implementation -- Library) and has nothing to do with you python code

2. Adding commands, variables, etc. in Machine Configurator (MC) is independent of the used parser or parser type itself. In MC you configure the command logic only. The parser itself is a complete different story.

3. "I cannot to add any G-commands." --> Select 'Current File' as source of command list on top left in MC. Current file means the opened file (regulary the MCF file). When you´re not able to add a command, variable, etc. add a metacode group first, After that you are able to add a e.g. command

Hope that helps if not reply to that topic


Re: Python Parser

Siemens Phenom Siemens Phenom
Siemens Phenom
Hi Yuri,

please post the entire trace back line of that error.
Are you writing your own parser from scratch or do you use Fanuc or Heidenhain files as base?

My first idea is that there is a regression with ';' and the '(' within the YACC file.
I would also start as simple as possible with the first Comment Lex rule. The complexity comes later ;-)


Learn online

Solution Information