java - Is this program already a parser? -
i've written program reads in java file including comments , outputs file without comments.
i consider both line comments //
, block comments /* */
. however, use files don't contain these 4 characters in other way: no string literals , no unicode escape sequences. works files use these characters exclusively comments. can programme called parser? grammar (either //
, or /* , , */
) regular, right?
i using switch case statements, i.e. implementing finite state machine. there's no tree built , no stack. thought program parser when deals context free languages , @ least has stack, i.e. implements pushdown automaton. have feeling term parser used rather freely.
to clarify: i'm not looking ways programme work java file, i'm interested in correct terminology.
no, removal of comments java code involves regular expression (a finite state automaton) , can't called "parser".... dfa (deterministic finite automaton) important component in programming language compiler because pre-processing such comment removal, identifier (variable/function/class names) identification can done dfas. in fact, compiler developers make use of lex tool (a dfa generator) implement programming language specific dfas, e.g. dfa comment identification in c , c++ different.
the next step generate intermediate code given high level code. 1 has make use of context-free grammars. common use shift-reduce parser build annotated parse tree code. common tool used task yacc.
Comments
Post a Comment