On Thu, Jun 13, 2019 at 6:51 AM Yanghao Hua <yanghao...@gmail.com> wrote: > > On Wed, Jun 12, 2019 at 9:39 AM Chris Angelico <ros...@gmail.com> wrote: > > If Python is really THAT close, then devise two syntaxes: an abstract > > syntax for your actual source code, and then a concrete syntax that > > can be executed. It's okay for things to be a little bit ugly (like > > "signal[:] = 42") in the concrete form, because you won't actually be > > editing that. Then your program just has to transform one into the > > other, and then run the program. > > Thought about that too .... but as you can imagine, you can write: > > x <== 3 # or > x \ > <== 3 # or > x \ > \ > ... > \ <== 3 # This is crazy but valid python syntax! > # more crazy ones are skipped ... > > so this is not a simple text replacement problem, eventually you end > up writing a python parser? Or a HDL parser.
Yes, you would need some sort of syntactic parser. There are a couple of ways to go about it. One is to make use of Python's own tools, like the ast module; the other is to mandate that your specific syntax be "tidier" than the rest of the Python code, which would permit you to use a more naive and simplistic parser (even a regex). ChrisA _______________________________________________ Python-ideas mailing list -- python-ideas@python.org To unsubscribe send an email to python-ideas-le...@python.org https://mail.python.org/mailman3/lists/python-ideas.python.org/ Message archived at https://mail.python.org/archives/list/python-ideas@python.org/message/BCGYTPPODZCFLFSETZOXPAQFKPGJ6ZVT/ Code of Conduct: http://python.org/psf/codeofconduct/