We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
I've just added this project grammar to https://mingodad.github.io/parsertl-playground/playground/ an Yacc/Lex compatible online editor/tester (select Toucan cpu/gpu parser from Examples then click Parse to see a parse tree for the content in Input Source), it also generate an EBNF understood by (IPV4) https://rr.red-dove.com/ui or (IPV6) https://www.bottlecaps.de/rr/ui to generate a nice navigable railroad diagram (see instruction bellow at the top).
Yacc/Lex
Toucan cpu/gpu parser
Examples
Parse
Input Source
EBNF
I hope it can help develop/debug/document this project grammar.
Notice that I'm cheating on T_TYPENAME that I'm prefixing with $ due to missing symbol table/scope management.
T_TYPENAME
$
// // EBNF to be viewd at // (IPV6) https://www.bottlecaps.de/rr/ui // (IPV4) https://rr.red-dove.com/ui // // Copy and paste this at one of the urls shown above in the 'Edit Grammar' tab // then click the 'View Diagram' tab. // program::= statements statements::= statements statement | /*%empty*/ statement::= ';' | expr_statement ';' | '{' statements '}' | if_statement | for_statement | while_statement | do_statement | T_RETURN expr ';' | T_RETURN ';' | var_decl_statement ';' | class_decl | class_forward_decl | enum_decl | using_decl | assignment ';' | T_INCLUDE expr_statement::= expr assignment::= assignable '=' expr_or_list | assignable T_ADD_EQUALS expr | assignable T_SUB_EQUALS expr | assignable T_MUL_EQUALS expr | assignable T_DIV_EQUALS expr if_statement::= T_IF '(' expr ')' statement opt_else opt_else::= T_ELSE statement | /*%empty*/ for_statement::= T_FOR '(' for_loop_stmt ';' opt_expr ';' for_loop_stmt ')' statement opt_expr::= expr | /*%empty*/ for_loop_stmt::= assignment | expr_statement | var_decl_statement | /*%empty*/ while_statement::= T_WHILE '(' expr ')' statement do_statement::= T_DO statement T_WHILE '(' expr ')' ';' var_decl_statement::= type var_decl_list simple_type::= T_TYPENAME | scalar_type | simple_type T_LT types T_GT | T_VOID | simple_type T_LT T_INT_LITERAL T_GT | simple_type T_LT T_INT_LITERAL ',' T_INT_LITERAL T_GT | simple_type T_COLONCOLON T_IDENTIFIER qualified_type::= simple_type | type_qualifiers simple_type type::= qualified_type | type '*' | type '^' | type '[' arith_expr ']' | type '[' ']' | T_AUTO var_decl_list::= var_decl_list ',' var_decl | var_decl class_or_native_class::= T_CLASS | T_NATIVE T_CLASS class_header::= class_or_native_class T_IDENTIFIER | class_or_native_class T_TYPENAME template_class_header::= class_or_native_class T_IDENTIFIER T_LT template_formal_arguments T_GT class_forward_decl::= class_header ';' class_decl::= class_header opt_parent_class '{' class_body '}' | template_class_header opt_parent_class '{' class_body '}' opt_parent_class::= ':' simple_type | /*%empty*/ class_body::= class_body class_body_decl | /*%empty*/ enum_decl::= T_ENUM T_IDENTIFIER '{' enum_list '}' enum_list::= enum_list ',' T_IDENTIFIER | enum_list ',' T_IDENTIFIER '=' T_INT_LITERAL | T_IDENTIFIER | T_IDENTIFIER '=' T_INT_LITERAL | /*%empty*/ using_decl::= T_USING T_IDENTIFIER '=' type ';' class_body_decl::= method_modifiers type T_IDENTIFIER '(' formal_arguments ')' opt_shader_type opt_workgroup_size method_body | method_modifiers T_TYPENAME '(' formal_arguments ')' opt_initializer method_body | method_modifiers '~' T_TYPENAME '(' ')' method_body | method_modifiers type var_decl_list ';' | enum_decl ';' | using_decl method_body::= '{' statements '}' | ';' template_formal_arguments::= T_IDENTIFIER | template_formal_arguments ',' T_IDENTIFIER method_modifier::= T_STATIC | T_VIRTUAL | T_DEVICEONLY opt_shader_type::= T_VERTEX | T_FRAGMENT | T_COMPUTE | /*%empty*/ opt_workgroup_size::= '(' arguments ')' | /*%empty*/ type_qualifier::= T_UNIFORM | T_STORAGE | T_VERTEX | T_INDEX | T_SAMPLEABLE | T_RENDERABLE | T_READONLY | T_WRITEONLY | T_READWRITE | T_COHERENT type_qualifiers::= type_qualifier type_qualifiers | type_qualifier method_modifiers::= method_modifier method_modifiers | /*%empty*/ formal_arguments::= non_empty_formal_arguments | /*%empty*/ non_empty_formal_arguments::= formal_arguments ',' formal_argument | formal_argument formal_argument::= type T_IDENTIFIER | type T_IDENTIFIER '=' expr_or_list var_decl::= T_IDENTIFIER | T_IDENTIFIER '=' expr_or_list scalar_type::= T_INT | T_UINT | T_SHORT | T_USHORT | T_BYTE | T_UBYTE | T_FLOAT | T_DOUBLE | T_BOOL arguments::= non_empty_arguments | /*%empty*/ non_empty_arguments::= non_empty_arguments ',' argument | argument argument::= T_IDENTIFIER '=' expr_or_list | expr_or_list arith_expr::= arith_expr '+' arith_expr | arith_expr '-' arith_expr | arith_expr '*' arith_expr | arith_expr '/' arith_expr | arith_expr '%' arith_expr | '-' arith_expr | arith_expr T_LT arith_expr | arith_expr T_LE arith_expr | arith_expr T_EQ arith_expr | arith_expr T_GT arith_expr | arith_expr T_GE arith_expr | arith_expr T_NE arith_expr | arith_expr T_LOGICAL_AND arith_expr | arith_expr T_LOGICAL_OR arith_expr | arith_expr '&' arith_expr | arith_expr '^' arith_expr | arith_expr '|' arith_expr | '!' arith_expr | T_PLUSPLUS assignable | T_MINUSMINUS assignable | assignable T_PLUSPLUS | assignable T_MINUSMINUS | '(' arith_expr ')' | '(' type ')' arith_expr | simple_type '(' arguments ')' | simple_type '{' arguments '}' | type '[' arith_expr ']' '(' arguments ')' | T_INT_LITERAL | T_UINT_LITERAL | T_BYTE_LITERAL | T_UBYTE_LITERAL | T_SHORT_LITERAL | T_USHORT_LITERAL | T_FLOAT_LITERAL | T_DOUBLE_LITERAL | T_TRUE | T_FALSE | T_NULL | assignable expr::= arith_expr | T_NEW type '(' arguments ')' | T_NEW type '[' arith_expr ']' | T_NEW '[' arith_expr ']' type '(' arguments ')' | T_INLINE '(' T_STRING_LITERAL ')' | T_STRING_LITERAL expr_or_list::= expr | '{' arguments '}' opt_initializer::= ':' expr_or_list | /*%empty*/ types::= type | types ',' type assignable::= T_IDENTIFIER | T_THIS | assignable '[' expr ']' | assignable '.' T_IDENTIFIER | assignable '.' T_IDENTIFIER '(' arguments ')' | simple_type '.' T_IDENTIFIER '(' arguments ')' | '*' assignable | '&' assignable //Tokens T_LT ::= "<" T_LE ::= "<=" T_EQ ::= "==" T_GE ::= ">=" T_GT ::= ">" T_NE ::= "!=" T_ADD_EQUALS ::= "+=" T_SUB_EQUALS ::= "-=" T_MUL_EQUALS ::= "*=" T_DIV_EQUALS ::= "/=" T_LOGICAL_AND ::= "&&" T_LOGICAL_OR ::= "||" T_PLUSPLUS ::= "++" T_MINUSMINUS ::= "--" T_COLONCOLON ::= "::" T_AUTO ::= "auto" T_FALSE ::= "false" T_NULL ::= "null" T_TRUE ::= "true" T_IF ::= "if" T_ELSE ::= "else" T_FOR ::= "for" T_WHILE ::= "while" T_DO ::= "do" T_RETURN ::= "return" T_NEW ::= "new" T_CLASS ::= "class" T_ENUM ::= "enum" T_VOID ::= "void" T_STATIC ::= "static" T_VIRTUAL ::= "virtual" T_VERTEX ::= "vertex" T_INDEX ::= "index" T_FRAGMENT ::= "fragment" T_COMPUTE ::= "compute" T_UNIFORM ::= "uniform" T_STORAGE ::= "storage" T_SAMPLEABLE ::= "sampleable" T_RENDERABLE ::= "renderable" T_NATIVE ::= "native" T_THIS ::= "this" T_READONLY ::= "readonly" T_WRITEONLY ::= "writeonly" T_READWRITE ::= "readwrite" T_DEVICEONLY ::= "deviceonly" T_COHERENT ::= "coherent" T_USING ::= "using" T_INLINE ::= "inline" T_INCLUDE ::= "include[ \t\n]+[^ \t\n]+" T_INT ::= "int" T_UINT ::= "uint" T_FLOAT ::= "float" T_DOUBLE ::= "double" T_BOOL ::= "bool" T_BYTE ::= "byte" T_UBYTE ::= "ubyte" T_SHORT ::= "short" T_USHORT ::= "ushort"
The text was updated successfully, but these errors were encountered:
No branches or pull requests
I've just added this project grammar to https://mingodad.github.io/parsertl-playground/playground/ an
Yacc/Lex
compatible online editor/tester (selectToucan cpu/gpu parser
fromExamples
then clickParse
to see a parse tree for the content inInput Source
), it also generate anEBNF
understood by (IPV4) https://rr.red-dove.com/ui or (IPV6) https://www.bottlecaps.de/rr/ui to generate a nice navigable railroad diagram (see instruction bellow at the top).I hope it can help develop/debug/document this project grammar.
Notice that I'm cheating on
T_TYPENAME
that I'm prefixing with$
due to missing symbol table/scope management.The text was updated successfully, but these errors were encountered: