8000 Scoping condition on a "local" keyword · textX textX · Discussion #387 · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Scoping condition on a "local" keyword #387

Answered by goto40
christian-oreilly asked this question in Q&A
Discussion options

You must be logged in to vote

I quickly made the demo:

from textx.metamodel import metamodel_from_str 
from textx.exceptions import TextXError

grammar = """
 Program:
     variables *= Variables
     functions *= Function; 

 Function: 'FUNCTION'
     locals += Locals
     assignements *= Assignment
     'END';

 Local: name=ID;
 Locals: 'LOCAL' vars*=Local[','];
 Variables: 'VARIABLES' vars*=Variable[','];
 Var: Local | Variable ; 
 Variable: name=ID;
 Assignment: variable=[Var|ID|..~locals.vars,~variables.vars] '=' value=Number;
 Number: /[+-]?(\d+(\.\d*)?|\.\d+)([eE][+-]?\d+)?/;
 """
try:
    meta = metamodel_from_str(grammar, autokwd=True)
    print("Meta-Model OK")
except TextXError as e:
    print("Error in met…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Answer selected by christian-oreilly
Comment options

You must be logged in to vote
2 replies
@goto40
Comment options

@christian-oreilly
Comment options

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
0