public class JParser extends Object
exp -> exp binop exp | unop exp | doubleValue | funcioncall | var |
group | question
binop -> '<' | '>' | '<=' | '>=' | '!=' | '==' | '+' |
'-' | '*' | '/' | '-' | '.' | '||' | '&&'
unop -> '!' | '-'
question -> exp '?' exp ':' exp
functioncall -> name '(' [exp << ',' exp >>] ')'}
group -> '(' exp ')'
A análise sintática é feita através do algoritmo tradicional de parser-top-down "Recursive Descent Parser". Para simplificar a prescedência dos operadores, a gramática implementada é sutilmente diferente.
Veja abaixo:
exp -> exp1 ['?' exp ':' exp]
exp1 -> exp2 <<'||' exp2>>
exp2 -> * exp3 <<'&&' exp3>>
exp3 -> exp4 <<('<' | '>' | '<=' | '>=' | '!=' | '==')
exp4>>
exp4 -> exp5 <<('+' | '-') exp5>>
exp5 -> exp6 <<('*' | '/') exp6>>
exp6 -> ('!' | '-') exp6 | exp7
exp7 -> exp8 <<'^' exp6>>
exp8 -> exp9 ( <<'.' name>> | <<'[' exp ']'>>)
exp9 -> doubleValue | functioncall | var | group
functioncall -> name '(' [exp <<',' exp>>] ')'
var -> name
group -> '(' exp ')'
TokenMemoization,
JScanner| Constructor and Description |
|---|
JParser()
Construtor.
|
| Modifier and Type | Method and Description |
|---|---|
Exp |
parse(String input)
Faz a análise sintática da entrada e retorna a árvore sintática.
|
public Exp parse(String input) throws JExpressionSyntaxErrorException
input - entrada.JExpressionSyntaxErrorException - caso a expressão seja inválida.Copyright © 2007–2016 Tecgraf/PUC-Rio. All rights reserved.