Search Results

Search found 2 results on 1 pages for 'kmels'.

Page 1/1 | 1 

  • Recognizing terminals in a CFG production previously not defined as tokens.

    - by kmels
    I'm making a generator of LL(1) parsers, my input is a CoCo/R language specification. I've already got a Scanner generator for that input. Suppose I've got the following specification: COMPILER 1. CHARACTERS digit="0123456789". TOKENS number = digit{digit}. decnumber = digit{digit}"."digit{digit}. PRODUCTIONS Expression = Term{"+"Term|"-"Term}. Term = Factor{"*"Factor|"/"Factor}. Factor = ["-"](Number|"("Expression")"). Number = (number|decnumber). END 1. So, if the parser generated by this grammar receives a word "1+1", it'd be accepted i.e. a parse tree would be found. My question is, the character "+" was never defined in a token, but it appears in the non-terminal "Expression". How should my generated Scanner recognize it? It would not recognize it as a token. Is this a valid input then? Should I add this terminal in TOKENS and then consider an error routine for a Scanner for it to skip it? How does usual language specifications handle this?

    Read the article

  • Editing a 1MB file continuously, what's more efficient?

    - by kmels
    I've to be continuously editing a 1MB file, simulating a file system. I've to modify the directory of File Control Blocks, FAT, blocks, etc. Proffesor recommended overwriting the file every time an update is made. 1MB shouldn't take minutes to do that, but I don't like this way. Is it a FileChannel the way to go here? Also, I understand that if I edit a MappedByteBuffer, the content of the mapped file region is also edited immediately? i.e. is reflexive mapped? Thanks.

    Read the article

1