- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
这是我尝试解析的输入文件:
Sphere(worldGlobe).
Texture(worldGlobe, worldGlobeTexture1).
Clouds(clouds1).
我遇到了这样的段错误。出于某种原因,如果我只是改变这些句子的顺序,一切都会正常。
Sphere(worldGlobe).
Clouds(clouds1).
Texture(worldGlobe, worldGlobeTexture1).
str_multicat 只是连接更多字符串。语法很简单。如果我从“谓词”的最后一个模式中删除此代码,我不会收到段错误:
char result[1000];
str_multicat(result,
"file -import \"D:/Program Files/Autodesk/Maya2012/presets/fluids/examples /CloudsAndFog/FasterClouds.ma\";\n",
"rename cloudLayer ", cloudLayer, ";\n",
"rename skyFog ", skyFog, ";\n");
这是我的 Bison 文件。
%{
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdarg.h>
int yylex(void);
void yyerror(char*);
void str_multicat(char* result, ...);
%}
%union {
char* s;
double d;
int i;
}
/* Tokens */
%token SPHERE
%token TEXTURE
%token CLOUDS
%token CLOUDS_TRANSPARENCY
%token ROTATE
%token TRANSLATEIN
%token CAMERA
%token CAMERASHOT
%token LBRACKET
%token RBRACKET
%token DOT
%token COMMA
%token <d> DOUBLE
%token <i> INT;
%token <s> NAME
%%
listOfPredicates: /* empty string */
| predicate listOfPredicates
;
predicate:
SPHERE LBRACKET NAME RBRACKET DOT
{
char result[1000];
strcpy(result, "polySphere -n ");
strcat(result, $3);
strcat(result, ";\n\0");
printf("%s\n", result);
}
|
TEXTURE LBRACKET NAME COMMA NAME RBRACKET DOT
{
char object[50];
strcpy(object, $3);
char material[50];
strcpy(material, object);
strcat(material, "Mat");
char materialSG[50];
strcpy(materialSG, material);
strcat(materialSG, "SG");
char texture[50];
strcpy(texture, $5);
char objectPlace2dTexture[50];
strcpy(objectPlace2dTexture, object);
strcat(objectPlace2dTexture, "_place2dTexture");
char objectFile[50];
strcpy(objectFile, object);
strcat(objectFile, "_file");
char result[10000];
str_multicat(result,
"// Assign new material\n",
"shadingNode -asShader lambert -n ", material, ";\n",
"sets -renderable true -noSurfaceShader true -empty -name ", materialSG, ";\n",
"connectAttr -f ", material, ".outColor ", materialSG, ".surfaceShader;\n",
"assignCreatedShader \"lambert\" \"\" ", material, " \"", object, "\";\n",
"sets -e -forceElement ", materialSG, ";\n",
"// Create file and place2dTexture nodes and connect them\n",
"shadingNode -asTexture file -n ", objectFile, ";\n",
"shadingNode -asUtility place2dTexture -n ", objectPlace2dTexture, ";\n",
"connectAttr -f ", objectPlace2dTexture, ".coverage ", objectFile, ".coverage;\n",
"connectAttr -f ", objectPlace2dTexture, ".translateFrame ", objectFile, ".translateFrame;\n",
"connectAttr -f ", objectPlace2dTexture, ".rotateFrame ", objectFile, ".rotateFrame;\n",
"connectAttr -f ", objectPlace2dTexture, ".mirrorU ", objectFile, ".mirrorU;\n",
"connectAttr -f ", objectPlace2dTexture, ".mirrorV ", objectFile, ".mirrorV;\n",
"connectAttr -f ", objectPlace2dTexture, ".stagger ", objectFile, ".stagger;\n",
"connectAttr -f ", objectPlace2dTexture, ".wrapU ", objectFile, ".wrapU;\n",
"connectAttr -f ", objectPlace2dTexture, ".wrapV ", objectFile, ".wrapV;\n",
"connectAttr -f ", objectPlace2dTexture, ".repeatUV ", objectFile, ".repeatUV;\n",
"connectAttr -f ", objectPlace2dTexture, ".offset ", objectFile, ".offset;\n",
"connectAttr -f ", objectPlace2dTexture, ".rotateUV ", objectFile, ".rotateUV;\n",
"connectAttr -f ", objectPlace2dTexture, ".noiseUV ", objectFile, ".noiseUV;\n",
"connectAttr -f ", objectPlace2dTexture, ".vertexUvOne ", objectFile, ".vertexUvOne;\n",
"connectAttr -f ", objectPlace2dTexture, ".vertexUvTwo ", objectFile, ".vertexUvTwo;\n",
"connectAttr -f ", objectPlace2dTexture, ".vertexUvThree ", objectFile, ".vertexUvThree;\n",
"connectAttr -f ", objectPlace2dTexture, ".vertexCameraOne ", objectFile, ".vertexCameraOne;\n",
"connectAttr -f ", objectPlace2dTexture, ".outUV ", objectFile, ".uv;\n",
"connectAttr -f ", objectPlace2dTexture, ".outUvFilterSize ", objectFile, ".uvFilterSize;\n",
"connectAttr -force ", objectFile, ".outColor ", material, ".color;\n",
"// Finally assign the texture file\n",
"setAttr -type \"string\" ", objectFile, ".fileTextureName \"C:/Maya/Textures/", texture, ".jpg\";\n"
);
printf("%s\n", result);
}
|
CLOUDS LBRACKET NAME RBRACKET DOT
{
char cloudsName[50];
strcpy(cloudsName, $3);
char cloudLayer[50];
strcpy(cloudLayer, cloudsName);
strcat(cloudLayer, "_cloudLayer");
char skyFog[50];
strcpy(skyFog, cloudsName);
strcat(skyFog, "_skyFog");
char result[1000];
str_multicat(result,
"file -import \"D:/Program Files/Autodesk/Maya2012/presets/fluids/examples /CloudsAndFog/FasterClouds.ma\";\n",
"rename cloudLayer ", cloudLayer, ";\n",
"rename skyFog ", skyFog, ";\n");
printf("%s\n", result);
}
;
%%
main() {
yyparse();
}
void yyerror(char *s) {
fprintf(stderr, "ERROR: %s\n", s);
}
void str_multicat(char* result, ...)
{
// Init arguments list
va_list argptr;
va_start(argptr, result);
// Use arguments
char* val;
strcpy(result, va_arg(argptr, char*));
while(val = va_arg(argptr, char*))
{
strcat(result, val);
}
strcat(result, "\0");
// End arguments list
va_end(argptr);
}
最佳答案
(问题已在评论中回答。请参阅 Question with no answers, but issue solved in the comments (or extended in chat) )
@larsman 写道:
Your
str_multicat
should receive a finalNULL
argument in every call.
关于c - 与 Bison 的斗争,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8650217/
我有一个使用 Yacc 编写的语法。语法的相关部分摘录在这里 postfix : primary | postfix '[' expr ']' | postfix '[' ex
如何在 bison/yacc 中使用继承的属性? 说,我有这样的语法 - 程序 -> stmts 我想做的是在 Bison 身上: 程序:stmts {$$.next = newLabel(); $1
有什么方法可以更改 Bison 错误消息的格式?例如,不要说 syntax error, unexpected T_ID, expected ';' or T_IMPORT说 unexpected i
我的语法有这两个标记声明: %token RP %token ELSE 而这两条规则: Statement : IF LP Exp RP Statement; Statement : IF LP
如果有一个表单的输入文件: BEGIN stuff.... END BEGIN stuff ... END 我的 .y 文件是这样的 %token BEGIN %token END %star
我希望为现有语言创建一个 JavaScript 解析器,该语言目前具有笨拙的“手工制作”C# 和 Java 解析器。我想使用 Jison,并且也一直在尝试学习 Bison 的基础知识。 我不确定如何回
目前我正在研究一个源到源编译器,我已经编写了一个野牛解析器,可以正确地为输入创建 AST。我现在需要对语法树进行多次转换,因此我需要向树中插入许多节点。 我可以手动创建所有要添加到语法树中的结构体/联
如果有一个表单的输入文件: BEGIN stuff.... END BEGIN stuff ... END 我的 .y 文件是这样的 %token BEGIN %token END %star
我正在寻找为现有语言创建 JavaScript 解析器的方法,该语言目前具有笨拙的“手工制作”C# 和 Java 解析器。想用Jison,也在努力学习Bison的基础。 一个我不确定如何回答的问题是
我正在使用 flex/bison 编写解析器(我可以用 Python 编写解析器,但我总是更喜欢经典。) 当我用这个编译代码时: gcc -lfl -ly chance.tab.c lex.yy.c
正在使用 flex/bison 开发编译器。我的构建输出中有此警告。 警告:在默认操作中键入冲突 ('s' '') 请问有什么帮助吗? 最佳答案 它似乎与源中的 %token 和 %type 声明有关
考虑这个 lex.l 文件: %{ #include "y.tab.h" %} digit [0-9] letter [a-zA-Z] %% "+"
我正在为 bison 中的一个简单的 Pascal 编译器编写语法,我想可视化我在 pascal.y 中指定的语法的解析树。是否可以基于我的 pascal.y 文件以图形方式显示语法树? 最佳答案 野
我正在尝试编写一个能够使用以下输入的语法: begin #this is a example x = 56; while x > 0 do begin point 15
我正在尝试使用 BNF 语法编写 Flex/Bison 文件。但是,当我尝试编译时出现错误,而且我不确定如何调试它们。 BNF语法: ::= | head() ::=:: | @ | tail() |
我正在用 Flex/Bison 编写一个小程序来标记/解析我创建的查询语言。 我想知道是否有任何方法可以在 Flex/Bison 中创建任何关键字。 我的意思是:flex 将输入分解成一个标记列表,但
我正在尝试使用 flex 和 bison 创建过滤器,因为我想从复杂的语言中获取某些语法元素。我的计划是使用 flex + bison 来识别语法,并转储出感兴趣元素的位置。 (然后使用脚本根据转储的
我正在尝试实现一个可以进行浮点运算的 Flex/bison 计算器。我的 Flex 代码如下所示 %{ #include "calc.tab.h" #include void yyerror(cha
我正在尝试使用 FLEX 和 BISON 进行一些练习。 这是我写的代码: calc_pol.y %{ #define YYSTYPE double #include "calc_pol.tab.h"
我有一个使用括号和方括号作为分隔符的语法。当由 bison 生成的解析器输入带有不平衡分隔符的输入时,传递给 yyerror 的 YYLTYPE* 中的错误位置是输入的结尾。所以,例如,在输入 x
我是一名优秀的程序员,十分优秀!