CDSoft / pp

PP - Generic preprocessor (with pandoc in mind) - macros, literate programming, diagrams, scripts...
http://cdelord.fr/pp
GNU General Public License v3.0
252 stars 21 forks source link

Valid Macro's Name Chars? #18

Closed tajmone closed 6 years ago

tajmone commented 7 years ago

I've looked at the source code but couldn't find any references (RegEx, etc) to what constitutes a valid macro name.

Which characters can be used in a macro's name? I assume the usual a-zA-Z0-9_-, but what about special chars (like: $#@;: and so on)?

If I've understood correctly, macro's names are case sensitive; therefore !hello and !Hello would be two distinct macros.

And (I assum) user defined macros can't take the name of a built-in macro (at least not with the same letter casing).

Are these last two assumptions correct?

CDSoft commented 7 years ago

Valid macro names are made of letters, digits and underscores (a-zA-Z0-9_). You can define (this is a bug!) macros with any characters but you won't be able to use these macros). pp should report an error if the macro name is invalid. Also if you define a macro with a builtin name, it won't be usable.

The parser is not based on regular expressions but on functions.

Macro names are case-sensitive.

CDSoft commented 7 years ago

bug fixed. pp will now print an error message is the name is invalid or built-in.

robinrosenstock commented 6 years ago

Can we reopen this please: Why not allow the dash - as a macro name character?

CDSoft commented 6 years ago

Is there a real need for this? I guess it would break existing documents and the dash is rarely used in identifiers (which language does this?). dash is already used in expression.

robinrosenstock commented 6 years ago

For example when using the macro: !define(my_special_symbol) then in my markdown document the word special gets syntax highlighted as italics in my editor (only in the source document of course). But this is really the only issue I can think off. And now I realize that you can change the syntax highlighting in your code editor to remedy this, though its a bit of work, too (on my side)

CDSoft commented 6 years ago

This is a more general problem when mixing different syntax in a single file. e.g. if I use wildcards (*) in shell macro parameters, the rest of the document is rendered as italic or bold text in vim. I also think the solution is to change the syntax highlighting but it's specific to:

Specific workaround for your case: don't use underscores ;-) (e.g.: mySpecialSymbol).

robinrosenstock commented 6 years ago

Alright, then this issue should be closed again.