Created
February 12, 2016 16:41
-
-
Save andfoy/d04f3d37b37018d23b12 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * JavaCC template file created by SF JavaCC plugin 1.5.17+ wizard for JavaCC 1.5.0+ | |
| */ | |
| options | |
| { | |
| static = false; | |
| DEBUG_PARSER = true; | |
| } | |
| PARSER_BEGIN(NuevoParser) | |
| package uniandes.teolen.parserJavaCC.newParser; | |
| public class NuevoParser | |
| { | |
| } | |
| PARSER_END(NuevoParser) | |
| SKIP : | |
| { | |
| " " | |
| | "\r" | |
| | "\t" | |
| | "\n" | |
| } | |
| TOKEN : // OPERATORS | |
| { | |
| < PLUS : "+" > | |
| | < MINUS : "-" > | |
| | < MULTIPLY : "*" > | |
| | < DIVIDE : "/" > | |
| } | |
| TOKEN : | |
| { | |
| < DIGIT : ["1"-"9"] > | |
| | < CONSTANT : ("0" | < DIGIT >)+"E"("0" | < DIGIT >)+ > | |
| | < IM_UNIT : "i"> | |
| | < #LOWER : ["a"-"z"] > | |
| | < #UPPER : ["A"-"Z"] > | |
| | < #CHAR : (< LOWER > | < UPPER >) > | |
| | < VAR : < CHAR > (< CHAR > | "_" | "0" | < DIGIT >)*> | |
| } | |
| int one_line() : | |
| {} | |
| { | |
| exp() ";" | |
| { | |
| return 0; | |
| } | |
| | ";" | |
| { | |
| return 1; | |
| } | |
| } | |
| void exp() : | |
| {} | |
| { | |
| term() | |
| ( | |
| ( | |
| < PLUS > | |
| | < MINUS > | |
| ) | |
| term() | |
| )* | |
| } | |
| void term() : | |
| {} | |
| { | |
| fact() | |
| ( | |
| ( | |
| < MULTIPLY > | |
| | < DIVIDE > | |
| ) | |
| fact() | |
| )* | |
| } | |
| void fact() : | |
| {} | |
| { | |
| (< MINUS >)? (variable() |complex()|"(" exp() ")" | frac() ) | |
| } | |
| void frac() : | |
| {} | |
| { | |
| "<" ( < PLUS > | < MINUS > )? ("0" | < DIGIT >)+ ":" ( < PLUS > | < MINUS > )? < DIGIT >("0" | < DIGIT >)*">" | |
| } | |
| void complex() : | |
| {} | |
| { | |
| (< CONSTANT > | ("0" | < DIGIT >)+)(","(< CONSTANT > | ("0" | < DIGIT >)+)< IM_UNIT >)? | |
| } | |
| void variable() : | |
| {} | |
| { | |
| < VAR >(("["exp_non_complex()"]")+)? | |
| } | |
| void exp_non_complex() : | |
| {} | |
| { | |
| term_non_complex() | |
| ( | |
| ( | |
| < PLUS > | |
| | < MINUS > | |
| ) | |
| term_non_complex() | |
| )* | |
| } | |
| void term_non_complex() : | |
| {} | |
| { | |
| fact_non_complex() | |
| ( | |
| ( | |
| < MULTIPLY > | |
| | < DIVIDE > | |
| ) | |
| fact_non_complex() | |
| )* | |
| } | |
| void fact_non_complex() : | |
| {} | |
| { | |
| (< MINUS >)? (("0" | < DIGIT >)+ | variable() |"(" exp_non_complex() ")") | |
| } | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment