I've written a program that reads in a Java file including comments and outputs the file without comments.
I consider both line comments //
and block comments /* */
. However, I only use files that don't contain these four characters in any other way: no string literals and no Unicode escape sequences. It only works for files that use these characters exclusively for comments. Can this programme be called a parser? The grammar (either //
and then something or /* and then something and then */
) is regular, right?
I am really only using switch case statements, i.e. implementing a finite state machine. There's no tree built and no stack. I thought that a program is only a parser when it deals with context free languages and at least has a stack, i.e. implements a pushdown automaton. But I have the feeling that the term parser is used rather freely.
To clarify: I'm not looking for ways to get this programme to work with any Java file, I'm just interested in the correct terminology.