TeX can change the meaning of characters at run time, so it's not context free.
How to define the grammar for TeX/LaTeX and Makefile?
Question
Both are technologies that are expressed via languages full of macros, but in a more technical terms, what is the kind of grammar and how to describe their own properties ?
I'm not interested in a graphical representation, by properties I mean a descriptive phrase about this subject, so please don't just go for a BNF/EBNF oriented response full of arcs and graphs .
I assume that both are context-free grammars, but this is a big family of grammars, there is a way to describe this 2 in a more precise way ?
Thanks.
No correct solution
OTHER TIPS
Is my language Context-Free?
I believe that every useful language ends up being Turing-complete, reflexive, etc.
Fortunately that is not the end of the story.
Most of the parser generation tools (yacc, antler, etc) process up to context-free grammars (CFG).
So we divide the language processing problem in 3 steps:
- Build an over-generating CFG; this is the "syntactical" part that constitutes a solid base where we add the other components,
- Add "semantic" constraints (with some extra syntactic and semantic constraints)
- main semantics ( static semantics, pragmatics, attributive semantics, etc)
Writing a context-free grammar is a very standard way of speaking about all the languages! It is a very clear and didactic notation for languages!! (and sometimes is not telling all the truth).
When We say that "is not context-free, is Turing-complete, ..." you can translate it to "you can count with lots of semantic extra work" :)
How can I speak about it?
Many choices available. I like to do a subset of the following:
- Write a clear semantic oriented CFG
- for each symbol (T or NT) add/define a set of semantic attributes
- for each production rule: add syntactic/semantic constraints predicates
- for each production rule: add a set equations to define the values of the attributes
- for each production rule: add a English explanation, examples, etc