[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

function reference



I am writing an expression grammar. Does any one know how to define grammar
for function reference?

      expression =
            {arithematic} arith_expression |
            {boolean} boolean_expression ;

      arith_expression =
            {term} arith_term |
            {plus} arith_expression plus arith_term |
            {minus} arith_expression minus arith_term ;

      arith_term =
            {factor} arith_factor |
            {mult} arith_term mult arith_factor |
            {power} arith_term power double |
            {div} arith_term div arith_factor ;

      arith_factor =
            {reference} reference |
            {double} double |
            {expression} l_paren arith_expression r_paren ;

      reference = {no_parameters} identifier reference_last;

      reference_last = {empty} | {parameters} l_paren parameters r_paren ;

      parameters = {empty} | {multiple} expression parameters_last ;

      parameters_last = {empty} | {multiple} comma expression
parameters_last ;

      relational_expression =
            {less_than} [left]:arith_expression lt [right]:arith_expression
|
            {greater_than} [left]:arith_expression gt
[right]:arith_expression |
            {less_than_equal} [left]:arith_expression lteq
[right]:arith_expression |
            {greater_than_equal} [left]:arith_expression gteq
[right]:arith_expression |
            {equal} [left]:arith_expression eq [right]:arith_expression |
            {not_equal} [left]:arith_expression ngeq
[right]:arith_expression ;

      boolean_expression =
            {term} boolean_term |
            {or} boolean_expression or boolean_term ;

      boolean_term =
            {factor} boolean_factor |
            {and} boolean_term and boolean_factor ;

      boolean_factor =
            {simple} relational_expression |
            {not} not relational_expression ;


Thank you

Ali