[yast-commit] r40878 - in /branches/tmp/dmacvicar/jycp: ./ .classpath .project src/ src/ycp.g vendor/ vendor/antlrworks-1.1.3.jar vendor/gi-1.2.jar
Author: dmacvicar Date: Wed Sep 12 16:14:41 2007 New Revision: 40878 URL: http://svn.opensuse.org/viewcvs/yast?rev=40878&view=rev Log: backup Added: branches/tmp/dmacvicar/jycp/ branches/tmp/dmacvicar/jycp/.classpath branches/tmp/dmacvicar/jycp/.project branches/tmp/dmacvicar/jycp/src/ branches/tmp/dmacvicar/jycp/src/ycp.g branches/tmp/dmacvicar/jycp/vendor/ branches/tmp/dmacvicar/jycp/vendor/antlrworks-1.1.3.jar (with props) branches/tmp/dmacvicar/jycp/vendor/gi-1.2.jar (with props) Added: branches/tmp/dmacvicar/jycp/.classpath URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/jycp/.classpath?rev=40878&view=auto ============================================================================== --- branches/tmp/dmacvicar/jycp/.classpath (added) +++ branches/tmp/dmacvicar/jycp/.classpath Wed Sep 12 16:14:41 2007 @@ -0,0 +1,6 @@ +<?xml version="1.0" encoding="UTF-8"?> +<classpath> + <classpathentry kind="src" path="src"/> + <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> + <classpathentry kind="output" path="bin"/> +</classpath> Added: branches/tmp/dmacvicar/jycp/.project URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/jycp/.project?rev=40878&view=auto ============================================================================== --- branches/tmp/dmacvicar/jycp/.project (added) +++ branches/tmp/dmacvicar/jycp/.project Wed Sep 12 16:14:41 2007 @@ -0,0 +1,17 @@ +<?xml version="1.0" encoding="UTF-8"?> +<projectDescription> + <name>jycp</name> + <comment></comment> + <projects> + </projects> + <buildSpec> + <buildCommand> + <name>org.eclipse.jdt.core.javabuilder</name> + <arguments> + </arguments> + </buildCommand> + </buildSpec> + <natures> + <nature>org.eclipse.jdt.core.javanature</nature> + </natures> +</projectDescription> Added: branches/tmp/dmacvicar/jycp/src/ycp.g URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/jycp/src/ycp.g?rev=40878&view=auto ============================================================================== --- branches/tmp/dmacvicar/jycp/src/ycp.g (added) +++ branches/tmp/dmacvicar/jycp/src/ycp.g Wed Sep 12 16:14:41 2007 @@ -0,0 +1,544 @@ + +grammar ycp; +options {k=2; backtrack=true; memoize=true;} + +@lexer::members { +protected boolean enumIsKeyword = true; +} + +/* Expressions */ + + /* + * EXPRESSION vs BLOCK: type + * An important difference between a block and an expression is that + * block's type is determined (!= isUnspec) only if it has an explicit + * "return". It is then used for detecting type-mismatched return + * statements, among other things. As a consequence, all statements + * except return must have an undetermined type (Type::Unspec). + * Do not confuse Type::Unspec with Type::Void. + */ + /* expressions are either 'compact' (with a defined end-token, no lookahead) + or 'infix' (which might need a lookahead token) */ + + + +compact_expression: + block +| LOOKUP '(' expression ',' expression ',' expression ')' +| SELECT '(' expression ',' expression ',' expression ')' +| function_call +| '(' expression ')' +| QUOTED_EXPRESSION expression ')' +| IS '(' expression ',' type ')' +| TEXTDOMAIN +| I18N string ',' string ',' expression ')' +| I18N string ')' +| identifier + +| list +| map +| constant +; + +infix_expression: + expression '+' expression +| expression '-' expression +| expression '*' expression +| expression '/' expression +| expression '%' expression +| expression LEFT expression +| expression RIGHT expression +| expression '&' expression +| expression '^' expression +| expression '|' expression +| '~' expression +| expression AND expression +| expression OR expression +| expression EQUALS expression +| expression '<' expression +| expression '>' expression +| expression LE expression +| expression GE expression +| expression NEQ expression +| '!' expression +//| '-' expression %prec UMINUS +| expression '?' expression ':' expression +; + +casted_expression: + '(' type ')' castable_expression +; + +castable_expression: +| compact_expression +| casted_expression +| bracket_expression +; + +bracket_expression: + compact_expression '[' list_elements CLOSEBRACKET expression +; + +expression: + compact_expression +| casted_expression +| infix_expression +| bracket_expression +; + +compilationUnit : expression; + +block: + '{' + block_end +| QUOTED_BLOCK + block_end +; + +block_end: + statements '}' +; + +/* -------------------------------------------------------------- */ +/* Statements */ +/* statements are always inside a block, so p_parser->m_block_stack is valid ! */ + +statements: + statements statement +; + +statement: + ';' + { + $$.t = Type::Unspec; // empty statement is allowed + $$.c = 0; + } +| SYM_NAMESPACE DCQUOTED_BLOCK +| MODULE STRING ';' +| INCLUDE STRING ';' +| IMPORT STRING ';' +| FULLNAME STRING ';' +| TEXTDOMAIN STRING ';' +| EXPORT identifier_list ';' +| TYPEDEF type identifier ';' +| definition +| assignment ';' +| function_call ';' +| block +| control_statement +| CASE expression ':' +| DEFAULT ':' +; + +control_statement: + IF '(' expression ')' statement opt_else +| WHILE '(' expression ')' + statement +| DO + block + WHILE '(' expression ')' ';' +| REPEAT + block + UNTIL '(' expression ')' ';' +| BREAK ';' +| CONTINUE ';' +| RETURN ';' +| RETURN expression ';' +| SWITCH '(' expression ')' + block +; + +opt_else: + ELSE statement +| /* empty */ +; + +/* -------------------------------------------------------------- */ +/* types */ + +type: + C_TYPE // type ($$.t) is set by scanner + // C_TYPE includes already expanded typedefs +| LIST +| LIST '<' type_gt +| MAP +| MAP '<' type ',' type_gt +| BLOCK '<' type_gt +| CONST type +| type '&' +| type '(' ')' +| type '(' types ')' +; + +/* recognize "type >" vs "type >>" */ +type_gt: + type '>' +| type RIGHT +; + +types: + type +| types ',' type +; +/* -------------------------------------------------------------- */ +/* Macro/Function or variable definition */ + +/* + + */ +definition: + opt_global DEFINE identifier '(' +| function_start ';' /* function declaration */ +| function_start block /* function definition */ +| opt_global_identifier '=' expression ';' /* variable definition */ +; + + +/*------------------------------------------------------ + function definition start + [global] [define] type identifier '(' [type identifier]* ') + + enter function type+identifier to local/global symbol + table. + Enter (list of) formal parameters type+symbol to + private symbol table to have them available when + parsing the (perhaps following) definition block. + + $$.c = YFunction + $$.v.tval = TableEntry() (->sentry->code() == YFunction + $$.t = declared_return_type for current block + $$.l = symbol definition line +*/ + +function_start: + opt_global_identifier '(' tupletypes ')' +; + +/*-------------------------------------------------------------- + identifier, optionally prepended by 'global' or + 'define' or 'global define' + $$.v.tval == entry + $$.t = type + $$.l = line of identifier +*/ + +opt_global_identifier: + opt_global opt_define type identifier +; + +opt_global: + GLOBAL + | +; + +opt_define: + DEFINE +| +; + +/*----------------------------------------------*/ +/* zero or more formal parameters */ +/* $$.c = undef */ +/* $$.t = Type::Unspec if error, any valid type otherwise */ +/* $$.v.fpval = pointer to formalparam_t chain */ + +tupletypes: + /* empty */ + { + $$.v.val = 0; + $$.t = Type::Void; + } +| tupletype +; + +/*----------------------------------------------*/ +/* one or more formal parameters */ +/* $$.v.fpval = pointer to formalparam_t chain */ + +tupletype: + formal_param +| tupletype ',' formal_param +; + +/*----------------------------------------------*/ +/* single formal function parameter */ +/* $$.v.fpval = pointer to formalparam_t */ + +formal_param: + type identifier +; +/* -------------------------------------------------------------- */ +/* Assignment */ + +assignment: + identifier '=' expression +| identifier '[' list_elements ']' '=' expression +; + +/* ----------------------------------------------------------*/ + +/* allow multi line strings */ +string: + STRING +| string STRING +; + +constant: + C_VOID +| C_BOOLEAN +| C_INTEGER +| C_FLOAT +| STRING /* can't use 'string' here, because it needs lookahead and hence is no 'compact'_expression */ +| C_BYTEBLOCK +| C_PATH +| C_SYMBOL +; + +/* -------------------------------------------------------------- */ +/* List expressions */ + +list: + '[' ']' +| '[' list_elements opt_comma ']' +; + +list_elements: + expression +| list_elements ',' expression +; + + /* optional comma */ +opt_comma: + ',' +| +; + +/* -------------------------------------------------------------- */ +/* Map expressions */ + +map: + MAPEXPR ']' /* empty map */ +| MAPEXPR map_elements opt_comma ']' +; + +map_elements: + expression ':' expression +| map_elements ',' expression ':' expression +; + +/* -------------------------------------------------------------- */ +/* + Function call + + initial parse of 'term_name (' triggers first type checking + and lookup of term_name so parameters can be checked against + prototype. + + function_call: term_name[$1] '('[2] {lookup prototype}[$3] parameters[$4] ')'[$5] {check parameters} + +*/ + +function_call: + function_name '(' + parameters ')' +; + +/* + function call parameters + + attach parameters directly to function, thereby using the type information + from the function in deciding how to treat parameters. + + since we're using the $0 feature of bison here, we can't + split up this BNF further :-( + + $0 refers to $3 of the 'function_call' rule, ie $0.c is the function (one of 4 kinds) + + return $$.t == 0 on error, $$.c == 0 if empty + */ + +parameters: + /* empty */ +| type identifier +| expression +| parameters ',' type identifier +| parameters ',' expression +; + +/* -------------------------------------------------------------- */ +/* + function name + + might be a known identifier (normal function call) + or a symbol constant (YCP Term) + +/* -> $$.v.tval == TableEntry if symbol already declared ($$.t != Type::Unspec) + $$.v.nval == charptr if symbol undefined ($$.t == Type::Unspec) + $$.t = Type::Unspec for SYMBOL, "|" for builtin, else type + */ + +function_name: + identifier +| C_SYMBOL +; + +/* -------------------------------------------------------------- */ +/* Identifiers (KNOWN and UNKNOWN symbols) */ +/* -> $$.v.tval == TableEntry if symbol already declared ($$.t != Type::Unspec) + $$.v.nval == charptr if symbol undefined ($$.t == Type::Unspec) + $$.t = Type::Unspec for SYMBOL, "|" for builtin, else type + */ + +identifier: + IDENTIFIER +| SYMBOL +; + +identifier_list: + identifier +| identifier ',' identifier_list +; +/* ---------------------------------------------------------------------- */ + +IDENTIFIER : ( '\u0041'..'\u005A'|'\u0061'..'\u007A' ) + ( '\u005F'|'\u0030'..'\u0039'|'\u0041'..'\u005A'|'\u0061'..'\u007A' )*; + +LETTER : ('a'..'z' | 'A'..'Z'); + +ODIGIT : ('0'..'7'); +DIGIT : ('0'..'9'); +HDIGIT : ('0'..'9' | 'a'..'f' | 'A'..'F' ); + +ALPHA : LETTER+; +ALNUM : ( LETTER | DIGIT )+; +//PATHSEGMENT +// : ([[:alpha:]_][[:alnum:]_-]*)|\"([^\\"]*(\\.)*)+\"; +PATHSEGMENT + : 'foo.bar.foo'; + +HexLiteral : '0' ('x'|'X') HexDigit+ IntegerTypeSuffix? ; + +DecimalLiteral : ('0' | '1'..'9' '0'..'9'*) IntegerTypeSuffix? ; + +OctalLiteral : '0' ('0'..'7')+ IntegerTypeSuffix? ; + +fragment +HexDigit : ('0'..'9'|'a'..'f'|'A'..'F') ; + +fragment +IntegerTypeSuffix : ('l'|'L') ; + +FloatingPointLiteral + : ('0'..'9')+ '.' ('0'..'9')* Exponent? FloatTypeSuffix? + | '.' ('0'..'9')+ Exponent? FloatTypeSuffix? + | ('0'..'9')+ Exponent FloatTypeSuffix? + | ('0'..'9')+ Exponent? FloatTypeSuffix + ; + +fragment +Exponent : ('e'|'E') ('+'|'-')? ('0'..'9')+ ; + +fragment +FloatTypeSuffix : ('f'|'F'|'d'|'D') ; + +CharacterLiteral + : '\'' ( EscapeSequence | ~('\''|'\\') ) '\'' + ; + +StringLiteral + : '"' ( EscapeSequence | ~('\\'|'"') )* '"' + ; + +fragment +EscapeSequence + : '\\' ('b'|'t'|'n'|'f'|'r'|'\"'|'\''|'\\') + | UnicodeEscape + | OctalEscape + ; + +fragment +OctalEscape + : '\\' ('0'..'3') ('0'..'7') ('0'..'7') + | '\\' ('0'..'7') ('0'..'7') + | '\\' ('0'..'7') + ; + +fragment +UnicodeEscape + : '\\' 'u' HexDigit HexDigit HexDigit HexDigit + ; + +//SYMBOL : ([[:alpha:]_][[:alnum:]_]+|[[:alpha:]][[:alnum:]_]*); +SYMBOL : ( (( ALPHA | '_' )( ALNUM | '_' )+) | (( ALPHA )( ALNUM | '_' )+) ); + +AND : '&&'; +OR : '||'; +LEFT : '<<'; +RIGHT : '>>'; +MAPEXPR : '$['; +LE : '<='; +GE : '>='; +EQUALS : '=='; +NEQ : '!='; +CLOSEBRACKET + : ']'; +I18N : '_('; + +TRUE : 'true'; +FALSE : 'false'; + +IF : 'if'; +ELSE : 'else'; +WHILE : 'while'; +DO : 'do'; +REPEAT : 'repeat'; +UNTIL : 'until'; +BREAK : 'break'; +CONTINUE: 'continue'; +RETURN : 'return'; +SWITCH : 'switch'; +DEFAULT : 'default'; +CASE : 'case'; +LOOKUP : 'lookup'; +TYPEDEF : 'typedef'; +CONST : 'const'; +GLOBAL : 'global'; +DEFINE : 'define'; +SELECT : 'select'; +LIST : 'list'; +MAP : 'map'; +BLOCK : 'block'; +MODULE : 'module'; +IMPORT : 'import'; +INCLUDE : 'include'; +FULLNAME : 'fullname'; +UMINUS : 'uminus'; +TEXTDOMAIN + : 'testdomain'; +EXPORT : 'export'; +SYM_NAMESPACE : 'namespace'; + +C_TYPE : C_VOID|C_BOOLEAN|C_INTEGER|C_FLOAT|C_BYTEBLOCK|C_PATH|C_SYMBOL; + +C_VOID : 'nil'; +C_BOOLEAN + : TRUE | FALSE; +C_INTEGER + : + DecimalLiteral; +C_FLOAT: FloatingPointLiteral; +STRING : StringLiteral; +C_BYTEBLOCK + : 'abyteblock'; +C_PATH : 'acpath'; +C_SYMBOL: '`' SYMBOL; + +DCQUOTED_BLOCK + : '::``{' | '::{'; +QUOTED_BLOCK + : '``{'; +QUOTED_EXPRESSION + : '``('; + +// \`\` { logError ("Lonely doubleqoute", LINE_VAR); return SCANNER_ERROR; } +// \` { logError ("Lonely qoute", LINE_VAR); return SCANNER_ERROR; } Added: branches/tmp/dmacvicar/jycp/vendor/antlrworks-1.1.3.jar URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/jycp/vendor/antlrworks-1.1.3.jar?rev=40878&view=auto ============================================================================== Binary file - no diff available. Added: branches/tmp/dmacvicar/jycp/vendor/gi-1.2.jar URL: http://svn.opensuse.org/viewcvs/yast/branches/tmp/dmacvicar/jycp/vendor/gi-1.2.jar?rev=40878&view=auto ============================================================================== Binary file - no diff available. -- To unsubscribe, e-mail: yast-commit+unsubscribe@opensuse.org For additional commands, e-mail: yast-commit+help@opensuse.org
participants (1)
-
dmacvicar@svn.opensuse.org