小编use*_*131的帖子

分别使用ANTLR Parser和Lexer

我使用ANTLR版本4来创建编译器.第一阶段是Lexer部分.我创建了"CompilerLexer.g4"文件并在其中推出了lexer规则.它工作正常.

CompilerLexer.g4:


lexer grammar CompilerLexer;

INT         :   'int'   ;   //1
FLOAT       :   'float' ;   //2
BEGIN       :   'begin' ;   //3
END         :   'end'   ;   //4
To          :   'to'    ;   //5
NEXT        :   'next'  ;   //6
REAL        :   'real'  ;   //7
BOOLEAN     :   'bool'  ;   //8
.
.
.
NOTEQUAL    :   '!='    ;   //46
AND         :   '&&'    ;   //47
OR          :   '||'    ;   //48
POW         :   '^'     ;   //49
ID          : [a-zA-Z]+ ;   //50




WS
:   ' ' -> channel(HIDDEN)  //50 …
Run Code Online (Sandbox Code Playgroud)

c# grammar lexer antlr4

8
推荐指数
1
解决办法
5293
查看次数

在C++中将回调函数转换为DWORD_PTR

实际上是c ++中的新手.我写了这段代码,但说无法从"waveOutProc"转换为"DWORD_PTR".你能告诉我如何修复它吗?

谢谢

void CALLBACK Audio::waveOutProc(HWAVEOUT hWaveOut, unsigned int uMsg,
unsigned long dwInstance, unsigned long dwParam1,
unsigned long dwParam2)
{
/*
* pointer to free block counter
*/
int* freeBlockCounter = (int*)dwInstance;
/*
* ignore calls that occur due to openining and closing the
* device.
*/
if(uMsg != WOM_DONE) { return ; }
EnterCriticalSection(&waveCriticalSection) ;
(*freeBlockCounter)++ ;
LeaveCriticalSection(&waveCriticalSection) ;
}
Run Code Online (Sandbox Code Playgroud)

////////////////////////////////////////////////// ////////////////////////////////

void Audio::playSound(const char* filename)
{
HWAVEOUT hWaveOut ;
HANDLE hFile;
WAVEFORMATEX wfx ;
char buffer[1024];
int i; …
Run Code Online (Sandbox Code Playgroud)

c++ waveout

2
推荐指数
1
解决办法
1002
查看次数

标签 统计

antlr4 ×1

c# ×1

c++ ×1

grammar ×1

lexer ×1

waveout ×1